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 app = require('express').createServer(),io = require('socket.io').listen(app),http = require('http'); | |
app.listen(8080); | |
app.get('/', function (req, res) { | |
res.sendfile(__dirname + '/index.html'); | |
}); | |
io.sockets.on('connection', function (socket) { | |
var options = { | |
host: 'www.google.com', |
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
hello_uv: hello_uv.c | |
gcc -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I../libuv/include -o hello_uv hello_uv.c ../libuv/uv.a -pthread -lrt -lm | |
clean: | |
rm hello_uv |
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 calc = function(n, callback) { | |
var sum = function(i, res) { | |
var func = (n>i) ? sum_tick : function(j,k) {callback(k);}; | |
func(i+1, res+i); | |
}; | |
var sum_tick = function(i, res) { | |
process.nextTick(function() { sum(i,res); }); | |
}; | |
sum(1,0); | |
}; |
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 calc = function(n, callback) { | |
var sum = function(i, res) { | |
var func = (n>i) ? sum : function(j,k) {callback(k);}; | |
func(i+1, res+i); | |
}; | |
sum(1,0); | |
}; | |
calc(10, function(x) {console.log(x);}); |
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
void uv__req_init(uv_req_t* req) { | |
req->type = UV_UNKNOWN_REQ; | |
} | |
void uv_req_init(uv_loop_t* loop, uv_req_t* req) { | |
loop->counters.req_init++; | |
uv__req_init(req); | |
} |
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
uv__req_init((uv_req_t*)handle); | |
loop->counters.req_init++; |
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 unref = require('./build/Release/unref.node').unref; | |
var http = require('http'); | |
http.createServer(function(req,res){ | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Loop Counter='+unref()+'\n'); | |
}).listen(8080); |
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
// nodetime for local use | |
var uphttp = require('http'); | |
var nodetime = require('nodetime'); | |
var upload_port = 12345; | |
nodetime.on('sample', function(sample) { | |
var upload = uphttp.request({ port: upload_port, | |
method: 'POST', | |
path: '/upload' | |
}); | |
upload.end(JSON.stringify(sample)); |
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)); | |
+}; | |
+ |
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 = []; |
OlderNewer