Skip to content

Instantly share code, notes, and snippets.

Domain Points Count Avg
techcrunch.com 32730 4305 7.60
nytimes.com 28185 3827 7.36
google.com 11049 1142 9.68
wired.com 10397 1474 7.05
paulgraham.com 7726 138 55.99
37signals.com 7259 489 14.84
wsj.com 6610 813 8.13
readwriteweb.com 6421 1429 4.49
arstechnica.com 5596 996 5.62
/api/get/player w/ post: {
'model': {
'id': 151,
'user': {
'id': int,
'email': str
},
'name_first': str,
'name_last': str,
'short_name': str, # short_name is a method!
from functools import wraps, partial
from inspect import getargspec
def _param_update(old_params, new_params):
args, kwargs = old_params
if type(new_params) == tuple:
if len(new_params) == 2 and type(new_params[0]) == tuple and type(new_params[1]) == dict:
args = new_params[0]
kwargs.update(new_params[1])
from functools import wraps, partial
from inspect import getargspec
def _param_update(old_params, new_params):
args, kwargs = old_params
if type(new_params) == tuple:
if len(new_params) == 2 and type(new_params[0]) == tuple and type(new_params[1]) == dict:
args = new_params[0]
kwargs.update(new_params[1])
Grammar:
Var -> x | y | z
Exp -> Var | AEx | MEx
MEx -> Exp (*|/) Exp
AEx -> Exp (+|-) Exp
Parsing:
x / y + z
andrey-fedorovs-macbook-pro:mod_wsgi-2.5 fedorov$ make
/usr/sbin/apxs -c -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -DNDEBUG -DENABLE_DTRACE -Wc,'-arch x86_64' -Wc,'-arch i386' -Wc,'-arch ppc7400' mod_wsgi.c -L/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config -arch x86_64 -arch i386 -arch ppc7400 -lpython2.6 -ldl
/usr/share/apr-1/build-1/libtool --silent --mode=compile gcc -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -I/usr/local/include -I/usr/include/apache2 -I/usr/include/apr-1 -I/usr/include/apr-1 -arch x86_64 -arch i386 -arch ppc7400 -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -DNDEBUG -DENABLE_DTRACE -c -o mod_wsgi.lo mod_wsgi.c && touch mod_wsgi.slo
mod_wsgi.c:34:19: error: httpd.h: No such file or directory
mod_wsgi.c:37:29: error: missing binary operator before token "("
mod_wsgi.c:53: error: syntax error before ‘apr_pool_t’
mod_wsgi.c:53: warning: data definition has no type or storage class
mod_wsgi
from inspect import getargspec
def filter_dict(d, fltr):
return dict( (x, d[x]) for x in fltr if x in d )
def apply_some(f, *args, **kwargs):
fspec = getargspec(f)
return f(*args, **kwargs) if fspec.keywords else f( *args, **filter_dict(kwargs, fspec.args) )
from operator import itemgetter
from itertools import groupby
get_inning = itemgetter('inning')
get_half = itemgetter('half')
def group_by_inning(es):
return groupby(sorted(es, get_inning), get_inning)
def group_by_inning_by_half(es):
from operator import itemgetter
from itertools import groupby
get_inning = itemgetter('inning')
get_half = itemgetter('half')
def group_by_inning(es):
return groupby(sorted(es, get_inning), get_inning)
def group_by_inning_by_half0(es):
from functools import wraps, partial
from inspect import getargspec
def _param_update(old_params, new_params):
args, kwargs = old_params
if type(new_params) == tuple:
if len(new_params) == 2 and type(new_params[0]) == tuple and type(new_params[1]) == dict:
args = new_params[0]
kwargs.update(new_params[1])