Skip to content

Instantly share code, notes, and snippets.

@neomantra
neomantra / gist:1540828
Created December 30, 2011 18:00
luamongo run_command
/*
* res,err = db:run_command(dbname, lua_table or json_str, options)
*/
static int dbclient_run_command(lua_State *L) {
DBClientBase *dbclient = userdata_to_dbclient(L, 1);
const char *ns = luaL_checkstring(L, 2);
int options = luaL_tointeger(L, 4); // if it is invalid it returns 0
BSONObj command; // arg 3
try {
@neomantra
neomantra / luajit-ev.lua
Created November 30, 2011 16:56
spike of luajit-ev
-- LuaJIT binding to libev (http://libev.schmorp.de/)
--
-- uses almost-identical API to lua-ev (https://github.com/brimworks/lua-ev)
-- Author: Evan Wies <neomantra at gmail>
--
local ffi = require('ffi')
local bit = require("bit")
local band, bor = bit.band, bit.bor
@neomantra
neomantra / gist:1125619
Created August 4, 2011 16:55
mongol API sketch
-- mongol is based on the mongo C driver:
-- http://api.mongodb.org/c/current/
-- BSON types are marshalled just like luamongo:
-- http://code.google.com/p/luamongo/wiki/BsonTypes
-- new empty BSON object
b = bson.new()
-- new BSON object