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
/* | |
oh no, pump bug! | |
There is a bug in node which causes a copied stream to be corrupt when using | |
pump. | |
A workaround is to manually perform pump, by listening on('data') on the | |
readstream and write it onto the writestream like | |
w.write(data, function(err, l) { ... } | |
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 stream = ... | |
stream.on('data', function(data) { | |
data.copy(buffer, ...); | |
}); | |
vs | |
stream.on('data', function(data) { | |
dataArray.push(data); |
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 server = new web.PrefixServer(); | |
server.on('/stats', function(request, response) { | |
... | |
}); | |
server.on('/m/progress', function(request, response) { | |
... | |
}); |
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() { | |
var bs = []; | |
for (var i = 0; i < 30; i++) { | |
var b = new Buffer(1024 * 1024 * 10); | |
for (var h = 0; h < 1024*1024*10; h++) { | |
b[h]=42; | |
} |
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() { | |
var b = new Buffer(1024 * 1024 * 10); | |
for (var h = 0; h < 1024*1024*10; h++) { | |
b[h]=42; | |
} | |
var bs = []; | |
for (var i = 0; i < 30; i++) { |
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 sanitizer = function(valids, unsettable) { | |
var compile = function(valid, value) { | |
var fn = Object.prototype.toString.call(value) === '[object RegExp]' ? | |
function(query, set, unset) { | |
if (query[valid] && value.test(query[valid])) { | |
set[valid] = query[valid]; | |
} | |
} : | |
function(query, set, unset) { | |
if (valid in query) { |
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 sanitizer = function(valids, unsettable) { | |
var compile = function(valid, value) { | |
var fn = Object.prototype.toString.call(value) === '[object RegExp]' ? | |
function(query, set, unset) { | |
if (query[valid] && value.test(query[valid])) { | |
set[valid] = query[valid]; | |
} | |
} : | |
function(query, set, unset) { | |
if (valid in query) { |
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
r reduce = function(op, a) { // this method is verbose and built for speed | |
a = a.list; | |
if (!a.next) { // single item track | |
delete a.list; | |
return a; | |
} | |
if (!a.next.next) { // fast op track | |
var b = a.next; |
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 reduce = function(op, a) { // this method is verbose and built for speed | |
a = a.list; | |
if (!a.next) { // single item track | |
delete a.list; | |
return a; | |
} | |
if (!a.next.next) { // fast op track | |
var b = a.next; |
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 result = ... some js ... | |
var file = ... some html ... | |
result = file.replace(/<script ([^>]*)src=["'].*\/dev["']([^>]*)>\s*<\/script>/i, function(_, a, b) { | |
return ('<script '+a+b+'>\n').replace(/\s+/g, ' ').replace(' >', '>')+result+'\n</script>'; | |
}); |
OlderNewer