Skip to content

Instantly share code, notes, and snippets.

View kitelife's full-sized avatar
💪
I may be slow to respond.

xiayf kitelife

💪
I may be slow to respond.
View GitHub Profile
@kitelife
kitelife / extend.js
Created April 30, 2015 06:48
JavaScript继承方案实现
function extend(Child, Parent) {
var F = function(){};
F.prototype = Parent.prototype;
Child.prototype = F();
Child.prototype.constructor = Child;
Child.uber = Parent.prototype;
}
class CORSResource(object):
"""
Adds CORS headers to resources that subclass this.
"""
def create_response(self, *args, **kwargs):
response = super(CORSResource, self).create_response(*args, **kwargs)
response['Access-Control-Allow-Origin'] = '*'
response['Access-Control-Allow-Headers'] = 'Content-Type'
return response
redswallow.me/blog/
http://www.soimort.org
http://lilydjwg.is-programmer.com/
http://weibo.com/qinjianxiang
http://rango.swoole.com/
http://www.guangla.com
www.renren.com/profile.do?id=250805736
http://blog.cooer.net
https://twitter.com/clowwindy
http://skora.net
import requests
class GithubWalker(object):
token = None
source_user = None
api_url_base = 'https://api.github.com'
user_has_walked = set()
user_id_wait_walk = []
@kitelife
kitelife / var_export.php
Last active August 29, 2015 14:04
php,打印对象/数组,返回字符串
<?php
$arrStr = var_export($arr, true);
@kitelife
kitelife / map_with_lamda.py
Created July 17, 2014 03:21
使用map和lamda表达式
keys = map(lambda element: element.strip(), keys)
@kitelife
kitelife / two_tuple_to_one_dict.py
Created July 17, 2014 03:19
python, 两个元组合并成一个字典
if len(gs) == len(keys):
gs_dict = dict(zip(keys, gs))
#! /usr/bin/env python
import argparse
import sys
import re
import time
line_nginx_full = re.compile(r"""(?P<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - - \[(?P<dateandtime>\d{2}\/[a-z]{3}\/\d{4}:\d{2}:\d{2}:\d{2} (\+|\-)\d{4})\] ((\"(GET|POST) )(?P<url>.+)(http\/1\.1")) (?P<statuscode>\d{3}) (?P<bytessent>\d+) (["](?P<refferer>(\-)|(.+))["]) (["](?P<useragent>.+)["])""",
re.IGNORECASE)
line_nginx_onlyStatus = re.compile(r'.+HTTP\/1\.1" (?P<statuscode>\d{3})')
@kitelife
kitelife / wechat_custom_menu.py
Created June 14, 2014 03:40
简单封装了微信服务号自定义菜单API
#coding: utf-8
import requests
import os
import json
import time
class WechatAdmin:
def __init__(self):