This file contains hidden or 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
// domain stack sample #3 | |
var domain = require('domain'); | |
var d1 = domain.create(); | |
var d2 = domain.create(); | |
var d3 = domain.create(); | |
d1.on('error', function(err) { | |
console.log('d1:', err.message); | |
}); | |
d2.on('error', function(err) { |
This file contains hidden or 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
// domain stack sample #3 | |
var domain = require('domain'); | |
var d1 = domain.create(); | |
var d2 = domain.create(); | |
var d3 = domain.create(); | |
d1.on('error', function(err) { | |
console.log('d1:', err.message); | |
}); | |
d2.on('error', function(err) { |
This file contains hidden or 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
// domain stack sample | |
var domain = require('domain'); | |
var d1 = domain.create(); | |
var d2 = domain.create(); | |
var d3 = domain.create(); | |
d1.on('error', function(err) { | |
console.log('d1:', err.message); | |
}); | |
d2.on('error', function(err) { |
This file contains hidden or 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
// domain stack sample | |
var domain = require('domain'); | |
var d1 = domain.create(); | |
var d2 = domain.create(); | |
var d3 = domain.create(); | |
d1.on('error', function(err) { | |
console.log('d1:', err.message); | |
}); | |
d2.on('error', function(err) { |
This file contains hidden or 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
--- node_modules/tower/node_modules/superagent/lib/node/index.js.org 2012-06-03 04:27:15.000000000 +0900 | |
+++ node_modules/tower/node_modules/superagent/lib/node/index.js 2012-06-13 10:07:53.142584979 +0900 | |
@@ -458,6 +458,29 @@ | |
// initiate request | |
var mod = exports.protocols[url.protocol]; | |
+ // use proxy | |
+ if(process.env.http_proxy) { | |
+ var proxy = parse(process.env.http_proxy); | |
+ if (url.protocol === 'http:') { |
This file contains hidden or 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 io = require('socket.io').listen(8081); | |
var parser = require('socket.io').parser; | |
io.sockets.on('connection', function(socket) { | |
var pre; | |
var i = 0; | |
io.transports[socket.id].parser.on('data', function(p) { | |
var packet = parser.decodePacket(p); | |
if(packet.type === 'heartbeat') { | |
if(global.gc) global.gc(); | |
var memoryUsage = process.memoryUsage(); |
This file contains hidden or 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 io = require('socket.io').listen(8081); | |
var parser = require('socket.io').parser; | |
io.sockets.on('connection', function(socket) { | |
var pre; | |
var i = 0; | |
io.transports[socket.id].parser.on('data', function(p) { | |
var packet = parser.decodePacket(p); | |
if(packet.type === 'heartbeat') { | |
var memoryUsage = process.memoryUsage(); | |
var rss = memoryUsage.rss; |
This file contains hidden or 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 http = require('http'); | |
var ran = 0; | |
var queryNum = 100; | |
var parallel = 10; | |
var agent = new http.Agent({maxSockets: parallel}); | |
if (process.argv.length != 5) { | |
console.error('usage: node http-request.js host port url\n' + | |
'ex). node http-request.js example.com 8080 /index.html'); | |
process.exit(-1); |
This file contains hidden or 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 tls = require('tls'); | |
var fs = require('fs'); | |
var zlib = require('zlib'); | |
var events = require('events'); | |
var util = require('util'); | |
var dictionary = require('./dict.js').dictionary; | |
var word = '<!DOCTYPE html><html><head><title>Hello SPDY</title></head><body>Hello SPDY</body></html>'; | |
function parseNV_HeaderBlock(buffer) { | |
var nv = []; |
This file contains hidden or 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
--- a/lib/domain.js | |
+++ b/lib/domain.js | |
@@ -136,7 +136,15 @@ Domain.prototype.remove = function(ee) { | |
}; | |
Domain.prototype.run = function(fn) { | |
- this.bind(fn)(); | |
+ this.bind(fn).apply(null, Array.prototype.slice.call(arguments,1)); | |
+}; | |
+ |