Skip to content

Instantly share code, notes, and snippets.

View spin6lock's full-sized avatar

John Luk spin6lock

View GitHub Profile
@spin6lock
spin6lock / pip.log
Created May 11, 2012 16:32
the error log when installing tweets2pdf
$ pip install -vv tweets2pdf/
Unpacking ./tweets2pdf
Running setup.py egg_info for package from file:///home/john/code/tweets2pdf
running egg_info
creating pip-egg-info/tweets2pdf.egg-info
writing pip-egg-info/tweets2pdf.egg-info/PKG-INFO
writing top-level names to pip-egg-info/tweets2pdf.egg-info/top_level.txt
writing dependency_links to pip-egg-info/tweets2pdf.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/tweets2pdf.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
@spin6lock
spin6lock / zmqrpc.py
Created May 11, 2012 08:14
zmq rpc demo
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys, os
import time
import itertools
from weakref import KeyedRef, ref, WeakValueDictionary
import traceback
import functools
import zmq
@spin6lock
spin6lock / dictstruct.py
Created May 10, 2012 10:21
construct a dict like the map in lua
# -*- coding:utf-8 -*-
def __sorted_cmp__(a, b):
try:
return cmp(int(a), int(b))
except ValueError:
return cmp(a, b)
class dictstruct(object):
"""
@spin6lock
spin6lock / zlib_example.php
Created March 19, 2012 02:55
a demo to decompress report data
<?php
$raw_data = "x\x01E\xcd\xd1\n\x80 \x0c\x05\xd0_\x91='L\xa5\xa0~%$,F\x05jP\xfa\x14\xfd{\xb3\x88\xde\xee\xce\xd8\xdd\t\xe3:\x0fn'\x07\x9d\x80DG\x82J@\xcc\x81G\xcdi\xdf<\x1d\x9c\xfb\x1e\xa2\x0b\xc4\xcb\x06\x995*-\x8dT\xad\xc0\xb63Xn~RX\xc8Z\xc6\xaf\x18k\xac\xf3\xd3L\xe9}\xe4\xa7-\x14\x98\x16\x17#\xf9\x82\n\xae\x1bl\x06\$Z";
$unzip_data = gzuncompress($raw_data);
var_dump($unzip_data);
?>
@spin6lock
spin6lock / curl.php
Created March 14, 2012 06:50
php curl api example
<?php
$local = True;
$raw_data_public = 'data={"area":"0505u", "big_area":"1","net":"telcom", "view_type":1}';
$raw_data_local = 'data={"area":"八月十五", "big_area":"广东区","net":"telcom", "view_type":1}';
$url_public = 'http://c40.txsj.0505u.com:8080/gmapi/channel/';
$url_local = 'http://219.136.138.172:8080/gmapi/channel/';
if ($local){
$data = base64_encode($raw_data_local);
$url = $url_local;
}