Skip to content

Instantly share code, notes, and snippets.

@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:1266826
Created October 6, 2011 08:17
Downgrading rubygems
sudo gem update --system 1.3.5
@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: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: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: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: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: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
Customer.stub(:find).with(:all) { data_array }
@unnitallman
unnitallman / gist:2426598
Created April 20, 2012 06:30
Custom html in link text using link_to
=link_to "http://google.co.in" do
Hello
<i class="icon-search icon-white">Unni</i>
<b> World </b>