Skip to content

Instantly share code, notes, and snippets.

View heapwolf's full-sized avatar
🕷️
Vault of the Black Spiders

heapwolf heapwolf

🕷️
Vault of the Black Spiders
View GitHub Profile
@heapwolf
heapwolf / abs.js
Created January 2, 2012 04:21
Math.abs() performance
var test = require('testling');
test('Math.abs performance', function (t) {
var t0 = new Date;
for (var i = 0; i < 100 * 1000; i++) Math.abs(i - 50 * 1000)
t.log(new Date - t0);
t.end();
});
@heapwolf
heapwolf / director usage
Created November 29, 2011 21:34 — forked from anonymous/director usage
figuring out how to use director (flatiron js)
var routes = {
'/track' : {
on: function() {
alert('a');
},
'/:id' : {
on: function(id){
alert('b');
}
}
/*! Cross-browser-compatible setZeroTimeout
*
* I took the original setZeroTimeout and made it cross-browser-compatible, using setTimeout(fn, 0) as a fallback in case postMessage is not supported.
* Mathias Bynens <http://mathiasbynens.be/>
* See <http://mathiasbynens.be/notes/settimeout-onload>
*
* Copyright statement below:
*
* See <http://dbaron.org/log/20100309-faster-timeouts>
* By L. David Baron <dbaron@dbaron.org>, 2010-03-07, 2010-03-09
$(".content").weld(
{
some : "data",
user : "tmpvar"
},
{
map : function(key, value) {
$(this).attr("foo", value); // key is null if it is an array.
},
method : "append" // defines what action the insert method should do.
function queryString2JSON() {
var query = {}
unescape(window.location.search).replace(/[^&\?]+/g, function(a, b) {
var c = a.split("=");
query[c[0]] = c[1];
});
return query;
}