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
// Two options for writing transportable custom assertions (for both | |
// options, the only API the runner needs to provide is an assert | |
// function). Guess which one I prefer. | |
// | |
// Option 1 | |
// API | |
assert(someHelperfunc(expected, actual), message); | |
// Implementation |
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
// JSON.stringify(require('uglify-js').parser.parse('{1 + ""} + 10;'), null, 2); | |
[ | |
"toplevel", | |
[ | |
[ | |
"block", | |
[ | |
[ | |
"stat", |
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
require('modulr').buildFromPackage(__dirname, function(e, result) { | |
if (e) { | |
throw e; | |
} | |
console.log(result); | |
}); |
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 url = 'http://dev.w3.org/html5/spec/Overview.html', | |
options = { runScripts: false }, | |
t0 = new Date(); | |
require('zombie').visit(url, options, function (err, browser) { | |
console.log('That took', (new Date() - t0) / 1000, 'seconds!!!'); | |
}); | |
// Killed the process after having it ran for > 1 hour | |
// For comparison, visiting google.com took ~ 2.5 seconds. |
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
---:test-npm $ mkdir package | |
---:test-npm $ cd package | |
---:package $ echo '{"name":"foo","version":"0.1.0"}' > package.json | |
---:package $ npm install async | |
async@0.1.9 ./node_modules/async | |
---:package $ cd .. | |
---:test-npm $ mkdir no-package | |
---:test-npm $ cd no-package/ | |
---:no-package $ npm install async | |
async@0.1.9 ../../../../node_modules/async |
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
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl http://npmjs.org/install.sh | sh |
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 lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>untitled</title> | |
<script type="text/javascript" charset="utf-8"> | |
alReady = function( n, t, ready ) { | |
ready = function(){ for ( t = 0; ready && t < n; ) ready[ t++ ](); ready = 0 } | |
document.addEventListener && document.addEventListener( "DOMContentLoaded", ready, false ) |
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
process.nextTick = function (callback) { | |
if (arguments.length == 1) { | |
nextTickQueue.push(callback); | |
} else { | |
var args = Array.prototype.slice.call(arguments, 1); | |
nextTickQueue.push(function() { | |
callback.apply(null, args); | |
}); | |
} | |
process._needTickCallback(); |
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
win.$script.domReady = function(fn) { | |
doc[readyState].exec(/in/) ? timeout(function() { win.$script.domReady(fn); }, 50) : 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 r(f){setTimeout(/in/(document.readyState)?r:f,9,f)} |