Skip to content

Instantly share code, notes, and snippets.

View boneyao's full-sized avatar
🤡
Don't try to find me!

boneyao boneyao

🤡
Don't try to find me!
  • ChengDu
View GitHub Profile
@boneyao
boneyao / keybase.md
Created September 21, 2018 03:52
keybase.md

Keybase proof

I hereby claim:

  • I am boneyao on github.
  • I am boneyao (https://keybase.io/boneyao) on keybase.
  • I have a public key whose fingerprint is 1273 C7B2 AA2D F4F3 6640 430E ADF2 2F50 B8E0 2E59

To claim this, I am signing this object:

@boneyao
boneyao / tree.md
Created February 18, 2017 06:21 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@boneyao
boneyao / profile.py
Created February 6, 2017 03:22 — forked from QuantumGhost/profile.py
A simple decorator for profiling python function.
import cProfile
import functools
import pstats
from cStringIO import StringIO
def profile(func):
@functools.wraps(func)
def wrapped(*args, **kwargs):
nginx_format = '$remote_addr => $upstream_addr [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_cookie" $request_time $upstream_response_time "$proxy_add_x_forwarded_for" $upstream_cache_status'
_map = {
'$remote_addr': '%h',
'$upstream_addr': '%^', #nq
'$time_local': '%d:%t +0800',
'$request': '%r',
'$status': '%s',
'$body_bytes_sent': '%b',
'$http_referer': '%R',
"$http_user_agent": '%u',