Skip to content

Instantly share code, notes, and snippets.

View tim-smart's full-sized avatar

Tim tim-smart

View GitHub Profile
@tim-smart
tim-smart / README.md
Created October 22, 2010 06:27 — forked from ucnv/README.md

This script is also available at .

@tim-smart
tim-smart / go.js
Created October 21, 2010 04:41 — forked from cainiac/go.js
function executeEventQueue() {
eventEmitter.emit(LISTENERS.executeApplicationEvents);
process.nextTick(executeEventQueue);
}
executeEventQueue();
var log = require('log');
/**
*
* @returns
*/
module.exports = {
server: {
address: '10.138.188.67',
port: 8000,
function bench (lmbd) {
var i = 0,
start = new Date().getTime()
while (i!=10000) {
lmbd()
++i
}
return new Date().getTime() - start
}
var assert = require('assert'),
EventEmitter = require('events').EventEmitter,
myEventEmitter = new EventEmitter()
var A = function(){}
// Create a Test Suite
module.exports = {
'when the topic is a regular object': function (assert) {
var a = new A();
var functions_array = [];
for (var i = 1; i < 4; i++) {
(function(index) {
functions_array[index] = function() {
var data = index;
sys.puts(data);
};
})(i);
};
@tim-smart
tim-smart / twi.js
Created August 31, 2010 01:15 — forked from amrnt/twi.js
var sys = require('sys'),
http = require('http'),
ws = require("./vendor/ws"),
arrays = require('./vendor/arrays');
var headers = {};
headers['Host'] = "search.twitter.com";
var clients = [];
fetch = ->
Git.readFile version, Path.join('articles', "#{name}.markdown"), preprocess
preprocess = (err, markdown) ->
return finish err if err
props = preProcessMarkdown markdown
finish Data.author version, props.author if props.author
finish {}
finish = (err, author) ->
var POOLSIZE = 8*1024;
var pool;
function allocPool () {
pool = new Buffer(POOLSIZE);
pool.used = 0;
}
function FastBuffer (subject, encoding, legacy, slice_legacy) {
var length, type;
class Planet
constructor: (@name,@size,@x,@y) ->
@ships = {}
@damage_pool = {}
add_ships: (player,amount) ->
#add ships to an array based on the player who owns them
log("adding #{amount} ships to player #{player}")
if @ships[player]?
@ships[player] += amount