Skip to content

Instantly share code, notes, and snippets.

View mranney's full-sized avatar

Matt Ranney mranney

View GitHub Profile
// 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');
process.nextTick(function () {
sys.puts("Running from nextTick");
})
setTimeout(function () {
sys.puts("Running from setTimeout 0.");
}, 0);
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'),
i, letters = "abcdefghijklmnopqrstuvwxyz", letter = 0;
function build_string(len) {
var j, out = "";
for (j = 0; j < len ; j += 1) {
out += letters[letter];
}
letter += 1;
if (letter > (letters.length - 1)) {
[Wed, 14 Apr 2010 17:06:05 GMT] [info] [<0.31388.1>] 127.0.0.1 - - 'POST' /logs/ 201[Wed, 14 Apr 2010 17:06:06 GMT] [error] [<0.2924.0>] ** Generic server <0.2924.0> terminating
** Last message in was {prompt,[<<"map_doc">>,{[{<<"_id">>,
<<"178922d051243d05aee7a312d48416f2">>},{<<"_rev">>,
<<"1-f55cf232223bb62922c62370d531ca1f">>},{<<"apns_token">>,<<>>},
{<<"command_id">>,<<"4">>},
{<<"hostname">>,<<"js-rv-laptop">>},{<<"log_id">>,
<<"1271264764556_4619768055">>},
{<<"message">>,
[<<"TRACE 2010-04-14 10:06:03.830426 | Platform.cpp:138 | sock_udp_bind | bound address 0 to fd 10 ">>,
<<"TRACE 2010-04-14 10:06:03.830572 | Platform.cpp:297 | sock_tcp_bind | bound address 0 to fd 11 ">>,
TypeError: Cannot call method 'lastIndexOf' of null
at Object.basename (node.js:311:30)
at resolveModulePath (node.js:446:13)
at loadModule (node.js:460:24)
at require (node.js:618:12)
at REPLServer.<anonymous> (eval at <anonymous> (repl:68:28))
at REPLServer.readline (repl:68:19)
at Stream.<anonymous> (repl:29:19)
at IOWatcher.callback (net:310:14)
at node.js:748:9
#!/bin/sh
#
PATH=/Users/mjr/work/node
node --version
PATH=/usr/local/bin
node --version