This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hook_tb = {} | |
local function hook_index(o, key) | |
print("get", key) | |
if type(o["data"][key]) ~= "table" then | |
return o["data"][key] | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###lua class设计 | |
* 首先要有super chain, 能够正确无误的调用super方法 | |
* 在create阶段绑定所有的attribute,在create结束后,应该禁用掉一切我外部绑定新attribute的方法,防止别人改掉内省逻辑 | |
* 所有数据成员,应该具有一个初始值设定,对数据对象的生命,应该调用self:define_attribute(key, value, defaultValue) | |
* 对于回收时刻,应该对每一个attribute,变更成初始状态的值 | |
* 应该支持面向接口集合的delegate,以便进行组合 | |
* 应该对对象内置函数和状态位之间的hook来进行状态位的绑定,不给外部改变状态的机会 | |
* 其他优化点 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "src/third/socket.lua" | |
local time_table = {} | |
local function hook_timer(o, key, value) | |
if type(value) == "function" and value ~= "summary" then | |
local function inner( ... ) | |
time_table[key] = time_table[key] or 0.0 | |
print("in function ",key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rpc_lua = {} | |
function rpc_lua:call(fn_name, ...) | |
return self[fn_name](self, ...) | |
end | |
function rpc_lua:test1(arg1, arg2, arg3) | |
print "test1" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rpc_lua = {} | |
function rpc_lua:call(fn_name, ...) | |
return self[fn_name](self, ...) | |
end | |
function rpc_lua:test1(arg1, arg2, arg3) | |
print "test1" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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): |
OlderNewer