This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
class CompressHtmlMiddleware(object): | |
def __init__(self): | |
self.whitespace = re.compile(r'^\s+', re.MULTILINE) | |
self.linebreak = re.compile(r'\n', re.MULTILINE) | |
def process_response(self, request, response): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var module = angular.module('yaMetrika', | |
[] | |
); | |
module.provider('yaMetrika', function() { | |
var counter = null; | |
this.setCounter = function(ycounter) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Jekyll | |
module Compressor | |
def compress_html(content) | |
content.gsub(/(?>[^\S ]\s*|\s{2,})(?=(?:(?:[^<]++|<(?!\/?(?:textarea|pre)\b))*+)(?:<(?>textarea|pre)\b|\z))/ix, '') | |
end | |
def output_file(dest, content) | |
FileUtils.mkdir_p(File.dirname(dest)) | |
File.open(dest, 'w') do |f| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'i18n' | |
# Create folder "_locales" and put some locale file from https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale | |
module Jekyll | |
module I18nFilter | |
# Example: | |
# {{ post.date | localize: "%d.%m.%Y" }} | |
# {{ post.date | localize: ":short" }} | |
def localize(input, format=nil) | |
load_translations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Thread | |
from queue import Queue | |
tasks = {} | |
def task_consumer(queue): | |
while True: | |
try: | |
task, args, kwargs = queue.get() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import calendar | |
def month_day_range(date): | |
first_day = date.replace(day = 1) | |
last_day = date.replace(day = calendar.monthrange(date.year, date.month)[1]) | |
return first_day, last_day |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# base iptables rules | |
# run by /etc/rc.local | |
iptables -F INPUT | |
iptables -Z INPUT | |
iptables -P INPUT ACCEPT | |
iptables -F OUTPUT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
text-rendering: optimizeLegibility; | |
font-feature-settings: "kern"; | |
font-kerning: normal; | |
-webkit-font-smoothing: antialiased; | |
-moz-osx-font-smoothing: grayscale; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
host='user@host' | |
path='/home/path_to_project' | |
[deploy] | |
hg pull | |
hg update | |
LD_LIBRARY_PATH=/usr/local/lib \ | |
python3.4 manage.py migrate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo ln -s /lib/x86_64-linux-gnu/libncurses.so.5.9 /lib/libtermcap.so.2 |