Skip to content

Instantly share code, notes, and snippets.

@baudehlo
Created March 23, 2011 23:20
Show Gist options
  • Save baudehlo/884245 to your computer and use it in GitHub Desktop.
Save baudehlo/884245 to your computer and use it in GitHub Desktop.
matt@Valour /tmp$ cat client.js
var fullchunk;
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
if (!fullchunk) {
fullchunk = "";
}
fullchunk += chunk;
});
process.stdin.once('end', function () {
process.stdin.removeAllListeners('data');
eval(fullchunk);
console.log("Eval: >>" + fullchunk + "<<");
});
matt@Valour /tmp$ cat server.js
require("http").createServer(function(request, response) {
console.log("connection!");
response.writeHead(200);
response.end("Hello World");
}).listen(3000);
matt@Valour /tmp$ node client.js < server.js
Eval: >>require("http").createServer(function(request, response) {
console.log("connection!");
response.writeHead(200);
response.end("Hello World");
}).listen(3000);
<<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment