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
-- 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 |
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
-- 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 |
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
/* | |
* 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 { |
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
/* | |
* str = db:get_last_error() | |
*/ | |
static int dbclient_get_last_error(lua_State *L) { | |
DBClientBase *dbclient = userdata_to_dbclient(L, 1); | |
string result = dbclient->getLastError(); | |
lua_pushlstring(L, result.c_str(), result.size()); | |
return 1; | |
} |
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
ffi.cdef([[ | |
struct ifaddrs { | |
struct ifaddrs *ifa_next; /* Next item in list */ | |
char *ifa_name; /* Name of interface */ | |
unsigned int ifa_flags; /* Flags from SIOCGIFFLAGS */ | |
struct sockaddr *ifa_addr; /* Address of interface */ | |
struct sockaddr *ifa_netmask; /* Netmask of interface */ | |
union { | |
struct sockaddr *ifu_broadaddr; /* Broadcast address of interface */ | |
struct sockaddr *ifu_dstaddr; /* Point-to-point destination address */ |
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 <cstdint> | |
#include <iostream> | |
#include <unordered_map> | |
struct Foo | |
{ | |
int a; | |
}; | |
uint64_t some_func(); |
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
--- returns a table of all permutations of `str` | |
local function permute_string( str ) | |
local string_byte, string_char = string.byte, string.char | |
local src = {} | |
for i = 1, #str do | |
src[i] = string_byte( str, i ) | |
end | |
local perm = {} |
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
--[[ | |
nanomsg LuaJIT FFI binding | |
Copyright (c) 2013 Evan Wies <evan at neomantra dot net> | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), | |
to deal in the Software without restriction, including without limitation | |
the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
and/or sell copies of the Software, and to permit persons to whom |
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
// gcc -o echo_client -g examples/echo_client.c -I ../nanomsg/src -L ../nanomsg/build -l nanomsg | |
// LD_LIBRARY_PATH="$LD_LIBRARY_PATH:../nanomsg/build" ./echo_client foobar | |
#include <assert.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include "nn.h" | |
#include "reqrep.h" | |
int main( int argc, const char* argv[] ) |
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
#!/bin/bash | |
usage() | |
{ | |
cat >&2 <<EOF | |
usage: $0 [-h] iface [iface2 [...]] | |
Scans for smp affinity for the interrupts on the passed interfaces. | |
Must be run as root. |
OlderNewer