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 walk(obj, pre, post) { | |
var k, v; | |
obj = (pre||I)(obj); | |
if (typeof(obj) === 'object') { | |
for (k in obj) if (obj.hasOwnProperty(k)) { | |
v = (post||I)(walk(k)); | |
if (v === undefined) { | |
delete obj[k]; | |
} else { | |
obj[k] = v; |
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 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]) |
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
ipdb> type(x) | |
<class 'gcapi.api.json_views.entity'> | |
ipdb> isinstance(x, son) | |
False | |
ipdb> print x.__class__.__base__.__bases__ | |
(<type 'dict'>, <class 'gcapi.api.json_views.son'>) | |
ipdb> son | |
<class 'api.json_views.son'> | |
woah: |
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
ipdb> type(x) | |
<class 'gcapi.api.json_views.entity'> | |
ipdb> isinstance(x, son) | |
False | |
ipdb> print x.__class__.__base__.__bases__ | |
(<type 'dict'>, <class 'gcapi.api.json_views.son'>) | |
ipdb> son | |
<class 'api.json_views.son'> |
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 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]) |
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 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): |
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 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): |
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 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) ) |
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
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 |
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
Grammar: | |
Var -> x | y | z | |
Exp -> Var | AEx | MEx | |
MEx -> Exp (*|/) Exp | |
AEx -> Exp (+|-) Exp | |
Parsing: | |
x / y + z |