Skip to content

Instantly share code, notes, and snippets.

from django_render.annotations import *
@url(r'^/index$', method=M.POST)
@post(text=str)
def index(request, text):
'''
curl -X "POST" -F "text=str" http://hostname.com/index
'''
return {'hello': text}

我们是谁?

“横戈跃马,互联未来”,北京跃联互动科技有限公司成立于2012年,是一家以互联网客户端产品研发为起点,集互联网多平台应用软件开发、设计、运营于一体的高科技企业。跃联互动正专注于聊天表情客户端开发与制作.

我们崇尚简单高效的创业文化,公司员工平均年龄不到30岁,60%员工具备千万级用户量互联网产品的技术研发和产品运营经验,且随着公司业务的发展在不断成长中。在成立的2年内,跃联互动已完成了A轮融资,并获得国内知名智能手机研发公司的投资。敏锐的市场洞察,和持续创新能力,是跃联互动最重要的核心竞争力。

我们做什么?

urlencode() {
# urlencode <string>
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c"
esac
git log --author="kai yang" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -
def get_ip(request):
try:
real_ip = request.META['HTTP_X_FORWARDED_FOR']
reg_ip = real_ip.split(",")[0]
except KeyError:
try:
reg_ip = request.META['REMOTE_ADDR']
except KeyError:
return 0
def datetime_to_seconds(time_in):
epoch = datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)
delta = time_in - epoch
return delta.total_seconds()
(function() {
if ( typeof Object.prototype.uniqueId == "undefined" ) {
var id = 0;
Object.prototype.uniqueId = function() {
if ( typeof this.__uniqueid == "undefined" ) {
this.__uniqueid = ++id;
}
return this.__uniqueid;
};
}
@wangtai
wangtai / nginx.conf
Last active August 29, 2015 14:12
nginx reverse proxy example
upstream main {
server web1.local:80;
server web2.local:80;
server web3.local:80;
}
location /some/path/ {
if ($host ~* "(.+)\.test\.bugua\.com$") {
set $new_host $1.bugua.com;
}
proxy_set_header Host $new_host;
def resize(file_path):
# import pdb; pdb.set_trace()
save_path = os.getcwd() + "/tmp/xxx.gif"
im = Image.open(file_path)
if im.format == 'GIF':
# rename file
new_file_path = file_path.split('.')[0] + '.gif'
@wangtai
wangtai / bobp-python.md
Created March 10, 2016 03:29 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens