Skip to content

Instantly share code, notes, and snippets.

View tooky's full-sized avatar

Steve Tooke tooky

View GitHub Profile
jQuery.fn.delegate = function(eventType, rules) {
return this.bind(eventType, function(e) {
var target = $(e.target);
for(var selector in rules)
if(target.is(selector))
return rules[selector].apply(this, arguments)
})
}
require 'rubygems'
require 'sinatra'
require 'activerecord'
configure :development do
set :db, {:adapter => 'sqlite3', :dbfile => 'shout.dev.sqlite3.db'}
end
configure :production do
set :db, {:adapter => 'sqlite3', :dbfile => 'shout.sqlite3.db'}
# Monkeypatch paperclip 2.1.2 to work with merb
module Paperclip
class Attachment
def assign uploaded_file
%w(file_name).each do |field|
unless @instance.class.column_names.include?("#{name}_#{field}")
raise PaperclipError.new("#{self} model does not have required column '#{name}_#{field}'")
end
end
begin
require 'less'
rescue LoadError
begin
config.gem "less"
require 'less'
rescue LoadError
puts "Please install the Less gem, `gem install less`."
end
end
@tooky
tooky / war.feature
Last active September 2, 2015 19:11
Feature: A Game of War
Scenario: Two Card Deck
Given a shuffled deck with the following cards:
| 2 ♥ |
| 3 ♣ |
And the cards are dealt evenly between 2 players
When the first hand is played
Then player 2 should hold all the cards
And player 2 should have won the game
Rules
=====
1. write exactly ONE failing test
2. make the test from (1) pass by first writing implementation code IN THE TEST
3. create a new implementation method/function by:
1. doing extract method on implementation code created as per (2), or
2. moving implementation code as per (2) into an existing implementation method
4. only ever create new methods IN THE TEST CLASS
5. only ever create implementation classes to provide a destination for extracting a method created as per (4).
<html>
<head>
<title>Example Notice</html>
<style type="text/css">
body { font-family: helvetica; }
#notice {
color: #fff;
position: absolute;
width: 300px;
top: 5px;
.*.sw?
@tooky
tooky / dojo.rb
Created July 16, 2010 21:18 — forked from anonymous/dojo.rb
require 'rubygems'
require 'spec'
class Account
attr_reader :balance
def self.find(pin)
Accounts[pin]
end
def initialize(ref,balance=0)
default:
suites:
default:
contexts:
- FeatureContext:
baseUrl: http://localhost:8080/