Skip to content

Instantly share code, notes, and snippets.

@teeparham
teeparham / ruby-1.9.2-p180-patched
Created June 8, 2011 04:59
compare ruby 1.9.2-p180 before & after patch
see http://www.rubyinside.com/get-edge-ruby-faster-loading-ruby-1-9-2-now-4973.html
> time bundle exec rake -T db
-- 1.9.2-p180
average = 13.3 sec
-- 1.9.2-p180-patched
average = 9.9 sec
@teeparham
teeparham / pingup.rb
Created July 28, 2011 15:54
Ruby ping logger
server = "google.com"
cmd = "ping -c 1 #{server}"
while true do
`#{cmd}`
if ($?.exitstatus != 0)
puts "Down: " + Time.now.to_s
while ($?.exitstatus != 0) do
`#{cmd}`
end
puts "Up: " + Time.now.to_s
@teeparham
teeparham / install.sh
Created August 25, 2011 04:18
test rails app with ruby 1.9.3-preview
rvm get head
rvm reload
rvm install 1.9.3-preview1
rvm use 1.9.3
bundle install
bundle exec rake
@teeparham
teeparham / co.sh
Created August 25, 2011 04:29
test rails app with ruby 1.9.3-preview (p2)
git checkout -b ruby193
@teeparham
teeparham / Gemfile
Created August 25, 2011 04:30
test rails app with ruby 1.9.3-preview (p3)
gem 'rake', '~> 0.9.3.beta.1'
@teeparham
teeparham / install-and-test.sh
Created August 25, 2011 04:30
test rails app with ruby 1.9.3-preview (p4)
bundle install
bundle exec rake
@teeparham
teeparham / ruby192.sh
Created October 4, 2011 16:27
install ruby MRI 1.9.2 with GC and require patches
# if re-install:
# rm -rf ~/.rvm/gems/ruby-1.9.2-p290
curl https://raw.github.com/gist/999435/fc2718ac3f488ab2341b65dc2ae5c123f8859bff/fast-require-ruby-19.2-p180 > /tmp/ruby192-require.patch
curl https://raw.github.com/gist/856296/patch-1.9.2-gc.patch > /tmp/ruby192-gc.patch
rvm get head && rvm reload
rvm uninstall 1.9.2
rvm install 1.9.2 --patch /tmp/ruby192-require.patch --patch /tmp/ruby192-gc.patch
rvm 1.9.2 --default
@teeparham
teeparham / test_helper.rb
Created October 18, 2011 18:03
rails form attributes helper
# build a hash of specified attribute values
#
# attrs_for(User.first, :name)
# => {"name"=>"Snoop Dogg"}
#
# in a test:
# post :create, :monkey => attrs_for(monkey, :name, :age)
#
def attrs_for(object, *attrs)
hash = {}
@teeparham
teeparham / update193.sh
Created October 31, 2011 15:55
update to ruby 1.9.3
rvm get latest
rvm reload
rvm install 1.9.3
rvm 1.9.3 --default
gem install bundler --pre # --pre is optional & gets you a faster pre-release
bundle
# remove rake from your Gemfile, as it's part of ruby
# or update it in your bundle:
@teeparham
teeparham / Gemfile
Created November 15, 2011 18:34
Resque Gemfile
gem 'resque', :require => 'resque/server'
gem 'resque-loner', :git => 'git://github.com/jayniz/resque-loner'
gem 'resque-scheduler'
gem 'resque_mailer'
gem 'resque-jobs-per-fork', :git => 'git://github.com/collectiveidea/resque-jobs-per-fork'