Skip to content

Instantly share code, notes, and snippets.

View bcoe's full-sized avatar
💭
hackin'

Benjamin E. Coe bcoe

💭
hackin'
View GitHub Profile
@bcoe
bcoe / writer.py
Created September 2, 2011 18:14
writer.py
import time
from karait import Message, Queue
print 'Starting python writer.'
messages_written = 0
start = time.time()
queue = Queue()
while True:
@bcoe
bcoe / reader.rb
Created September 2, 2011 18:16
reader.rb
require 'rubygems'
require 'karait'
require 'yaml'
puts "Starting ruby reader/writer"
messages_read = 0.0
start_time = Time.now().to_f
queue = Karait::Queue.new
@bcoe
bcoe / results.yaml
Created September 2, 2011 18:19
results.yaml
---
sender: writer.py
messages_read_per_second: 1653.29212369982
started_running: 1314790290.33488
messages_written_per_second: 1900.18564215637
messages_written: 106199
messages_read: 110250.0
@bcoe
bcoe / example-karait.js
Created September 12, 2011 19:56
example-karait.js
exports.Queue = function(params, onQueueReady) {
if (typeof(params) === 'function') {
onQueueReady = params;
params = {};
}
var defaults = {
host: 'localhost',
port: 27017,
@bcoe
bcoe / example-mongodb.js
Created September 12, 2011 19:59
example-mongodb.js
Collection.prototype.insertAll = function insertAll (docs, options, callback) {
if('function' === typeof options) callback = options, options = {};
if(options == null) options = {};
if(!('function' === typeof callback)) callback = null;
// ... Function body.
};
@bcoe
bcoe / example-express.js
Created September 12, 2011 20:02
example-express.js
res.sendfile = function(path, options, fn){
var self = this
, req = self.req
, next = this.req.next
, options = options || {};
// support function as second arg
if ('function' == typeof options) {
fn = options;
@bcoe
bcoe / example-jsdom.js
Created September 12, 2011 20:07
example-jsdom.js
exports.jQueryify = exports.jsdom.jQueryify = function (window /* path [optional], callback */) {
var args = Array.prototype.slice.call(arguments),
callback = (typeof(args[args.length - 1]) === 'function') && args.pop(),
path,
jQueryTag = window.document.createElement("script");
if (args.length > 1 && typeof(args[1] === 'string')) {
path = args[1];
}
@bcoe
bcoe / example-jsdom.js
Created September 12, 2011 20:07
example-jsdom.js
exports.jQueryify = exports.jsdom.jQueryify = function (window /* path [optional], callback */) {
var args = Array.prototype.slice.call(arguments),
callback = (typeof(args[args.length - 1]) === 'function') && args.pop(),
path,
jQueryTag = window.document.createElement("script");
if (args.length > 1 && typeof(args[1] === 'string')) {
path = args[1];
}
@bcoe
bcoe / before.js
Created September 12, 2011 20:11
before.js
exports.func = function(options, callback) {
if (typeof(options) === 'function') {
callback = options;
options = {};
}
callback = callback || function() {};
// ... Function body.
@bcoe
bcoe / after.js
Created September 12, 2011 20:13
after.js
exports.func = function(options, callback) {
sexy.args([this], function() {
// ... Function body.
});
}