Skip to content

Instantly share code, notes, and snippets.

@BenHall
BenHall / Console2.Tabs.xml
Created January 20, 2010 21:21
Console2 Tabs
<tabs>
<tab title="Console2">
<console shell="" init_dir=""/>
<cursor style="0" r="255" g="255" b="255"/>
<background type="0" r="0" g="0" b="0">
<image file="" relative="0" extend="0" position="0">
<tint opacity="153" r="0" g="0" b="0"/>
</image>
</background>
</tab>
#!C:/IronRuby/bin/ir.exe
#
# This file was generated by RubyGems.
#
# The application 'rspec' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
#Based on this commit - http://github.com/casualjim/caricature/commit/d636e077016b1f4c3be5e66de793780a8f029048
class Object
def isolate(method, &block)
@isolate = method
instance_eval &block
end
def returns(val)
puts "#{@isolate} should return #{val}"
end
@BenHall
BenHall / rspec_count_matcher.rb
Created January 25, 2010 01:56
Example of a custom RSpec matcher
module Matchers
class CountEqual
def initialize(expected)
@expected = expected
end
def matches?(actual)
@actual = actual
@actual.Count() == @expected.Count()
end
@BenHall
BenHall / RSpec_Suite.rb
Created March 3, 2010 23:35
Break your RSpec specs into multiple suites for rapid feedback
# http://jakescruggs.blogspot.com/2007/03/wrapping-context-in-context-in-rspec.html
SPEC_SUITES = [
{ :id => :acl, :title => 'access control', :files => %w(spec/controllers/**/acl_spec.rb) },
{ :id => :amazon, :title => 'Amazon libraries', :dirs => %w(spec/lib/amazon) }
]
namespace :spec do
namespace :suite do
SPEC_SUITES.each do |suite|
@BenHall
BenHall / couchbalanced
Created April 3, 2010 13:14
HAProxy and CouchDB
# this config needs haproxy-1.1.28 or haproxy-1.2.1
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
#chroot /usr/share/haproxy
user haproxy
group haproxy
@BenHall
BenHall / Installing_0_11_On_Ubuntu
Created April 3, 2010 19:50
Upgrading Couchdb 0.10 to 0.11
sudo aptitude install automake spidermonkey-bin autoconf subversion-tools libtool help2man build-essential erlang erlang-manpages libicu38 libmozjs-dev wget libicu-dev libreadline5-dev checkinstall
sudo apt-get install libcurl4-openssl-dev
wget http://mirrors.enquira.co.uk/apache/couchdb/0.11.0/apache-couchdb-0.11.0.tar.gz
tar -xzvf apache-couchdb-0.11.0.tar.gz
cd apache-couchdb-0.11.0
./configure --bindir=/usr/bin --sbindir=/usr/sbin --localstatedir=/var --sysconfdir=/etc
make
curl -X POST http://127.0.0.1:5984/_replicate -d '{"source":"product_catalog", "target":"content_pool", "continuous":true}'
@BenHall
BenHall / Executing
Created April 13, 2010 22:34
Capybara HelloWorld
cucumber . URL="http://localhost:5764/"
@BenHall
BenHall / yyyy regex
Created April 22, 2010 13:53
dd/mm/yyyy regex
protected const string DateRegEx = @"(0?[1-9]|[12][0-9]|3[01])[- /.](0?[1-9]|1[012])[- /.](19|20)?\d\d";