Skip to content

Instantly share code, notes, and snippets.

@wthit56
wthit56 / gist:4427971
Last active December 10, 2015 11:29 — forked from anonymous/gist:4427822
// run here (use the data-uri below as an address):
// data:text/html;ascii,<script src="https://gist.github.com/raw/4427971/cef83fed8b6de8bfbb9fa3ae461b724fff87c057/gistfile1.js" type="text/javascript"></script>
// The technique used here is based on an article by Ashley Gullen: http://netm.ag/SWI0E5
// Array#slice returns an array with the seleted range of items.
// Because a new array is created every time you use this method, however,
// all these arrays are in memory, which means the JavaScript GC (Garbage Collection)
// has to collect up all of these unused arrays and throw them away.
// In performance-critical situations, such as in a game-loop that needs to run within
@pguillory
pguillory / gist:729616
Created December 5, 2010 23:51
Hooking into Node.js stdout
var util = require('util')
function hook_stdout(callback) {
var old_write = process.stdout.write
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
write.apply(process.stdout, arguments)
callback(string, encoding, fd)
}