Skip to content

Instantly share code, notes, and snippets.

View tim-smart's full-sized avatar

Tim tim-smart

View GitHub Profile
function Parent () {
this.name = 'Roger'
}
Parent.prototype.yell = function yell () {
var parent = this
console.log('My name is ' + parent.name + '!!')
return parent
}
@tim-smart
tim-smart / utils.lua
Created July 2, 2012 23:24
My common utilities for my luvit projects.
local Object = {}
function Object:new (...)
local ret = setmetatable({}, { __index = self })
if ret.__init then
ret:__init(...)
end
return ret
local http = require('http')
local qs = require('querystring')
local json = require('json')
local table = require('table')
local headers =
{ ['Accept'] = 'application/json'
, ['Content-Length'] = 0
}
--langdef=js
--langmap=js:.js
--regex-js=/([A-Za-z0-9_$]+)[ \t]*[:=][ \t]*function[A-Za-z0-9_$ \t]*\(/\1/f, function, functions/
--regex-js=/\[[ \t]*['"]([A-Za-z0-9_$ ]+)['"][ \t]*\][ \t]*=[ \t]*function[A-Za-z0-9_$ \t]*\(/\1/f, function, functions/
--regex-js=/['"]([A-Za-z0-9_$ ]+)['"][ \t]*:[ \t]*function[A-Za-z0-9_$ \t]*\(/\1/f, function, functions/
--regex-js=/function[ \t]+([A-Za-z0-9_$]+)[ \t]*([^)])/\1/f, function, functions/
--regex-js=/(\b[A-Z][A-Za-z0-9_$]*)[ \t]*=[ \t]*new[ \t]+/\1/v, variable, variables/
--regex-js=/(\b[A-Z][A-Z0-9_$]*)[ \t]*=/\1/c, constant, contants/
--langdef=coffee
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
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/([A-Za-z0-9_$]+)[ \t]*[:=][ \t]*\([^)]*\)[ \t]*[-=]>/\1/,function/
--regex-coffee=/([A-Za-z0-9_$]+)[ \t]*[:=][ \t]*[-=]>/\1/,function/
--regex-coffee=/^[^#]*class[ \t]+([A-Za-z0-9_$]+)/\1/,class/
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
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,
@tim-smart
tim-smart / README.md
Created October 22, 2010 06:27 — forked from ucnv/README.md

This script is also available at .

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...