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
-- Prosody IM | |
-- Copyright (C) 2008-2009 Matthew Wild | |
-- Copyright (C) 2008-2009 Waqas Hussain | |
-- | |
-- This project is MIT/X11 licensed. Please see the | |
-- COPYING file in the source package for more information. | |
-- | |
local datamanager = require "util.datamanager"; | |
local log = require "util.logger".init("usermanager"); |
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
<?php | |
/** | |
* A command line interface for automatic downloads of image feeds | |
* | |
* @package easypopulate | |
* @author Waqas Hussain | |
* @copyright 2010 | |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License (v2 only) | |
*/ |
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 setmetatable = setmetatable; | |
local pcall = pcall; | |
local type = type; | |
local t_concat = table.concat; | |
local print = print; | |
local socket_url = require "socket.url"; | |
local http = require "socket.http"; | |
local ltn12 = require "ltn12"; |
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 coroutine = coroutine; | |
local tonumber = tonumber; | |
local string = string; | |
local setmetatable, getmetatable = setmetatable, getmetatable; | |
local pairs = pairs; | |
local deadroutine = coroutine.create(function() end); | |
coroutine.resume(deadroutine); |
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; |
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
-- 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 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
-- 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
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. |