Skip to content

Instantly share code, notes, and snippets.

@inimino
inimino / 1.js
Created December 19, 2009 15:06 — forked from ELLIOTTCABLE/style-1.js
function () {
if (typeof exports !== 'undefined') { from = exports }
else { from = new(Object) };
}
var email = {
send:function (options){
options = options||{};
options.to = options.to||"marak.squires@gmail.com";
options.from = options.from||"obama@whitehouse.gov";
...
var http = require('http'),
sys = require('sys'),
path = require('path'),
posix = require('posix'),
events = require('events');
var listdir = function (pathname) {
var p = new events.Promise();
var ls = process.createChildProcess("ls", [pathname]);
ls.addListener("output", function (data) {
var File = require('file'),
Sys = require('sys'),
Posix = require('posix');
// Sync api wrapper around some Posix commands
// Sells it soul to `wait`.
var posix_sync = {
readdir: function (path) {
return Posix.readdir(path).wait();
},
@inimino
inimino / test.js
Created April 21, 2010 16:26 — forked from anonymous/leak.js
# bash one-liner to run it and watch memory usage
( ./node test.js & PID=$! && trap 'kill $PID' 0; while sleep 1; do ps -o rss= -p $PID; done )
testing with curl:
inimino@kat:~$ curl -sv -m3 http://boshi.inimino.org:8080/ >/dev/null
* About to connect() to boshi.inimino.org port 8080 (#0)
* Trying 69.164.198.129... connected
* Connected to boshi.inimino.org (69.164.198.129) port 8080 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8m zlib/1.2.3.4 libidn/1.18 libssh2/1.2.1
> Host: boshi.inimino.org:8080
> Accept: */*
/*
userData = {
'person1' : [1,2,3,4],
'person2' : [3,4,5,6]
}
*/
First loop over all the userData once and construct an index.
index=[]
Inimino’s way:
foo = routine {
if argument == 1, return ‘a’
if argument == 2, return ‘b’
if argument == 3, return ‘c’
}
foo' = routine {
if argument == 2, return 'Changed'
else return foo(argument)

This is my README