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
--[[============================================================================= | |
# FileName: HXProtHandler.lua | |
# Desc: 单个消息多个处理函数带有优先级的实现 | |
# Author: hanxi | |
# Email: [email protected] | |
# HomePage: http://hanxi.cnblogs.com | |
# Version: 0.0.1 | |
# LastChange: 2013-08-26 11:42:37 | |
# History: 添加优先级冲突检测 | |
=============================================================================]] |
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
#include <iostream> | |
using namespace std; | |
class A { | |
public: | |
A() { | |
q=&A::funcA; | |
cout << "q=" << q << endl; | |
//(this ->* ((A*)this)->A::q) (); |
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
--[[ deepcopy.lua | |
Deep-copy function for Lua - v0.2 | |
============================== | |
- Does not overflow the stack. | |
- Maintains cyclic-references | |
- Copies metatables | |
- Maintains common upvalues between copied functions (for Lua 5.2 only) | |
TODO |
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
#include "lua.h" | |
#include "lauxlib.h" | |
#include <stdio.h> | |
int | |
dylib_add(lua_State* L) { | |
int a = lua_tonumber(L,1); | |
int b = lua_tonumber(L,2); | |
int c = 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
#include <stdio.h> | |
#include <sys/wait.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
int main(void) | |
{ | |
pid_t pid; | |
if ((pid = fork()) < 0) |
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
--[[============================================================================= | |
# FileName: 2048.lua | |
# Desc: lua console 2048 | |
# Author: hanxi | |
# Email: [email protected] | |
# HomePage: http://www.hanxi.info | |
# Version: 0.0.1 | |
# LastChange: 2014-04-28 11:05:09 | |
# History: | |
=============================================================================]] |
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
local rawnext = next | |
function next(t,k) | |
local m = getmetatable(t) | |
local n = m and m.__next or rawnext | |
return n(t,k) | |
end | |
function pairs(t) return next, t, nil end | |
function readonly(t) | |
local proxy = {} |
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
CREATE TABLE `ScoreRank` ( | |
`Name` varbinary(64) NOT NULL, | |
`Score` int(11) DEFAULT NULL, | |
`Level` int(11) NOT NULL DEFAULT '1', | |
PRIMARY KEY (`Name`,`Level`) | |
) ENGINE=InnoDB DEFAULT CHARSET=latin1; |
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
-- bare-bones luac in Lua | |
-- usage: lua luac.lua file.lua file.out | |
local out=arg[1]..".out" | |
if arg[2]~=nil then out=arg[2] end | |
f=assert(io.open(out,"wb")) | |
assert(f:write(string.dump(assert(loadfile(arg[1]))))) | |
assert(f:close()) |
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
local tostring = tostring | |
local tonumber = tonumber | |
local ssub = string.sub | |
local sformat = string.format | |
local tconcat = table.concat | |
local tinsert = table.insert | |
local si={1,2,3,4,5,6,7,8,9} | |
function printsi(si) | |
print(tconcat(si)) |
OlderNewer