Skip to content

Instantly share code, notes, and snippets.

View richardkmichael's full-sized avatar

Richard Michael richardkmichael

  • 20:00 (UTC -07:00)
View GitHub Profile
@richardkmichael
richardkmichael / gist:1122623
Created August 3, 2011 13:27
Where has ActionController::Dispatcher gone in a Rails 3.1 console?
Loading development environment (Rails 3.0.9)
ruby-1.9.2-p290 :001 > env = Rack::MockRequest.env_for('/')
=> {"rack.version"=>[1, 1], "rack.input"=>#<StringIO:0x00000102bfa628>, "rack.errors"=>#<StringIO:0x00000102bfa6c8>, "rack.multithread"=>true, "rack.multiprocess"=>true, "rack.run_once"=>false, "REQUEST_METHOD"=>"GET", "SERVER_NAME"=>"example.org", "SERVER_PORT"=>"80", "QUERY_STRING"=>"", "PATH_INFO"=>"/", "rack.url_scheme"=>"http", "HTTPS"=>"off", "SCRIPT_NAME"=>"", "CONTENT_LENGTH"=>"0"}
ruby-1.9.2-p290 :002 > ActionController::Dispatcher.new.call(env)
=> [200, {"Last-Modified"=>"Wed, 03 Aug 2011 13:08:10 GMT", "Content-Type"=>"text/html", "Content-Length"=>"5780"}, #<Rack::File:0x00000102f7a230 @root="/Users/testuser/Documents/Personal/Source/dispatch-test-rails3-stable/public", @path_info="/index.html", @path="/Users/testuser/Documents/Personal/Source/dispatch-test-rails3-stable/public/index.html">]
@richardkmichael
richardkmichael / gist:950389
Created May 1, 2011 10:11
Loading local variables into an IRB session: matz vs. rbx
$ cat foo.rb
s = 'foo'
ruby-1.9.2-p180 :008 > eval File.read('foo.rb')
=> "foo"
ruby-1.9.2-p180 :009 > s
NameError: undefined local variable or method `s' for main:Object
from (irb):9
from /Users/rmichael/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>'
@richardkmichael
richardkmichael / git-filter-branch.sh
Created October 28, 2010 18:41
With GNU sed, add LANG=en.UTF-8 to git-filter-branch to allow author names and email addresses to contain non-ASCII characters.
#!/bin/sh
#
# Rewrite revision history
# Copyright (c) Petr Baudis, 2006
# Minimal changes to "port" it to core-git (c) Johannes Schindelin, 2007
#
# Lets you rewrite the revision history of the current branch, creating
# a new branch. You can specify a number of filters to modify the commits,
# files and trees.