Skip to content

Instantly share code, notes, and snippets.

View mranney's full-sized avatar

Matt Ranney mranney

View GitHub Profile
@mranney
mranney / output.txt
Created March 23, 2010 07:41
example of multi-repl
(in window 1)
rv-mjr2:~$ node repltest.js
node via stdin> foo
'stdin is fun'
(in window 2)
rv-mjr2:~$ telnet localhost 5000
Trying ::1...
var fs = require('fs'),
sys = require('sys');
fs.stat("/tmp", function(err, stat_data) {
if (err !== null) {
sys.puts(err.stack);
}
else {
sys.puts(sys.inspect(stat_data));
}
var sys = require('sys'),
http = require('http');
http.createServer(function (req, res) {
setTimeout(function () {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Hello World');
res.close();
}, 2000);
}).listen(8000);
var sys = require("sys"),
http = require("http"),
port = 12345,
spawn = require("child_process").spawn;
function gzipStr (str, callback) {
var child = spawn("gzip", ["-c", "-f", "-n"]),
stdout = "", stderr = "";
child.stdout.addListener("data", function (chunk) {
// on OSX, connecting to 127.0.0.2 will wait a long time and fail to connect
// If you change the IP to 127.0.0.1, this program connects.
var sys = require("sys"),
http = require("http"),
out_client = http.createClient(5984, "127.0.0.2"),
out_request = out_client.request("GET", "/_all_dbs", {
"Host": "localhost"
});
out_request.addListener("response", function (out_response) {
Starting CouchDB...
Eshell V5.7.4 (abort with ^G)
1> Apache CouchDB 0.11.0 (LogLevel=info) is starting.
1> Apache CouchDB has started. Time to relax.
1> [info] [<0.35.0>] Apache CouchDB has started on http://127.0.0.1:5984/
1> [info] [<0.105.0>] 127.0.0.1 - - 'GET' /_all_dbs 200
1> [info] [<0.98.0>] 127.0.0.1 - - 'GET' / 200
1> [info] [<0.101.0>] 127.0.0.1 - - 'GET' /_session 200
1> [info] [<0.106.0>] 127.0.0.1 - - 'GET' / 200
1> [info] [<0.106.0>] 127.0.0.1 - - 'GET' /_utils 301
Uncaught Exception: Error: Stream already opened
at Client.connect (net:585:22)
at Client._reconnect (http:564:12)
at ClientRequest.<anonymous> (http:572:14)
at ClientRequest.flush (http:355:8)
at ClientRequest.<anonymous> (http:376:8)
at ClientRequest.end (http:463:33)
at ClientRequest.close (http:454:15)
at IncomingMessage.<anonymous> (/usr/local/lib/log_server/logfront.js:385:29)
at HTTPParser.onMessageComplete (http:97:23)
var sys = require('sys'), i;
function get_printer(timeout) {
return function () {
sys.puts("Running from setTimeout " + timeout);
};
}
process.nextTick(function () {
sys.puts("Running from nextTick");
var sys = require('sys'),
child_process = require('child_process'),
ls = child_process.spawn("ls", []),
exit;
exit = function (data) {
sys.puts(data);
ls.removeListener('exit', exit);
}
var sys = require('sys');
process.nextTick(function () {
sys.puts("Running from nextTick");
})
setTimeout(function () {
sys.puts("Running from setTimeout 0.");
}, 0);