Skip to content

Instantly share code, notes, and snippets.

@sidneylimafilho
Created October 4, 2011 04:28
Show Gist options
  • Save sidneylimafilho/1260907 to your computer and use it in GitHub Desktop.
Save sidneylimafilho/1260907 to your computer and use it in GitHub Desktop.
Counterproof node is a cancer
var http = require("http");
function fibonacci(n, callback) {
if (n < 2) return 1;
if (callback)
setTimeout(function () { callback(fibonacci(n - 2) + fibonacci(n - 1)) }, 0);
else
return fibonacci(n - 2) + fibonacci(n - 1);
}
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
fibonacci(40, function (r) { res.end(String(r)) });
}).listen(1337, "127.0.0.1");
//
// Sample only to prove the non blocking
//
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end("Non Blocking! " + req.query);
}).listen(1338, "127.0.0.1");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment