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 requestlimit = function(num) { | |
var queue = []; | |
return function(req, res, next) { | |
queue.push(next); | |
var removeAndNext = function() { | |
var qindex = queue.indexOf(next); | |
if (qindex >= 0) delete queue[qindex]; | |
if (queue.length) queue[0](); | |
} |
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 paper = require('./lib/paper.js/node.js'); | |
var express = require('express'); | |
var receiver = require('./public/receiver'); | |
var webServer = express(); | |
var httpServer = require('http').createServer(webServer); | |
var io = require('socket.io').listen(httpServer); | |
io.configure(function () { io.set('transports', ['flashsocket', 'xhr-polling']); }); | |
function publishPathsToClient(socket) { |
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
read line; | |
i=1 | |
maxempty=50 | |
empty=0 | |
while [ "1" ] | |
do | |
if [ "$line" ] | |
then | |
echo :: $i blah blah : $line | |
empty=0 |
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
// on the command line: | |
// ./processPool --port poolport | |
// on any machine | |
// ./processWorker --connect poolip:poolport | |
// The process pool is a registry that delegates services to | |
// workers and knows which services are registered where. | |
var pool = ProcessPool.connect(9000); |
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
module.exports = function () { | |
var list = arguments; | |
return function (req, res, realNext) { | |
var id = -1; | |
var innerNext = function (err) { | |
if (err) return realNext(err); | |
var nextFn = ++id < list.length - 1 ? innerNext : realNext, | |
mw = list[id]; | |
mw(req, res, nextFn); | |
}; |
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
local table = require('table'); | |
function wrap(cb, fn) | |
return function(...) | |
local arg = {...}; | |
if (type(arg[cb]) == 'function') then | |
return fn(...); | |
else | |
local myargs = {...}; | |
table.insert(myargs, cb, 1); |
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 parallelResizes = 5; | |
async.mapSeries(files, function (item, cb) { | |
im.identify(source_dir + file, cb); | |
}, function (err, identifies) { | |
var queue = async.queue(function (options, callback) { | |
im.resize(options, callback); | |
}, parallelResizes); | |
identifiers.forEach(function (id) { | |
/* create options objects for every identifier-size pair and push each like this: */ queue.push(optionsSize1, optionsSize2,...); | |
}); |
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
// The original function. Nothing wrong with it. Its short and simple. | |
// The code flow is obvious. | |
function myfunction(response) { | |
db.stuff(function stuff_cb (results) { | |
var transformed = trans(results); | |
db.stuffWith(transformed, function stuffWith_cb(endResult) { | |
var finalTransform = final(endResult, transformed); | |
response.end(finalTransform); | |
}); |
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 (){ | |
// update test | |
var root = this; | |
var SopaBlackout = function(){}; | |
var addEvent = function(obj, type, fn, ref_obj){ | |
if (obj.addEventListener){ | |
obj.addEventListener(type, fn, false); | |
}else if (obj.attachEvent){ | |
obj["e"+type+fn] = 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
import B = module("b"); | |
class A extends B.B { | |
g(): number { return super.f(); } | |
}; |