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
Array.prototype.splice.call(document.querySelectorAll("h2,h3,h4,h5,h6"), 0). | |
map(function (el, n) { | |
var txt, id; | |
id = el.getAttribute("id"); | |
txt = el.innerText; | |
if (!id) { | |
el.setAttribute("id", encodeURIComponent(txt)); | |
} |
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
# Available here: http://www.cl.cam.ac.uk/~rja14/book.html | |
# Easy download using curl | |
curl -O http://www.cl.cam.ac.uk/~rja14/Papers/SEv2-c[01-27].pdf | |
curl -O http://www.cl.cam.ac.uk/~rja14/Papers/SEv2-{ack,index,toc,pref,acks,biblio}.pdf |
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
<!doctype html> | |
<html> | |
<head> | |
<title>Plot</title> | |
<script type="text/javascript"> | |
// Looking at this formula, just for fun | |
// http://en.wikipedia.org/wiki/Logistic_map | |
var R = Math.PI / 2; | |
var Rmax = 4; |
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
var a = Q.delay(100).thenResolve("a is done"); | |
var b = Q.delay(110).thenResolve("b is done"); | |
var c = Q.delay(120).thenResolve("c is doen"); | |
Q.all([a, b, c]).spread(function (a, b, c) { console.log("all", a, b, c); }); | |
a.then(function (a) { console.log("a only", a); }); |
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 (global, rand) { | |
var prefix = "setImmediate-"; | |
var counter = 0; | |
var tasks = {}; | |
global.setImmediate = function (cb, params) { | |
var id = prefix + counter++ + rand(); | |
tasks[id] = { | |
fn: cb, p: params || [] | |
}; |
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 forEach(a, fn) { | |
var i; | |
for (i in a) { | |
if (a.hasOwnProperty(i)) { | |
fn.call(null, a[i], i, a); | |
} | |
} | |
} | |
function map(a, fn) { |
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 (input) { | |
return [].reduce.call(input, function (mem, n, i) { | |
return mem[i % 5] = n, mem.push(Math.max(mem.pop(), eval(mem.join("*")))), mem; | |
}, [0, 0, 0, 0, 0, 0]).pop(); | |
} | |
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
#!/bin/sh | |
# | |
# simulate_3g.sh - Simulate a sluggish 3G network with delays & packet loss | |
# Usage: simulate_3g.sh 8080 8081 | |
# Make sure only root can run our script | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi |
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
// Paraphrased from http://teppo.tv/haikueditori/haikueditori.js | |
var rVowels = /[aeiouyåäö]/i; | |
var rConsonants = /[bcdfghjklmnpqrstvwxz]/i; | |
var rDiphthongs = /(aa|ee|ii|oo|uu|yy|åå|ää|öö|ai|ei|oi|ui|yi|åi|äi|öi|au|eu|iu|ou|äy|öy|ie|uo|yö|ey|iy)/i; | |
function isVowel(chr) { | |
return rVowels.test(chr); | |
} |