Skip to content

Instantly share code, notes, and snippets.

@unnitallman
unnitallman / gist:1930135
Created February 28, 2012 06:16
Adding bunder-stubs to a project
rvm get head && rvm reload
chmod +x $rvm_path/hooks/after_cd_bundler
cd /path/to/project
bundle install --binstubs=./bundler_stubs
@unnitallman
unnitallman / gist:1559413
Created January 4, 2012 10:07
Phusion passenger + rvm + different ruby version
rvm use 1.9.1
gem install passenger
cd /var/rails/staging_sites/Zed
passenger start -a 127.0.0.1 -p 3000 -d
<VirtualHost *:80>
ServerName staging.zed.bangthetable.com
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
</VirtualHost>
@unnitallman
unnitallman / gist:1369873
Created November 16, 2011 11:25
Installing rmagick on osx
http://hocuspokus.net/2010/03/installing-rmagick-on-snow-leopard-leopard/
@unnitallman
unnitallman / gist:1369872
Created November 16, 2011 11:25
Installing mysql gem on osx
http://wonko.com/post/how-to-install-the-mysqlruby-gem-on-mac-os-x-leopard
@unnitallman
unnitallman / gist:1307331
Created October 23, 2011 12:52
How to get a method's name from within that method
def test_method
puts __method__
end
@unnitallman
unnitallman / gist:1280308
Created October 12, 2011 04:47
Use a specific rubygems version with RVM
rvm rubygems 1.3.5
@unnitallman
unnitallman / gist:1266826
Created October 6, 2011 08:17
Downgrading rubygems
sudo gem update --system 1.3.5
@unnitallman
unnitallman / gist:1247809
Created September 28, 2011 12:28
Adding query string to a url
>> callback = Addressable::URI.parse("http://unni.com")
=> #<Addressable::URI:0x810ab0b4 URI:http://unni.com>
>> callback.query_values = callback.query_values ? callback.query_values.merge({"angry" => "birds"}) : {"angry" => "birds"}
=> {"angry"=>"birds"}
>> callback.to_s
=> "http://unni.com?angry=birds"
>> callback = Addressable::URI.parse("http://unni.com?nikhil=krishna")
=> #<Addressable::URI:0x8109fc8c URI:http://unni.com?nikhil=krishna>
>> callback.query_values = callback.query_values ? callback.query_values.merge({"angry" => "birds"}) : {"angry" => "birds"}
@unnitallman
unnitallman / gist:1237177
Created September 23, 2011 11:47
Typecasting a base class object to a derived class object
u = User.find(id)
u = u.becomes(u.type.constantize)
@unnitallman
unnitallman / connection_fix.rb
Created September 3, 2011 09:13 — forked from defunkt/connection_fix.rb
MySQL server has gone away fix
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/