Skip to content

Instantly share code, notes, and snippets.

@thejh
thejh / durstenfeld_shuffle.coffee
Created June 1, 2011 14:17 — forked from dpritchett/durstenfeld_shuffle.coffee
durstenfeld array shuffle in coffeescript
# See http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
# written as one-liners because my REPL didn't like multiline functions this morning
# tested on CoffeeScript v1.0.1
input = [0 .. 7]
swap = (input, x, y) -> [input[x], input[y]] = [input[y], input[x]]
rand = (x) -> Math.floor Math.random() * x
durst = (input) -> swap(input, i, rand i) for i in [input.length - 1 .. 1]
"""
request ok
'Function without a name from /home/jann/gitty/node-assertvanish/request-test.js:5' (type 'Function') is still alive!
Function without a name from /home/jann/gitty/node-assertvanish/request-test.js:5
object ({'readable': true, 'writable': true, 'uri': [object], 'callback': [REFERENCE], 'pool': [object], 'dests': [object], '__isRequestRequest': true, '_redirectsFollowed': 0, 'maxRedirects': 10, 'followRedirect': true, 'method': GET, 'headers': [object], 'port': 80, 'host': www.google.de, '_events': [object], 'path': /, 'httpModule': [object], 'start': [function ""], 'ntick': true, 'response': [object], 'getAgent': [function ""], 'request': [function ""], 'pipe': [function ""], 'write': [function ""], 'end': [function ""], 'pause': [function ""], 'resume': [function ""], 'setMaxListeners': [function ""], 'emit': [function ""], 'addListener': [function ""], 'on': [function ""], 'once': [function ""], 'removeListener': [function ""], 'removeAllListeners': [function ""], 'listeners': [function ""], '_
request ok
'Function without a name from /home/jann/gitty/node-assertvanish/request-test.js:5' (type 'Function') is still alive!
Function without a name from /home/jann/gitty/node-assertvanish/request-test.js:5
object ({'readable': true, 'writable': true, 'uri': [object], 'callback': [REFERENCE], 'pool': [object], 'dests': [object], '__isRequestRequest': true, '_redirectsFollowed': 0, 'maxRedirects': 10, 'followRedirect': true, 'method': GET, 'headers': [object], 'port': 80, 'host': www.google.de, '_events': [object], 'path': /, 'httpModule': [object], 'start': [function ""], 'ntick': true, 'response': [object], 'getAgent': [function ""], 'request': [function ""], 'pipe': [function ""], 'write': [function ""], 'end': [function ""], 'pause': [function ""], 'resume': [function ""], 'setMaxListeners': [function ""], 'emit': [function ""], 'addListener': [function ""], 'on': [function ""], 'once': [function ""], 'removeListener': [function ""], 'removeAllListeners': [function ""], 'listeners': [function ""], '_
request ok
'Function without a name from /home/jann/gitty/node-assertvanish/request-test.js:5' (type 'Function') is still alive!
Function without a name from /home/jann/gitty/node-assertvanish/request-test.js:5
object ({'readable': true, 'writable': true, 'uri': [object], 'callback': [REFERENCE], 'pool': [object], 'dests': [object], '__isRequestRequest': true, '_redirectsFollowed': 0, 'maxRedirects': 10, 'followRedirect': true, 'method': GET, 'headers': [object], 'port': 80, 'host': www.google.de, '_events': [object], 'path': /, 'httpModule': [object], 'start': [function ""], 'ntick': true, 'response': [object], 'getAgent': [function ""], 'request': [function ""], 'pipe': [function ""], 'write': [function ""], 'end': [function ""], 'pause': [function ""], 'resume': [function ""], 'setMaxListeners': [function ""], 'emit': [function ""], 'addListener': [function ""], 'on': [function ""], 'once': [function ""], 'removeListener': [function ""], 'removeAllListeners': [function ""], 'listeners': [function ""], '_
NATIVE CAUSE: ServerResponse ({'statusCode': 200, 'writeContinue': [function ""], '_implicitHeader': [function ""], 'writeHead': [function ""], 'writeHeader': [function ""], 'assignSocket': [function ""], 'detachSocket': [function ""], 'destroy': [function ""], '_send': [function ""], '_writeRaw': [function ""], '_buffer': [function ""], '_storeHeader': [function ""], 'setHeader': [function ""], 'getHeader': [function ""], 'removeHeader': [function ""], '_renderHeaders': [function ""], 'write': [function ""], 'addTrailers': [function ""], 'end': [function ""], '_finish': [function ""], '_flush': [function ""], 'pipe': [function ""], 'setMaxListeners': [function ""], 'emit': [function ""], 'addListener': [function ""], 'on': [function ""], 'once': [function ""], 'removeListener': [function ""], 'removeAllListeners': [function ""], 'listeners': [function ""]})
NATIVE CAUSE: ServerResponse ({'statusCode': 200, 'writeContinue': [REFERENCE], '_implicitHeader': [function ""], 'writeHead': [function ""], 'writeHeade
Function without a name from /home/jann/gitty/node-assertvanish/request-test.js:5
object ({'readable': true, 'writable': true, 'uri': [object], 'callback': [REFERENCE], 'pool': [object], 'dests': [object], '__isRequestRequest': true, '_redirectsFollowed': 0, 'maxRedirects': 10, 'followRedirect': true, 'method': GET, 'headers': [object], 'port': 80, 'host': www.google.de, '_events': [object], 'path': /, 'httpModule': [object], 'start': [function ""], 'ntick': true, 'response': [object], 'getAgent': [function ""], 'request': [function ""], 'pipe': [function ""], 'write': [function ""], 'end': [function ""], 'pause': [function ""], 'resume': [function ""], 'setMaxListeners': [function ""], 'emit': [function ""], 'addListener': [function ""], 'on': [function ""], 'once': [function ""], 'removeListener': [function ""], 'removeAllListeners': [function ""], 'listeners': [function ""], '_started': true, 'agent': [object], 'req': [object]})
Function 'g' from events.js:141
Array ({'0': [function "g"], '1':
@thejh
thejh / gist:1057110
Created June 30, 2011 20:11
Coffee alias test
sum =* a+b
foo = ->
a = 3
b = 4
sum * 10
@thejh
thejh / getUserExample.coffee
Created July 18, 2011 12:13
getUser example for method overloading example
getUser = (*) ->
(name) when typeof name is 'string' ->
User.lookup 'name', name
(id) when typeof id is 'number' ->
User.lookup 'id', id
->
throw new Error "invalid arguments"
info - socket.io started
debug - client authorized
info - handshake authorized 2644789511415902503
debug - setting request GET /socket.io/1/websocket/2644789511415902503
debug - set heartbeat interval for client 2644789511415902503
debug - client authorized for
debug - websocket writing 1::
info - transport end
debug - set close timeout for client 2644789511415902503
debug - cleared close timeout for client 2644789511415902503
var lightnode = require('lightnode');
var http = require('http');
var assertvanish = require('./index');
var fileServer = new lightnode.FileServer('/home/jann/gitty/node-assertvanish/');
var server = http.createServer(function(req, res) {
fileServer.receiveRequest(req, res);
});