Skip to content

Instantly share code, notes, and snippets.

View maxp's full-sized avatar

Maxim Penzin maxp

View GitHub Profile
#!/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/
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;
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):
# 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):
@maxp
maxp / yamlnode.java
Created February 22, 2010 07:27
yanmnode helper for SnakeYAML
//
// YamlNode helper
// author: mpenzin@gmail.com
// date: 2010-02-22
//
package util;
import java.util.ArrayList;
import java.util.Collection;
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;
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
[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
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)
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]