Skip to content

Instantly share code, notes, and snippets.

View altamic's full-sized avatar

Michelangelo Altamore altamic

View GitHub Profile
# Implements the "missing action" route by default
# see http://thelucid.com/2010/03/15/rails-can-we-please-have-a-delete-action-by-default/
ActionController::Resources::Resource.class_eval do
def add_default_actions_with_delete_action
add_default_actions_without_delete_action
add_default_action(member_methods, :get, :delete)
end
alias_method_chain :add_default_actions, :delete_action
@altamic
altamic / this is how I see it
Created December 15, 2009 23:54 — forked from anonymous/gist:257152
randpath
def rand_path(args)
path_index = (rand()*args.size).to_i
case args[path_index]
when Array then rand_path(args[path_index])
when Proc then args[path_index].call
else
puts "Discarded #{args[path_index].class} argument"
end
end

Martin DeMello's Gooey Challenge

Original URL: http://hackety.org/2008/06/12/martinDemellosGooeyChallenge.html

June 12th 12:57
by why

Martin DeMello:

One of the most interesting facets of a desktop GUI system is how easy it makes it to go off the beaten track, particularly how well you can add “first class” components to the system. (Using ‘first class’ here to mean ‘on an equal footing with the widgets supplied by the toolkit’). Also, as a ruby programmer, I’d naturally rather not drop down into C (or Java) to do this.

module DelegateAttributes
def self.included(base)
base.class_eval do
extend ClassMethods
end
end
module ClassMethods
def delegate_or_override(*methods)