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
source 'http://rubygems.org' | |
gem 'rails', '3.0.4' | |
group :test do | |
gem 'database_cleaner' | |
gem 'rspec-rails' | |
gem 'rspec-rails-matchers' | |
gem 'sham' | |
gem 'spork', '=0.9.0.rc7' |
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
var fs = require('fs'); | |
fs.mkdir('./hello',0777,makeDirectory); | |
function makeDirectory(err){ | |
if (err) throw err; | |
fs.writeFile('./hello/world.txt', 'Hello!', writeFile); | |
} | |
function writeFile(err){ |
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
#!/usr/bin/env ruby | |
def match_message(regexp) | |
m = Module.new | |
(class << m; self; end).instance_eval do | |
define_method(:===) do |error| | |
regexp === error.message | |
end | |
end | |
m |
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
class Group | |
module Error | |
class Standard < StandardError; end | |
class AlreadyAMember < Standard | |
def message | |
"You are already a member of this group." | |
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
class Group | |
module Error | |
class Standard < StandardError; end | |
class AlreadyAMember < Standard; end | |
class NotPermittedToJoin < Standard; end | |
end | |
def join user | |
raise Error::NotPermittedToJoin unless self.permitted?(user) | |
raise Error::AlreadyAMember if self.member?(user) |
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
class Module | |
alias :let :define_method | |
end | |
UserPresenter = Struct.new(:user) do | |
let(:full_name){ [user.first_name, user.last_name].join(' ') } | |
end | |
describe UserPresenter do | |
let(:user){ stub(:user, :first_name => 'Bob', :last_name => 'Smith') } |
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 'benchmark' | |
require 'mysql2' | |
x = Mysql2::Client.new | |
y = Mysql2::Client.new | |
Benchmark.bm do |b| | |
b.report('w/o') do | |
x.query("SELECT SLEEP(1)") | |
y.query("SELECT SLEEP(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
# Rails 3.2 @ d5d241cb2c696f13e2c16efca0d24565a6e1c0a5 | |
require 'active_support/dependencies/autoload' | |
require 'benchmark' | |
GC.disable | |
FILES = (1..1_000_000).map do |file| | |
["Base#{file}".to_sym, "base/#{file}"] | |
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
#!/usr/bin/env ruby | |
require 'benchmark' | |
REGEXPS = [ | |
/^no such file to load -- (.+)$/i, | |
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i, | |
/^Missing API definition file in (.+)$/i, | |
/^cannot load such file -- (.+)$/i, | |
] |
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
source "http://rubygems.org" | |
gem 'guard-yard' | |
gem 'rb-fsevent', :require => false |
OlderNewer