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 | |
| grep -v \"Yandex/ |grep -v \"YaDirectBot/ |grep -v \"msnbot/ | grep -v Mediapartners-Google | grep -v Googlebot/ | \ | |
| grep -v "Yahoo! Slurp" | grep -v \"LinkWalker | grep -v \"Python-urllib | grep -v \"StackRambler/ | grep -v \"Aport\" | \ | |
| grep -v \"MLBot | grep -v \"Gigabot | grep -v \"COMODOSpider | grep -v \"ia_archiver | grep -v \"Java | \ | |
| grep -v \"Begun\ Robot\ Crawler | grep -v MJ12bot/ | grep -v Mail.Ru/ | grep -v " (Twiceler-" | \ | |
| grep -v \"Yangai\ WorldSearch\ Bot | grep -v \ DotBot/ | grep -v \ WebDataCentreBot/ | \ | |
| grep -v \ TIC/ | grep -v \ spbot/ | grep -v \"Mail.Ru/ | grep -v \ Exabot/ | grep -v \ Nigma.ru/ | \ | |
| grep -v \ Purebot/ |
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
| A basic FastCGI configuration for nginx looks like this: | |
| location /yourapplication/ { | |
| include fastcgi_params; | |
| if ($uri ~ ^/yourapplication/(.*)?) { | |
| set $path_url $1; | |
| } | |
| fastcgi_param PATH_INFO $path_url; | |
| fastcgi_param SCRIPT_NAME /yourapplication; | |
| fastcgi_pass unix:/tmp/yourapplication-fcgi.sock; |
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 math | |
| class ImmutableVector(object): | |
| __slots__ = ('_d',) | |
| def __init__(self, x, y): | |
| object.__setattr__(self, _d, (x, y)) | |
| def __setattr__(self, n, v): | |
| raise ValueError("Can't alter instance of %s" % type(self)) | |
| @property | |
| def x(self): |
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
| # Use a flag to indicate the state of the bus. | |
| class _StateEnum(object): | |
| class State(object): | |
| name = None | |
| def __repr__(self): | |
| return "states.%s" % self.name | |
| def __setattr__(self, key, value): | |
| if isinstance(value, self.State): |
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
| // | |
| // YamlNode helper | |
| // author: mpenzin@gmail.com | |
| // date: 2010-02-22 | |
| // | |
| package util; | |
| import java.util.ArrayList; | |
| import java.util.Collection; |
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
| select array_to_string(array_agg(chr(a[s])),'') "I wish you" from ( | |
| select a, generate_series(1,array_length(foo.a,1)) s from ( | |
| select array[72,97,112,112,121,32,88,109,97,115,33] as a | |
| ) foo | |
| ) bar; |
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
| fp = open(msgfile) | |
| msg = email.message_from_file(fp) | |
| fp.close() | |
| counter = 1 | |
| for part in msg.walk(): | |
| # multipart/* are just containers | |
| if part.get_content_maintype() == 'multipart': | |
| continue |
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
| [alias] | |
| s = status | |
| b = branch | |
| ba = branch -a -v -v | |
| bs = !git-branch-status | |
| bsi = !git-branch-status -i | |
| ci = commit | |
| co = checkout | |
| d = diff -C |
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
| def get_object_or_none(klass, *args, **kwargs): | |
| if isinstance(klass, Manager): | |
| manager = klass | |
| klass = manager.model | |
| else: | |
| manager = klass._default_manager | |
| try: | |
| return manager.get(*args, **kwargs) |
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
| def plural( n, s ): | |
| '''returns one of three s[] depends on number | |
| [1-час,234-часа,5-часов,] | |
| ''' | |
| n = abs(n) | |
| if n in (11,12,13,14): | |
| return s[2] | |
| n = n % 10 | |
| if n == 1: | |
| return s[0] |