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
// Usage | |
var workerFibo = createPromiseWorker(function(x){ | |
return (function fibo(n){ | |
if (n > 1) { | |
return fibo(n - 1) + fibo(n - 2); | |
} else { | |
return 1; | |
} | |
})(x) | |
}); |
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 truncate(str, maxlength) { | |
return (str.length > maxlength) ? str.slice(0, maxlength - 1) + '…' : str; | |
} | |
function getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
function getRandomKey(arr) { | |
return arr[getRandomInt(0, arr.length - 1)]; |
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
shell = Components.classes["@mozilla.org/browser/shell-service;1"] | |
.getService(Components.interfaces.nsIShellService); | |
var ios = Components.classes["@mozilla.org/network/io-service;1"] | |
.getService(Components.interfaces.nsIIOService); | |
var ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"] | |
.getService(Components.interfaces.nsIScriptSecurityManager); | |
var dsm = Components.classes["@mozilla.org/dom/storagemanager;1"] | |
.getService(Components.interfaces.nsIDOMStorageManager); | |
NewerOlder