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
XSL files to convert Wordpress XMPP services table into XML. | |
curl http://xmpp.org/resources/public-services/ > services.html | |
xsltproc --html services-full.xsl services.html > services-full.xml | |
xsltproc --html services.xsl services.html > services.xml |
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
-- Recive a HTTP POST and relay it | |
-- Author: Waqas Hussain | |
-- Derived from mod_post_msg by Kim Alvefur <[email protected]> | |
-- Some code borrowed from mod_webpresence | |
-- | |
-- Example usage: | |
-- curl http://example.com:5280/presence/user -d "Hello there" | |
-- or | |
-- curl http://example.com:5280/presence/[email protected] -d "Hello there" | |
-- This would set presence of [email protected] with status 'Hello there' |
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
require "socket" | |
client = socket:tcp(); | |
client:connect("localhost", 5582); | |
while true do | |
local ch = client:receive(1); | |
if string.char(0) == ch 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
-- mod_limit_subscription | |
-- Limits subscription requests to admins | |
local st = require "util.stanza"; | |
local is_admin = usermanager.is_admin; | |
function subscription_handler(event) | |
local origin, stanza = event.origin, event.stanza; | |
if stanza.attr.type == "subscribe" and not is_admin(origin.full_jid, module.host) 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
I have DNS records with weights. Need to select/sort randomly by weight. Problem: Distribution of the random variable I have is undefined. | |
Current plan: | |
Get random number X = N uniformly random bits from rand(0,1)<0.5 (von Neumann's fair coin from unfair). | |
2^N >= sum(weights). X <= sum(weights). X would be uniform over sum(weights). Right? | |
Select kth number from list such that sum(Weight1...Weightk)>X. | |
1. Is this correct? | |
2. Is there a better way (I'd like to minimize rand() calls and processing in general)? | |
3. von Neumann's fair coin method works with two coin tosses for every fair toss. Can I reuse the last toss of the old pair in the next? That would cut rand() down by half. |
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
-- lua-ev emulation using socket.select | |
local READ, WRITE = 0x01, 0x02; | |
local timeout = 5; | |
local Loop = {}; | |
function Loop.new() | |
print("Loop:new") |
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
function waqas_MattyMath(){ | |
var $wnd_0 = window, $doc_0 = document, gwtOnLoad, bodyDone, base = '', metaProps = {}, values = [], providers = [], answers = [], onLoadErrorFunc, propertyErrorFunc; | |
if (!$wnd_0.__gwt_stylesLoaded) { | |
$wnd_0.__gwt_stylesLoaded = {}; | |
} | |
if (!$wnd_0.__gwt_scriptsLoaded) { | |
$wnd_0.__gwt_scriptsLoaded = {}; | |
} | |
function isHostedMode(){ | |
var result = 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
-- mod_muc_broadcast.lua | |
local jid_bare = require "util.jid".bare; | |
local st = require "util.stanza"; | |
module:hook("message/bare", function(event) | |
local stanza = event.stanza; | |
if stanza.attr.type == "chat" or stanza.attr.type == "normal" or not stanza.attr.type then | |
local from = jid_bare(stanza.attr.from); |
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
function ini_parse(text) | |
text = "[]\n"..text:gsub(";[^\n]*\n", ""); -- remove comments and add dummy section | |
local result = {}; | |
local section = ""; | |
local lineno = 0; | |
for line in text:gmatch("([^\n]+)") do | |
lineno = lineno + 1; | |
local block = line:match("^%[([^%]*)%]$"); | |
if block then | |
section = block; |
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 gettime = require "socket".gettime; | |
module "shaper" | |
local shaper = {}; | |
function shaper:update() | |
local newt = gettime(); | |
local elapsed = newt - self.t; |