Skip to content

Instantly share code, notes, and snippets.

diff -r 35ff8e3c8093 Makefile
--- a/Makefile Mon Jul 22 06:08:14 2019 -0400
+++ b/Makefile Fri Mar 20 09:34:00 2020 -0400
@@ -9,7 +9,7 @@
gcc memmon.c -shared -o memmon.so -fPIC -I/usr/include/lua$(LUA_VERSION)/ -Wall -Werror
lua-memmon: memmon.c lua52.c
- gcc -Wall -Werror -DLUA_COMPAT_ALL -O0 memmon.c lua52.c -o lua-memmon -fPIC -I/usr/include/lua5.2/ /usr/lib/x86_64-linux-gnu/liblua5.2.so -ldl -lm -Wl,-dynamic-list,exports.txt
+ gcc -Wall -Werror -DENABLE_MALLOC_TRACE -DLUA_COMPAT_ALL -O0 memmon.c lua52.c -o lua-memmon -fPIC -I/usr/include/lua5.2/ /usr/lib/x86_64-linux-gnu/liblua5.2.so -ldl -lm -Wl,-dynamic-list,exports.txt
@echo
{
"name": "x",
"version": "1.0.0",
"description": "",
"main": "main.js",
"dependencies": {
"flocks.js": "^1.6.1",
"javascript-state-machine": "^2.3.5",
"react": "^0.13.3",
"reflux": "^0.2.8"
function event_handler(event)
-- Do stuff
end
module:hook("event", event_handler)
function logger(event, handler_chain)
local r = handler_chain(event);
log("debug", "event %s was handled, the handler returned %s", event, tostring(r));
@zeen
zeen / gist:9491993
Last active August 29, 2015 13:57
Relax mod_component host check to allow node@host components
diff -r c0ee152400ff plugins/mod_component.lua
--- a/plugins/mod_component.lua Sun Mar 09 23:48:32 2014 +0100
+++ b/plugins/mod_component.lua Tue Mar 11 14:30:49 2014 -0400
@@ -197,8 +197,8 @@
local from = stanza.attr.from;
if from then
if session.component_validate_from then
- local _, domain = jid_split(stanza.attr.from);
- if domain ~= session.host then
+ local node, domain = jid_split(stanza.attr.from);
@zeen
zeen / tabber.lua
Last active December 23, 2015 00:39
Convert tabs to spaces while aligning with columns
local tabsize = 4;
function tabber(s)
local t = {};
for part in s:gmatch("[^\t]*") do
t[#t+1] = part;
t[#t+1] = "\t";
end
t[#t] = nil;
local n = 0;
for i=1,#t do
@zeen
zeen / xbench.lua
Created September 17, 2012 18:30
A basic XMPP benchmark script
--
-- XMPP server benchmark tool
--
options = {
username = "waqas";
hostname = "example.com";
resource = "x";
password = " ";
#!/usr/bin/env lua
do
local _parse_sql_actions = { [0] =
0, 1, 0, 1, 1, 2, 0, 2, 2, 0, 9, 2, 0, 10, 2, 0, 11, 2, 0, 13,
2, 1, 2, 2, 1, 6, 3, 0, 3, 4, 3, 0, 3, 5, 3, 0, 3, 7, 3, 0,
3, 8, 3, 0, 3, 12, 4, 0, 2, 3, 7, 4, 0, 3, 8, 11
@zeen
zeen / dnsutil.lua
Created April 8, 2012 22:28
Pure Lua DNS parser, serializer, pretty printer
local t_insert,t_concat = table.insert,table.concat;
local s_char = string.char;
local pairs,ipairs = pairs,ipairs;
local type = type;
local tostring,tonumber = tostring,tonumber;
-- DNS Parser
-- The following is a parser for the DNS format defined in RFC1035
// ==UserScript==
// @name Kill StackOverflow Logo
// @namespace http://prosody.im
// @description Kill StackOverflow Logo
// @version 0.0.1
// @match http://stackoverflow.com/*
// ==/UserScript==
try {
document.getElementById("hlogo").style.display="none"
function bin(x)
local s,m={}
for i=0,7 do
m=x%2;x=(x-m)/2;
s[8-i]=m;
end
return table.concat(s);
end