This script is also available at .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Parent () { | |
this.name = 'Roger' | |
} | |
Parent.prototype.yell = function yell () { | |
var parent = this | |
console.log('My name is ' + parent.name + '!!') | |
return parent | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Object = {} | |
function Object:new (...) | |
local ret = setmetatable({}, { __index = self }) | |
if ret.__init then | |
ret:__init(...) | |
end | |
return ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local http = require('http') | |
local qs = require('querystring') | |
local json = require('json') | |
local table = require('table') | |
local headers = | |
{ ['Accept'] = 'application/json' | |
, ['Content-Length'] = 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async = require('async-array').async | |
one = async [1, 2, 3, 4] | |
two = async ['one', 'two', 'three'] | |
one | |
.map (id, i, next) -> | |
db.query 'SELECT * FROM x WHERE id = ?', [id], next | |
two |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ubuntu: | |
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND | |
18452 thepeopl 20 0 44332 6776 4228 S 0.0 1.3 0:00.10 node | |
Solaris: | |
PID USER LWP PRI NICE SIZE RES STATE TIME CPU COMMAND | |
10016 node 1 59 0 15M 7932K sleep 0:00 0.00% ../node/node run.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ClientPool = function ClientPool (port, host, max_clients) { | |
this.port = +port; | |
this.host = host; | |
this.max_clients = max_clients || 200; | |
this.clients = []; | |
this.free = []; | |
var pointer = 0; | |
Object.defineProperty(this, 'pointer', { | |
enumerable: false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var events = require('events'); | |
var Queue = function () { | |
var self = this; | |
this.array = Array.prototype.slice.call(arguments); | |
this.offset = 0; | |
this.lock = false; | |
this.process = function () { | |
// Do some processing here... |