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
" Automatically align multiline hashes in Ruby (Ruby 1.9 syntax only). | |
function! AlignRubyHashes() | |
" Only look for lines that start with a simple keyword, colon, space, and | |
" ending in a comma. | |
let p = '^\s*\w\+:\s.*,$' | |
" Don't do anything if there is no Tabularize, or there is no surrounding | |
" line that can be aligned with. | |
if exists(':Tabularize') && (getline(line('.')) =~# '^\s*\w\+:\s$') && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p) | |
" save current position because later command moves the cursor |
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
(defn ack [m n] | |
(if (= m 0) | |
(+ n 1) | |
(if (= n 0) | |
(ack (- m 1) 1) | |
(ack (- m 1) (ack m (- n 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
activerecord.errors.models.content.attributes.topic.invalid | |
activerecord.errors.models.content.invalid | |
activerecord.errors.messages.invalid | |
# with STI | |
activerecord.errors.models.post.attributes.topic.invalid | |
activerecord.errors.models.post.invalid | |
activerecord.errors.models.content.attributes.topic.invalid | |
activerecord.errors.models.content.invalid | |
activerecord.errors.messages.invalid |
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
humans do: | |
errors.add(:topic, :custom_invalid) | |
rails does: | |
errors.add(:topic, :invalid, :default => :custom_invalid) | |
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 "rbench" | |
RBench.run(500) do | |
report("memoed") do | |
Foo.memoed("hello") | |
end | |
report("unmemoed") do | |
Foo.unmemoed("hello") | |
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
Marcel: "Ja, we willen graag dat jullie een huis bouwen. Het moet met hout, stenen of een voordeur!" | |
Iain: "We gebruiken dezelfde versie van WordPress als Hannibal toen hij blogde over hoe hij olifanten gebruikte om de Alpen door te trekken" |
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
# File management | |
run "rm README" | |
file "README.rdoc", "TODO add readme content" | |
run "cp config/database.yml config/database.example.yml" | |
run "rm public/index.html" | |
# RSpec as plugin, because it won't freeze easily as gem | |
plugin "rspec", :git => "git://github.com/dchelimsky/rspec.git" | |
plugin "rspec-rails", :git => "git://github.com/dchelimsky/rspec-rails.git" |
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
#!/bin/bash | |
# Unattended REE/Passenger installation | |
# Source: http://weblog.brightlight-ict.nl/2008/12/unattended-passenger-ruby-enterprise-installation-on-ubuntu-8/ | |
# 15/03/09 Updated to use latest r.e.e. and passenger 2.1 and rewrote bits thanks to the comments left on my blog. Thanks guys | |
if [ "$(whoami)" != "root" ]; then | |
echo "You need to be root to run this!" | |
exit 2 | |
fi | |
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 File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths")) | |
# Commonly used webrat steps | |
# http://github.com/brynary/webrat | |
# Dutch webrat steps translated by Iain | |
# http://iain.nl/ | |
Stel /^ik ben op (.+)$/ do |page_name| | |
visit path_to(page_name) | |
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
$ rake spec | |
/home/iain/code/sail/vendor/rails/activesupport/lib/active_support/dependencies.rb:443:in `load_missing_constant': uninitialized constant Remarkable::ActiveRecord (NameError) | |
from /home/iain/code/sail/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing_with_dependencies' | |
from /usr/local/lib/ruby/gems/1.9.1/gems/remarkable_rails-3.1.2/lib/remarkable_rails/active_orm.rb:17:in `<top (required)>' | |
from /home/iain/code/sail/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require' | |
from /home/iain/code/sail/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require' | |
from /usr/local/lib/ruby/gems/1.9.1/gems/remarkable_rails-3.1.2/lib/remarkable_rails.rb:25:in `<top (required)>' | |
from /home/iain/code/sail/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require' | |
from /home/iain/code/sail/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require' | |
from /home/iain/code/sail/spec/spec_helper.r |
OlderNewer