Skip to content

Instantly share code, notes, and snippets.

View awesome's full-sized avatar

So Awesome Man awesome

View GitHub Profile
@digitalronin
digitalronin / gitrmall.rb
Created July 22, 2008 13:36
Ruby script to automatically "git rm" deleted files
#!/usr/bin/env ruby
# Ruby script to automatically "git rm" deleted files
DELETED_REXP = /^#\s+deleted:\s+(.*)/
MARKER_LINE = '# Changed but not updated:'
lines = `git status`
found_marker = false
@tonywok
tonywok / results.md
Created September 15, 2011 01:33
Rails 3.1 Callbacks
s = Test.new(:name => "foo")

# ActiveRecord::Test after_initialize
# ActiveRecord::Test after_initialize, :on => :update
# ActiveRecord::Test after_initialize, :on => :create
# ActiveRecord::TestObserver after_initialize

# ===> #<Test id: nil, name: "foo", created_at: nil, updated_at: nil>
@bradland
bradland / datebench.rb
Created November 9, 2011 20:57
Date bench
#!/usr/bin/env ruby
require 'benchmark'
require 'date'
Benchmark.bm do|b|
ITERATE = 100000
b.report("strptime") do
time = "2011-05-25 00:00:03 -0400"
fmt = "%Y-%m-%d %H:%M:%S %z"
@ihower
ihower / gist:1513416
Created December 23, 2011 06:51
rails/ruby/jruby/passenger/Trinidad benchmark
= httperf --server localhost --port 3000 --uri /render_text --num-conns 500 --num-calls 20
== Ruby 1.9.2/WEBrick
Request rate: 329.5 req/s (3.0 ms/req)
Request rate: 334.6 req/s (3.0 ms/req)
== Ruby 1.9.2/Passenger
Request rate: 539.5 req/s (1.9 ms/req)
Request rate: 543.1 req/s (1.8 ms/req)
@juliepagano
juliepagano / jasmine_setup.rake
Created January 3, 2012 21:38
Jasmine & Rails 3.1 asset pipeline don't play well together; a workaround
task :copy_jquery_files do
# Jasmine doesn't work with the asset pipeline; therefore we copy the jquery
# files manually.
spec = Gem::Specification.find_by_name("jquery-rails")
jquery_dir = Pathname.new(Gem.dir) +
"gems" +
"#{spec.name}-#{spec.version}" +
"vendor" +
"assets" +
"javascripts"
@milligramme
milligramme / bash_completion
Created January 20, 2012 08:13
brew install bash-completion
$ brew install bash-completion
==> Downloading http://bash-completion.alioth.debian.org/files/bash-completion-1.3.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/bash-completion/1.3
==> make install
==> Caveats
Add the following lines to your ~/.bash_profile file:
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
@pat
pat / my_spec.rb
Created February 29, 2012 07:17
Quick hack: A Capybara that you can tell not to auto-follow redirects
it "does not have to auto-follow redirects", :driver => :tito_driver do
page.driver.stop_following_redirects
# make a web request that redirects
# do whatever you need to do
# the continue...
page.driver.follow_redirects!
end
@xunker
xunker / gist:2481976
Created April 24, 2012 17:50
RVM Error with gemset
#!/usr/bin/env ruby
require 'rubygems'
require 'rvm'
require 'trollop'
opts = Trollop::options do
opt :ruby, "ruby interp to use", :type => :string, :required => true
opt :gem_name, "gem", :type => :string, :required => true
opt :gem_version, "gem", :type => :string, :required => true
end
@repeatedly
repeatedly / ruby_hash_literal_with_here_document.md
Created July 17, 2012 11:15
Why Ruby failed to parse a Hash literal with multiple here documents.

1 element

h = { 
  hoge: <<EOS
Hey!
EOS
}

p h
@hideo55
hideo55 / heredoc.rb
Created July 17, 2012 11:27
Ruby here document
h = {
hoge: <<EOS,
Hey!
EOS
fuga: <<EOS
Yo!
EOS
}
p h