Skip to content

Instantly share code, notes, and snippets.

View akirayu101's full-sized avatar
🥅
Focusing

Akira Yu akirayu101

🥅
Focusing
  • Bytedance
  • Hangzhou.China
View GitHub Profile
## 空state,不产生任何的效果
class State(object):
def __init__(self):
pass
def enter(self, entity, param_table, state_maintain, global_maintain):
pass
def update(self, entity, param_table, state_maintain, global_maintain):
pass
-- Internal register table
local _class={}
--Create an class(为了不与cocos2d-x中给出的class的名字冲突,这里创建接口改名为luaClass)
function luaClass(base)
local superType = type(base)
local vtbl = {}
local class_type = {}
class_type.ctor = false
-- error message monad here
data E a = Success a | Error String
unitE a = Success a
errorE s = Error s
(Success a) `bindE` k = k a
(Error s) `bindE` k = Error s
showE (Success a) = "Success: " ++ showval a
showE (Error s) = "Error: " ++ s
showpos :: Position -> String
@akirayu101
akirayu101 / simple_spider.py
Last active August 29, 2015 14:11
test gevent simple spider
__author__ = 'hzyuxin'
import requests
from gevent import monkey
monkey.patch_all()
import gevent
main_url = 'http://www.cellmap.cn/cellmap_gsm2gps_api.aspx'
def job(lac, cell):
a = {}
a["__realdata"] = {}
a["__realdata"]["a"] = 1 -- save const a
a["__realdata"]["b"] = 2 -- save const b
local function const_index(o, key) return o["__realdata"][key] end
local function const_newindex(o, key, value) return end
setmetatable(a, {__index = const_index, __newindex = const_newindex})
print(a["a"])
print(a["b"])
require "src/modules/traceback.lua"
hook_tb = {}
local function hook_index(o, key)
local function_name, filename, line = traceback.getsource(4)
logger:fatal("access hook_tb in funtion[%s] filename[%s] line[%d]", function_name, filename, line)
@akirayu101
akirayu101 / test_gm.lua
Created November 27, 2014 09:41
test gm
rpc_lua = {}
function rpc_lua:call(fn_name, ...)
return self[fn_name](self, ...)
end
function rpc_lua:test1(arg1, arg2, arg3)
print "test1"
end
@akirayu101
akirayu101 / simple_lua_rpc.lua
Created November 27, 2014 03:31
simple_lua_rpc
rpc_lua = {}
function rpc_lua:call(fn_name, ...)
return self[fn_name](self, ...)
end
function rpc_lua:test1(arg1, arg2, arg3)
print "test1"
end
* Generate classes like WhereNot automatically with class decorator?
* Haskell style deconstruction, perhaps like:
@pmatch
def count(first_arg=Match(x=Head, *xs=Rest)):
print x, xs
Will require some nasty hacks like https://github.com/smcq/python-inject
* Implement boolean operators for stuff like:
@pmatch