Skip to content

Instantly share code, notes, and snippets.

@iain
iain / gist:7819
Created August 28, 2008 20:45 — forked from svenfuchs/gist:7818
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
humans do:
errors.add(:topic, :custom_invalid)
rails does:
errors.add(:topic, :invalid, :default => :custom_invalid)
@iain
iain / gist:45111
Created January 9, 2009 14:12
quotes terwijl arieslet down was
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"
@iain
iain / bench.rb
Created January 10, 2009 14:08 — forked from wycats/bench.rb
I want this for my own :P
require "rubygems"
require "rbench"
RBench.run(500) do
report("memoed") do
Foo.memoed("hello")
end
report("unmemoed") do
Foo.unmemoed("hello")
end
@iain
iain / gist:63953
Created February 13, 2009 15:31
First try Rails template
# 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"
#!/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
@iain
iain / gist:87691
Created March 30, 2009 08:45
Dutch version of default webrat steps
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
@iain
iain / Rake spec with normal Remarkable procedure
Created May 24, 2009 09:56
Remarkable 3.1.2 on Ruby 1.9.1
$ 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
$ rake spec
(in /home/iain/code/remarkable/remarkable)
Exemplo desativado: não deve conter os valores fornecidos
Example disabled: single contain
Example disabled: should contain the given values
Example disabled: should not contain the given values
...............*................................................
Pending:
$ time dd if=/dev/zero bs=1024 count=1000000 of=~/1Gb.file
1000000+0 records in
1000000+0 records out
1024000000 bytes transferred in 15.577478 secs (65735929 bytes/sec)
real 0m15.609s
user 0m1.299s
sys 0m6.948s