Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View svenfuchs's full-sized avatar

Sven Fuchs svenfuchs

View GitHub Profile
class A
def foo
puts 'original'
end
alias bar foo
def foo
puts 'modified'
end
ripper2ruby $ ruby test/lib_test.rb ripper2ruby : master-2
Going to parse and rebuild Ruby files from the following 225 libraries:
aasm, active_fulfillment, active_merchant, active_scaffold, active_shipping,
acts_as_paranoid, acts_as_versioned, acts_like_git, adva_cms, ajax-rdoc,
altered_beast, amqp, ansuz, archaeopteryx, arel, asset_packager,
attachment_fu, authlogic, autumn, backdrop, background-fu, bacon, bdoc,
beanstalkd, bluecloth, bones, braid, browsercms, bundle-fu, cache-money,
cache_fu, cacheable, cached_externals, can_search, cap_gun, capistrano,
cerberus, chronic, classy_resources, clearance, context, cosy, crap4r,
Do not use colons to separate if/unless/when conditions from expressions:
# e.g. adva_cms, ansuz, cruisecontrol, freemium, merb, paperclip, radiant,
# rbot, rfpdf, rghost, rstomp, shoulda, typus
case true; when TrueClass: true; end
# ruby 1.8.7
=> true
# ruby 1.9.1
=> syntax error, unexpected ':', expecting keyword_then or ',' or ';' or '\n'
From 81c1231ce151f2e35af3d9ad7ea54cb3c988811a Mon Sep 17 00:00:00 2001
From: Sven Fuchs <svenfuchs@artweb-design.de>
Date: Sun, 12 Jul 2009 16:11:13 +0200
Subject: [PATCH] relax gem version requirement for I18n gem
---
activesupport/lib/active_support/vendor.rb | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/activesupport/lib/active_support/vendor.rb b/activesupport/lib/active_support/vendor.rb
# Ummm ... well. Just some pseudo code I guess. Fork + complete as needed.
#
# Dependencies: Kombucha culture is expected to be installed in ~/kitchen
# If you don't have one you can easily obtain one from the internet.
rails kombucha -m ~/homemade.rb
# ~/homemade.rb
system %(
const_set(:"(•___){", Class.new do
def initialize
puts "too many tweets!"
end
end)
const_get(:"(•___){").new
# ... hmmmm.
# in case you have the gem already installed:
sudo gem uninstall git
# clone the library and build the gem
cd /to/some/tmp/dir
git clone git://github.com/svenfuchs/i18n.git
cd i18n
rake build
# in case the build fails because of a broken gemspec file
@svenfuchs
svenfuchs / gist:181350
Created September 5, 2009 08:55
cheap callbacks using ruby modules
module Rack
module Cache
class MetaStore
module Base
def lookup
puts 'lookup'
end
end
include Base
end
option_accessor :client_ttl
def call!(env)
@trace = []
@env = options.merge(env)
@request = Request.new(@env.dup.freeze)
response =
if @request.get? || @request.head?
if !@env['HTTP_EXPECT']