Skip to content

Instantly share code, notes, and snippets.

View ehrenmurdick's full-sized avatar

Ehren Murdick ehrenmurdick

View GitHub Profile
@ehrenmurdick
ehrenmurdick / activities_helper.rb
Created February 27, 2012 22:56 — forked from jlsuttles/activities_helper.rb
activity_sequence
# config/initializers/activity_order.rb
ACTIVITIES = [PersonalValues, PersonActions, SomeOther]
# config/initializer/array.rb
class Array
def relative_index(item, idx)
self[index(item) + idx]
end
def next(item)
@ehrenmurdick
ehrenmurdick / person.rb
Created February 14, 2012 19:11 — forked from jlsuttles/person.rb
state machines confuse me
class Person < ActiveRecord::Base
validates :name, :presence: true, :if: :authed?
validates :name, :presence: true, :if: :unaccepted?
validates :name, :presence: true, :if: :accepted?
state_machine :state, :initial => :authed do
event :filled_out_profile do
transition :authed => :unaccepted
end
# = Icebox : Caching for HTTParty
#
# Cache responses in HTTParty models [http://github.com/jnunemaker/httparty]
#
# === Usage
#
# class Foo
# include HTTParty
# include HTTParty::Icebox
# cache :store => 'file', :timeout => 600, :location => MY_APP_ROOT.join('tmp', 'cache')
class Numeric
def spaces
self * " "
end
end
p 128.spaces