This file contains hidden or 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
/** | |
* $Id: md5.c,v 1.2 2008/03/24 20:59:12 mascarenhas Exp $ | |
* Hash function MD5 | |
* @author Marcela Ozorio Suarez, Roberto I. | |
*/ | |
#include <string.h> | |
//#include "md5.h" |
This file contains hidden or 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 a lua table, no recursion sub table, the key never be a table. | |
local function _copy(obj, target) | |
local n = 0 | |
-- clear target table | |
for k,v in pairs(target) do | |
if type(v) == "table" then | |
v.__del = true | |
n = n + 1 | |
else |
This file contains hidden or 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> | |
int | |
main() { | |
double f = 1.0/3.0; | |
double f2; | |
char tmp[100]; | |
sprintf(tmp, "%lf", f); | |
sscanf(tmp, "%lf", &f2); | |
printf("f = %lf f2 = %lf , %d\n", f, f2, (f2 == f)); // should be 0 (false) |
This file contains hidden or 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 <stdlib.h> | |
#include <time.h> | |
#include <assert.h> | |
struct memnode { | |
struct memnode * next; | |
}; | |
struct fixalloc { |
This file contains hidden or 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 skynet = require "skynet" | |
local socket = require "socket" | |
local mode , id = ... | |
local function echo(id) | |
socket.start(id) | |
skynet.error("start", id) | |
while true do |
This file contains hidden or 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 yield = coroutine.yield | |
local function loadlog(filename) | |
-- local log = {} | |
local f = assert(io.open(filename)) | |
for line in f:lines() do | |
if line == "=======" then | |
break | |
end | |
local ptr, osize, nsize, ret = line:match("([^ ]+) (%d+) (%d+) ([^ ]+)") |
This file contains hidden or 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 DIRSEP, PATSEP, MARK = package.config:match "(.-)\n(.-)\n(.-)\n" | |
MARK = MARK:gsub(".", function (c) return "%" .. c end) | |
-- todo: replace your own readable function | |
local function readable(filename) | |
local f = io.open(filename) | |
if f then | |
f:close() | |
return true | |
end |
This file contains hidden or 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 M = {} | |
function M.test(...) | |
print(...) | |
end | |
return M |
This file contains hidden or 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 skynet = require "skynet" | |
require "skynet.manager" | |
local mode = ... | |
if mode == "slave" then | |
skynet.start(function() | |
skynet.dispatch("lua", function(session, address, ti, ...) | |
if session == 0 then |
This file contains hidden or 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 FUNC_TEMP=[[ | |
local $ARGS | |
return function(...) | |
$SOURCE | |
end, | |
function() | |
return {$LOCALS} | |
end | |
]] |