Skip to content

Instantly share code, notes, and snippets.

View eddorre's full-sized avatar

Carlos Rodriguez eddorre

View GitHub Profile
@mungruby
mungruby / singleton_struct.rb
Created May 29, 2012 02:10
Avoiding redefining constant Struct::ClassName warnings
fields = [:switch, :sha_ind, :dtdm, :utdm, :ttdm, :actual]
def create_struct name, fields
Struct.new(name, *fields)
end
def create_singleton_struct name, fields
if Struct::const_defined? name
Struct.const_get name
else
@cypriss
cypriss / README.md
Last active June 18, 2018 11:57
Rails 2.3.14 Ruby 1.9.3 - Monkey Patches

How we upgraded UserVoice, a Rails 2.3.14 app, to Ruby 1.9.3.

Blog post here

@tsabat
tsabat / zsh.md
Last active December 25, 2023 19:16
Getting oh-my-zsh to work in Ubuntu
@mattdenner
mattdenner / gist:985791
Created May 22, 2011 19:37
Handy tip for using proxy_owner in named scopes
class Thing < ActiveRecord::Base
# This named scope is supposed to take in an instance of Owner so that it can be used. Normally people would start
# writing `Thing.something(Owner.first).first` but ...
named_scope :something, lambda { |owner|
# Something here using 'owner'
}
end
class Owner < ActiveRecord::Base
# ... this association uses the method_missing behaviour of associations to cheat the appearance of something. In
@adamcrown
adamcrown / .irbrc
Last active November 7, 2023 06:34
My Bundler proof .irbrc file including wirble, awesome_print, hirb, console logging and route helpers
require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8
def unbundled_require(gem)
loaded = false
if defined?(::Bundler)
Gem.path.each do |gems_path|
gem_path = Dir.glob("#{gems_path}/gems/#{gem}*").last
unless gem_path.nil?
$LOAD_PATH << "#{gem_path}/lib"
@patmcnally
patmcnally / .irbrc
Created March 30, 2011 03:54
.irbrc file that incorporates wirble, hirb, rails 3, and awesome print
# load libraries
require 'rubygems' rescue nil
require 'wirble'
#require 'json'
alias q exit
class Object
def local_methods
(methods - Object.instance_methods).sort