I hereby claim:
- I am geekkeen on github.
- I am mouse_house (https://keybase.io/mouse_house) on keybase.
- I have a public key ASA8KSnrLs_9Y8m3Iou9U5okQWog1wXOhwaseMGPPOL_3Ao
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
type APIHandler func(http.ResponseWriter, req *http.Request, ps httprouter.Params) | |
type Decorator func(APIHandler) APIHandler | |
func Log(logf lg.AppLogFunc) Decorator{ | |
return func(f APIHandler) APIHandler{ | |
return func(w http.ResponseWriter, req *http.Request, ps httprouter.Parms){ | |
start = time.Now() | |
response, err = f(w, req, ps) | |
elapsed = time.Since(Start) | |
status := 200 |
# awk 使用方法 | |
cat ad.platform.site | awk '{ split($27,url,"?"); if($33>5000 && $34 == "msecs" && $22 == "Oct" && $23 == 29 ) {print $22,$23,$24,url[1],$33,$34}}' |
# Find an insteresting code about the relationship `Schedule` and `Job` in apschedule | |
Class Job(obejct): | |
def __init__(self, scheduler, id, **kwargs): | |
self._scheduler = scheduler | |
self.id = id | |
def modify(self, job, **changes): | |
self._scheduler.modify_job(self.id, **changes) | |
def get_callable_name(func): | |
if hasattr(func, '__qualname__'): | |
return func.__qualname__ | |
# get func's class | |
f_self = getattr(func, '__self__', None) or getattr(func, 'im_self', None) | |
if f_self and hasattr(func, '__name__'): | |
# bound method class | |
f_class = f_self if isinstance(f_self, type) else f_self.__calss__ | |
else: |
class MemoizedSlots(object): | |
def _fallback_getattr(self, key): | |
raise AttributeError(key) | |
def __getattr__(self, key): | |
if key.startswith('_memoized'): | |
raise AttributeError(key) | |
elif hasattr(self, '_memoized_attr_%s' % key): | |
value = getattr(self, '_memoized_attr_%s' % key)() | |
setattr(self, key, value) |
def get_labels(model, *filter_options): | |
unnest_lables = db.session.query(func.unnest(getattr(model, 'labels'))).filter(*filter_options) | |
labels = set() | |
def _walk(iterable): | |
for item in iterable: | |
if isinstance(item, tuple): | |
_walk(item) | |
else: | |
labels.add(item) |
class FileStorage(object): | |
def __init__(self, stream, **kwargs): | |
self.stream = stream | |
def __getattr__(self, name) | |
return getattr(self.stream, name) |
class FileWrapper(object): | |
def __init__(self, file, buf_size=8192): | |
self.file = file | |
self.buf_size = buf_size | |
def close(self): | |
if hasattr(self.file, 'close'): | |
self.file.close() | |
def __iter__(self): |
class JobLookupError(KeyError): | |
def __init__(self, job_id): | |
super(KeyError, self).__init__(u'No job by the id of %s was found' % job_id) | |
raise JobLookupError(job_id) |