Skip to content

Instantly share code, notes, and snippets.

class Event < ActiveRecord::Base
before_save :set_event_creator
def set_event_creator
self.creator = Event.creator
end
end
# Somewhere in controller ;-)
array = [:one, :two, :three]
array.[] 0 #=> :one
array.[] 1 #=> :two
# why?;-)
# array[:hello] #=> array[:hello]
# [:world] #=> [:world] :'((((
#
# array[:hello][:world] #=> array[:hello][:world]
require 'benchmark'
class InfoDesk
def flights
puts "flights"
end
def trains
puts "trains"
end
class Proc
alias :original_call :call
def call
puts "custom call from proc"
original_call
super if defined? super
end
end
Aquarium::Aspects::Aspect.new :around, :calls_to => /^metody_admina/, :in_type => User::AdminType do |jp, obj, *args|
jp.proceed
end
class Object
def self.define_method(*args)
"fuck it"
end
end
foo = Class.new(ExampleClass) do
def bar
puts "bar"
end
scope :example_scope, where(:invited => true)
@LTe
LTe / Gemfile
Created November 15, 2011 12:44
source :rubygems
gem "muzang", "~> 1.0.0"
gem "muzang-plugins", "~> 1.0.0"
module MethodModule
def methoda(*args)
return args
end
end
class MyClass
include MethodModule
def methoda(*)
@LTe
LTe / gist:1581884
Created January 9, 2012 08:22
gookig.diff
diff --git a/lib/geokit/geocoders.rb b/lib/geokit/geocoders.rb
index c407141..c9f457c 100644
--- a/lib/geokit/geocoders.rb
+++ b/lib/geokit/geocoders.rb
@@ -83,7 +83,7 @@ module Geokit
def self.__define_accessors
class_variables.each do |v|
- sym = v.to_s.delete("@").to_sym
+ sym = v.delete("@").to_sym