Skip to content

Instantly share code, notes, and snippets.

View sirpengi's full-sized avatar

shu.chen sirpengi

View GitHub Profile
@sirpengi
sirpengi / saml.py
Created September 25, 2014 20:38
for saml
import time
def cry():
print "T.T;"
time.sleep(1)
T = type('T', tuple(), {'__getattr__': lambda s, k: cry()})()
lonely = True
while lonely:
@sirpengi
sirpengi / yolodb.py
Created September 27, 2014 18:23
yolodb
class YOLODBType(object):
pass
def YOLODB():
class val():
v = None
def _T(f, c, g, is_root=False):
class T(YOLODBType):
def __str__(self):
return str(g.v)
@sirpengi
sirpengi / blah.js
Created February 12, 2015 21:42
what is this
var evaluate = function(f) {
var args = copyArgs(arguments, 1)
if (_.isFunction(f)) {
return f.apply(f, args);
}
return f
};
[shuchen@archy stuff]$ python2.7 a.py
module A being imported!
module B being imported!
module A being imported!
hollering from A
hollering from A
import string
import sys
class count_dict(dict):
"""
stub object used to simplify tracking
the number of letters encountered.
this expects to be initialized with an uppercase letter yo.
"""
(py27)[shuchen@archy Downloads]$ cat test.py
from docutils.core import publish_string
import pstats, cProfile
fn = 'foo.rst'
profile_fn = fn + '.prof'
with open(fn) as fh:
data = fh.read()
def gogogo():
>>> a = lambda x: 1000
>>> a
<function <lambda> at 0xb77f88b4>
>>> a(1)
1000
>>> (id(a(1)), id(a(1)))
(143414124, 143414124)
>>> (id(a(1)), id(a(2)))
(143414124, 143414124)
>>> def return_1000(): return 1000
@sirpengi
sirpengi / 17x17_yes.txt
Created February 14, 2012 00:17
N-colorable grid checker
22133421413223443
24211233443411322
31344411143241232
41231323412144134
31112324234443221
13324314412212323
31424223321414413
43121113244323412
44334242312321211
12221344143334241
2011-10-15 05:05:59 dxq hi friends
2011-10-15 16:51:41 dxq hi friends
2011-10-26 04:26:09 dxq hi friends
2011-10-28 04:40:37 dxq hi friends
2011-10-29 03:47:19 dxq hi friends
2011-11-02 19:44:43 sixthgear hi friends
2011-11-04 02:44:14 dxq hi friends
2011-11-08 02:47:33 dxq hi friends
2011-11-08 23:50:36 dxq hi friends
2011-11-11 00:56:49 dxq hi friends
@sirpengi
sirpengi / decorateeverything.py
Created March 23, 2012 02:26
decorate everything!
def DecorateEverything(decorator):
"""Function that returns a metaclass that decorates
all class callables (except those starting with __)
with `decorator`."""
class DEMeta(type):
def __init__(cls, name, bases, dct):
new_dct = {}
for k, v in dct.iteritems():
if hasattr(v, "__call__") and not k.startswith('__'):
setattr(cls, k, decorator(v))