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
function xmlEscape(s) { | |
return s.replace(/[<>&"]/g, function (c) { | |
return "&" | |
+ { "<": "lt", ">": "gt", "&": "amp", "\"": "quot" }[c] | |
+ ";"; | |
}); | |
} | |
var xml = [ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ]; |
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
Date.prototype.format = function (fmt) { | |
var date = this; | |
return fmt.replace( | |
/\{([^}:]+)(?::(\d+))?\}/g, | |
function (s, comp, pad) { | |
var fn = date["get" + comp]; | |
if (fn) { | |
var v = (fn.call(date) + |
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
function sigFigs(n, sig) { | |
var mult = Math.pow(10, | |
sig - Math.floor(Math.log(n) / Math.LN10) - 1); | |
return Math.round(n * mult) / mult; | |
} | |
alert(sigFigs(1234567, 3)); // Gives 1230000 | |
alert(sigFigs(0.06805, 3)); // Gives 0.0681 | |
alert(sigFigs(5, 3)); // Gives 5 |
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
/** | |
* Left-pad a number with zeros so that it's at least the given | |
* number of characters long | |
* @param n The number to pad | |
* @param len The desired length | |
*/ | |
function leftPad(n, len) { | |
return (new Array(len - String(n).length + 1)).join("0").concat(n); | |
} |
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
#!/usr/local/bin/python2.4 | |
import sys, email, urllib | |
print 'reQall Router invoked' | |
msg = email.message_from_file(sys.stdin) | |
content = msg['subject'].split(': ', 1)[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
function getQueryParams(qs) { | |
qs = qs.replace(/\+/g, " "); | |
var params = {}, | |
re = /[?&]?([^=]+)=([^&]*)/g, | |
tokens; | |
while (tokens = re.exec(qs)) { | |
params[decodeURIComponent(tokens[1])] | |
= decodeURIComponent(tokens[2]); | |
} |
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
function escapeXml(s) { | |
return s.replace(/([&<>'"])/g, | |
function (c) { | |
return "&" + { | |
"&": "amp", | |
"<": "lt", | |
">": "gt", | |
"'": "apos", | |
'"': "quot" | |
}[c] + ";"; |
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
/** | |
* Hack to allow jQuery to work within XHTML documents that define an xmlns | |
*/ | |
/** | |
* Use the given object to override the given methods in its prototype | |
* with namespace-aware equivalents | |
*/ | |
function addNS(obj, methods) { | |
var proto = obj.constructor.prototype; |
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
/** | |
* Note: Has hard-coded dependency on a CommonJS Unit Test 1.0 assertion module, | |
* but doesn't have to. | |
*/ | |
function Mock(intf) { | |
var expectations, failures, expect = {}; | |
for (var p in intf) { | |
if (intf.hasOwnProperty(p) && typeof intf[p] === "function") { | |
(function ($p) { |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Ates Goral <http://magnetiq.com> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
OlderNewer