Skip to content

Instantly share code, notes, and snippets.

Dominic Tarr dominictarr

Block or report user

Report or block dominictarr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dominictarr / hello_sinatra.rb
Created Sep 9, 2010
get started testing sinatra with capybara
View hello_sinatra.rb
require 'rubygems'
require 'sinatra/base'
class Hello < Sinatra::Base
get '/' do
"hello world"
View hello.rb
puts "hello world?"
dominictarr / base12.rb
Created Sep 10, 2010
calculate times table in base 12
View base12.rb
base = ARGV.length > 0 ? ARGV[0].to_i : 12
puts "usuage:
ruby #{__FILE__} {number}
(number = 12 by default)"
puts "times table in base #{base}:"
(base + 1).times {|x|
(base + 1).times {|y|
dominictarr / dsl.rb
Created Sep 11, 2010
ruby DSL example
View dsl.rb
class DSL
def go (&block)
instance_eval &block if block
def self.go (&block)
dominictarr / set default.rb
Created Sep 24, 2010
ruby 'default' opperator.
View set default.rb
foo ||= true
puts foo
foo = nil
foo ||= true
puts foo
foo = false
foo ||= true
puts foo
dominictarr / queue.js
Created Sep 26, 2010
run a function with a limited amount of concurrency.
View queue.js
var sys = require('sys'),
exec = require('child_process').exec;
// fs = require('fs');
// ecsv = require('ecsv')
function Queue () {
var waiting = [];
this.max = -1;
this.current = 0;
//run checks if we're under the max processors, and runs if there is room.
dominictarr / handle_the_jandal.js
Created Oct 20, 2010
ways to process errors in node js
View handle_the_jandal.js
var sys = require('sys')
, EventEmitter = require('events').EventEmitter;
function error1 (err){
sys.puts("Handle: " + err);
function error2 (err){
sys.puts("JANDAL: " + err);
function exit (){
dominictarr / child.asynct.js
Created Nov 18, 2010
this test will be reported to pass, when clearly it should fail. async_testing v0.3.0
View child.asynct.js
if (module == require.main) {
return require('async_testing').run(process.ARGV);
exports ['test should fail'] = function (test){
View async_testing.runfile.asynct.js
exports ['does not call onSuiteDone twice'] = function (test){
var file = 'async_testing/test/test-stderr'
function suiteDone (status,report){
console.log("suiteDone - " + status + "'" + file + "'")
You can’t perform that action at this time.