Skip to content

Instantly share code, notes, and snippets.


Rhett Sutphin rsutphin

  • Human Practice, Inc.
  • Chicago, Illinois
View GitHub Profile
View gist:238518
require 'socket'
require 'webrick/httprequest'
require 'stringio'
# Super-primitive transparent, recording, single-threaded HTTP Proxy
class TransparentHttpProxy
attr_reader :port
def initialize(port, recorder)
@port = port
View hash_modification.rb
def visit(h, incr)
puts "Visiting #{h.inspect}"
visited_keys = []
h.each_pair do |k, v|
visited_keys << k
h[] = v
if h.size > 20 # arbitrary limit
raise "Infinite loop!"
View Gemfile
# include at least one source and the rails gem
source :gemcutter
gem "rails", "~> 2.3.5", :require => nil
gem "sqlite3-ruby", :require => "sqlite3"
# Devise 1.0.2 is not a valid gem plugin for Rails, so use git until 1.0.3
# gem "devise", :git => "git://", :ref => "v1.0"
group :development do
# bundler requires these gems in development
View script.markdown

Installed gems

$ gem list nokogiri

*** LOCAL GEMS ***

nokogiri (1.4.0, 1.3.3)


rsutphin / rails23-bundler-template.rb
Created Mar 19, 2010
A rails 2.3 template which adds bundler 0.9.12 support to a new rails app
View rails23-bundler-template.rb
file 'config/preinitializer.rb', <<-PRE
# Use bundled gems
require File.expand_path('../../.bundle/environment', __FILE__)
rescue LoadError
# This setup deliberately requires that the application be locked.
# For an alternative, see
if File.exist?(File.expand_path('../../Gemfile.lock', __FILE__))
raise "Application is locked but not installed. Run `bundle install` and then try again."
rsutphin /
Created Mar 19, 2010
Script to reproduce bundler issue 210

Generate app

$ rails -m foo
$ cd foo

Add a gem which provides generators to the Gemfile

source :gemcutter
gem 'rails', '2.3.5', :require => nil
gem 'sqlite3-ruby'
rsutphin / module_super_with_alias.rb
Created Mar 31, 2010
MRI 1.8.x quirk with alias and super for included modules
View module_super_with_alias.rb
module A
def foo
alias bar foo
module B
def foo
View a.gemspec do |s| = "A"
s.version = "0.0.0"
s.summary = "Gem A"
rsutphin / build.yaml
Created May 26, 2010
Demonstration for ivy4r issue #3
View build.yaml
- ivy4r
settings.file: ivysettings.xml