Skip to content

Instantly share code, notes, and snippets.

View liutaihua's full-sized avatar

LiuTaihua liutaihua

View GitHub Profile
@liutaihua
liutaihua / proxy.go
Last active August 29, 2015 14:06 — forked from vmihailenco/proxy.go
package main
import (
"bytes"
"encoding/hex"
"flag"
"fmt"
"io"
"log"
"net"
@liutaihua
liutaihua / gist:8536621
Created January 21, 2014 08:59 — forked from musubu/gist:2202583
解析url, 把url里的query参数, 解析成json格式
var querystring = require('querystring');
var original = 'http://example.com/product/abcde.html';
var escaped = querystring.escape(original);
console.log(escaped);
// http%3A%2F%2Fexample.com%2Fproduct%2Fabcde.html
var unescaped = querystring.unescape(escaped);
console.log(unescaped);
@liutaihua
liutaihua / __init__.py
Created November 7, 2012 09:21 — forked from ipconfiger/__init__.py
OAuth包,实现了sina,QQ,网易,搜狐的OAuth认证
# -*- Encoding: utf-8 -*-
import base64
import binascii
import cgi
import hashlib
import hmac
import logging
import time
import urllib
import urlparse
@liutaihua
liutaihua / asynciostream.py
Created June 13, 2012 06:54 — forked from zuriby/asynciostream.py
Tornado IO Stream Handler
class StreamHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
def get(self):
self.post()
@tornado.web.asynchronous
def post(self):
self.ioloop = tornado.ioloop.IOLoop.instance()
self.pipe = self.get_pipe()
self.ioloop.add_handler(
@liutaihua
liutaihua / nginx-SLA
Created April 28, 2012 09:52
nginx log collector for opentsdb
#!/usr/bin/env python
# -*-mode: python; coding: iso-8859-1 -*-
#
# Copyright (c) Liu taihua <[email protected]>
"""
Usage:
[-h|--help] [-t interval=60] [-c cluster=Nanhui] [-H prefer=hostname|IP] [-v|--verbose True|False]
Example:
@liutaihua
liutaihua / hashdos
Created April 2, 2012 13:47
hashdos
#-*- coding:utf8 -*-
#!/usr/bin/env python
import socket
import sys
import math
import urllib
import string
import time
import urlparse