Skip to content

Instantly share code, notes, and snippets.

$posts = Mango::factory('posts')->load(FALSE);
foreach($posts as $post)
{
$content .= Kohana::debug($post->as_array());
// clean up
$post->delete();
}
var redis = require('redis'),
client1 = redis.createClient(), client2 = redis.createClient(),
msg_count = 0, sys = require('sys');
//List of jobs to do
var _jobs = [];
for (var i = 0; i < 1000; i++) {
function eat() {
var q = _queue.pop(), l = _queue.length;
if (q === undefined) {
sys.debug("Nothing to eat :(");
}
else {
doWork(q);
}
var args = process.argv.slice(2);
var exargs = {
'-a' : function(val) {
if(!val) return;
console.log('Arg a does stuff with ' + val);
},
'-b' : function() {
console.log('arg b in da house');
//Expected arguments w. actions
var exargs = {
//help
'-h' : function() { abort(usage); },
//directory where modules reside
'-w' : function(val) {
if (!val) return;
worker.moduleDirs.push(val);
worker.reloadModules();
},
@troufster
troufster / hax.css
Created October 18, 2010 09:34
hej
width: 96%;font-size:11px;display:block;clear:both;list-style:none;margin:10px 10px 10px 5px;padding:7px;background-color : #FFFFE6;color: #775100;border : 1px solid #FEE37A;font: 11px verdana,arial,sans-serif;
@troufster
troufster / HashMap.js
Created November 22, 2010 19:45
Javascript 2d spatial hash
var HashMap = function(cell_size) {
this.cell_size = cell_size;
this.grid = [];
}
HashMap.prototype._key = function(vec) {
var cellsize = this.cell_size;
return Math.floor(vec.x/cellsize) * cellsize + ' ' +
Math.floor(vec.y/cellsize) * cellsize;
}
@troufster
troufster / bisonbuffer.js
Created January 4, 2011 19:51
Dead simple buffering
//Buffering bison "packets" before websockets to remove overhead
var bison = require('./bison');
var o1 = { name : "sven", nested : { boolzor : true } };
var o2 = { name : "rolf" };
var buf = [];
buf.push(o1);
/**
* Hairy Balls FSM
*
*/
var FSM = function(s, is) {
this.states = s;
this.iState = is;
this.curState = is;
}
@troufster
troufster / Zone.js
Created January 12, 2011 18:49
Draft of js spatial hash
/**
* Module dependencies
*/
var Vector = require('../public/lib/vector'),
_floor = Math.floor;