Instantly share code, notes, and snippets.

View mocks cheat sheet
stub = stub("stub")
customer = double("customer")
# single stub
customer = double("customer", :name => 'Bryan')
# multiple stubs
customer = double("customer", :name => 'Bryan', :open_source_projects => ['WebRat', 'Rack::Test'])
# single stub
customer.stub(:name).and_return("Aslak")
customer.should_receive(:name).and_return("Aslak")
View rvm install ruby on snow leopard
rvm install 1.9.1 -C --with-readline-dir=/Developer/SDKs/MacOSX10.6.sdk/usr
View MODULARITY_OLYMPICS.markdown

2010 Modularity Olympics

This is a contest, open to programming languages from all nations, to write modular and extensible code to solve the following problem: Implement a service that can run queries on a database.

The Challenge

Sounds simple right? Wrong! A programmer without control over the source-code of that service must be able to later add enhancements such as statistics collecting, timeouts, memoization, and so forth. There are a few more requirements:

  1. the “enhancements” must be specified in a configuration object which is consumed at run-time (e.g., it could be based on user-input).
  2. The enhancements are ordered (stats collecting wraps timeouts, not the other way around) but it must be possible to reverse the order of the enhancements at run-time.
  3. The enhancements must be “surgical” and not “global”. That is, it must be possible to simultaneously have two query services, one reversed and one not reversed, and even have a query service without any enhancements.