Skip to content

Instantly share code, notes, and snippets.

View spin6lock's full-sized avatar

John Luk spin6lock

View GitHub Profile
local list = {}
local v_map = {}
local count = 20
math.randomseed(os.time())
local function gen_data()
for i=1,count do
local r = math.random(1, 100)
list[i] = {objid=r}
v_map[r] = r
@spin6lock
spin6lock / xls2lua_pool.diff
Created August 13, 2018 09:16
xls2lua_pool_vs_xls2lua
diff xls2lua_pool.py xls2lua.py !10017
20,21d19
< from multiprocessing import Pool
< from functools import partial
773,774d770
< def wrap_conv_xls(args, file_names_):
< convet_xls_file(args[0], args[1], file_names_=file_names_)
809,811d804
< p = Pool(8)
<
@spin6lock
spin6lock / xml_diff.lua
Created November 20, 2017 08:31 — forked from luxuia/xml_diff.lua
xml_diff
#! /usr/bin/env lua
--1. git config diff.xml_diff.textconv xml_diff.lua
---- file: .git/config
---- [diff "xml_diff"]
---- textconv = xml_diff.lua
--2. file: .gitattributes]
---- *.xml diff=xml_diff
@spin6lock
spin6lock / gist:62fa67397ba5049b78bb
Created September 1, 2014 11:50
A simple echo server
#!/usr/bin/env python
"""
A simple echo server
"""
import socket
host = ''
port = 50000
@spin6lock
spin6lock / xcode_compile_error.log
Created May 29, 2013 02:40
quick-cocos2dx LuaHostMac compile error
This file has been truncated, but you can view the full file.
Build Preparation
Dependency cycle for target 'LuaHostMac' detected: LuaHostMac -> LuaHostMac
Build target libquickcocos2dx
ProcessPCH /Users/MobileGame/Library/Developer/Xcode/DerivedData/LuaHostMac-certifysiadpjhbqxeskvaiuofpk/Build/Intermediates/PrecompiledHeaders/libquickcocos2dx-ambgnlepjrpfnzgpszalouayuxqz/libquickcocos2dx.pch.pth libquickcocos2dx.pch normal i386 c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/MobileGame/Work/quick-cocos2d-x/lib/proj.mac
@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
@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 / 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 / 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 / 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