Skip to content

Instantly share code, notes, and snippets.

View mafintosh's full-sized avatar

Mathias Buus mafintosh

View GitHub Profile
/*
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) { ... }
var stream = ...
stream.on('data', function(data) {
data.copy(buffer, ...);
});
vs
stream.on('data', function(data) {
dataArray.push(data);
var server = new web.PrefixServer();
server.on('/stats', function(request, response) {
...
});
server.on('/m/progress', function(request, response) {
...
});
(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;
}
(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++) {
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) {
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) {
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;
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;
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>';
});