Skip to content

Instantly share code, notes, and snippets.

View spin6lock's full-sized avatar

John Luk spin6lock

View GitHub Profile
@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;
}
@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 / 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 / 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 / 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 / update.py
Created August 10, 2012 07:01
python update
# -*- coding: utf-8 -*-
def update(module_name):
import types, gc, re
def test_and_process_list(obj, old, new):
if not isinstance(obj, list): return
# find the references in list
refs = [ index for index, item in enumerate(obj) if item is old ]
# update the list
@spin6lock
spin6lock / psd_hater.txt
Created November 8, 2012 02:38
why PSD is a bad format[by Xee] translated to Chinese[working on it]
// At this point, I'd like to take a moment to speak to you about the Adobe PSD format.
// PSD is not a good format. PSD is not even a bad format. Calling it such would be an
// insult to other bad formats, such as PCX or JPEG. No, PSD is an abysmal format. Having
// worked on this code for several weeks now, my hate for PSD has grown to a raging fire
// that burns with the fierce passion of a million suns.
现在,请允许我花一小会给你说一下adobe家的psd格式。PSD不是一个好格式,它甚至算不上一个坏格式。
将它称为坏格式,简直是对其他坏格式的侮辱,例如PCX或者JPEG。TMD,PSD是一个糟糕透了的格式。
在连续数周码这段代码之后,我对PSD的厌恶已经增长到犹如狂暴的怒火,猛烈得犹如灿烂千阳。
@spin6lock
spin6lock / snapshot_analyze.py
Last active October 14, 2015 01:08
a simple tool to gen report from two OBJ_DUMP snapshot
#encoding:utf8
def analyze(filename):
statics = {}
with open(filename) as fh:
for line in fh:
infos = line.split()
obj_name, obj_size, _, refs = infos[0:4]
statics[obj_name] = [int(refs), int(obj_size)]
return statics
@spin6lock
spin6lock / gdb_bt.log
Created May 10, 2013 07:09
cocos-2dx HelloLua demo core dump
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./HelloLua'.
Program terminated with signal 11, Segmentation fault.
#0 0x0000000000000000 in ?? ()
(gdb) bt
#0 0x0000000000000000 in ?? ()
#1 0x00007fea6fbc5c82 in cocos2d::CCGLProgram::initWithVertexShaderByteArray (this=0x21e9900,
vShaderByteArray=0x7fea6fce18f8 '\t' <repeats 13 times>, "\nattribute vec4 a_position;\t\t\t\t\t\t\t\nattribute vec2 a_texCoord;\t\t\t\t\t\t\t\nattribute vec4 a_color;\t\t\t\t\t\t\t\t\n", '\t' <repeats 13 times>, "\n#ifdef GL_ES\t\t\t\t\t\t\t\t\t\t\nvarying lowp vec4 v_fragmentColor;\t\t\t\t\t\nvarying m"...,
fShaderByteArray=0x7fea6fce1b00 '\t' <repeats 11 times>, "\n#ifdef GL_ES\t\t\t\t\t\t\t\t\nprecision lowp float;\t\t\t\t\t\t\n#endif\t\t\t\t\t\t\t\t\t\t\n", '\t' <repeats 11 times>, "\nvarying vec4 v_fragmentColor;\t\t\t\t\nvarying vec2 v_texCoord;\t\t\t\t\t\nuniform sampler2D CC_Texture0;\t\t\t\t\n", '\t' <repeats 11 time
@spin6lock
spin6lock / compile_error.log
Created May 27, 2013 09:16
compile error on native code integrating
/Users/mobileGame/Work/quick-cocos2d-x/lib/proj.android/../cocos2d-x/scripting/lua/cocos2dx_support/LuaCocos2d.cpp: In function 'int tolua_Cocos2d_CCTMXMapInfo_getTileProperties00(lua_State*)':
/Users/mobileGame/Work/quick-cocos2d-x/lib/proj.android/../cocos2d-x/scripting/lua/cocos2dx_support/LuaCocos2d.cpp:41775:75: error: invalid conversion from 'void*' to 'int' [-fpermissive]
/Users/mobileGame/Work/quick-cocos2d-x/lib/proj.android/../cocos2d-x/scripting/lua/cocos2dx_support/LuaCocos2d.cpp:41775:75: error: cannot convert 'char const*' to 'int*' for argument '3' to 'int toluafix_pushusertype_ccobject(lua_State*, int, int*, void*, char const*)'
/Users/mobileGame/Work/quick-cocos2d-x/lib/proj.android/../cocos2d-x/scripting/lua/cocos2dx_support/LuaCocos2d.cpp: In function 'int tolua_Cocos2d_CCTMXMapInfo_formatWithTMXFile00(lua_State*)':
/Users/mobileGame/Work/quick-cocos2d-x/lib/proj.android/../cocos2d-x/scripting/lua/cocos2dx_support/LuaCocos2d.cpp:42113:75: error: invalid conversion from 'void*' to 'int' [-fp