This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Example Notice</html> | |
<style type="text/css"> | |
body { font-family: helvetica; } | |
#notice { | |
color: #fff; | |
position: absolute; | |
width: 300px; | |
top: 5px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require 'less' | |
rescue LoadError | |
begin | |
config.gem "less" | |
require 'less' | |
rescue LoadError | |
puts "Please install the Less gem, `gem install less`." | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'cucumber/rake/task' | |
Cucumber::Rake::Task.new(:features) do |t| | |
t.cucumber_opts = "--format pretty" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# works | |
gem('activemerchant'); require 'active_merchant' | |
# fails with FATAL: The file activemerchant was not found | |
dependency('activemerchant') { require 'active_merchant' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Merb::BootLoader.after_app_loads do | |
config_path = Merb.root / 'config' / 'starling.yml' | |
load_path = Merb.root / 'app' / 'workers' | |
if File.exists?(config_path) | |
Workling::Client.options = YAML.load_file(config_path)[Merb.environment.to_sym] | |
Dir.glob(load_path / '**' / '*.rb').each { |wling| require wling } | |
else | |
Merb.logger.error! "No starling.yml file found in #{Merb.root}/config." | |
exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RESULTS = %w(H H H H H H A A A A A D) | |
def result | |
RESULTS[rand(RESULTS.length)] | |
end | |
require 'readline' | |
def prompt(prompt="> ") | |
input = nil |