Skip to content

Instantly share code, notes, and snippets.

View rsl's full-sized avatar
🏳️‍🌈
still a bad fish and free bird

Russell Norris rsl

🏳️‍🌈
still a bad fish and free bird
View GitHub Profile
require 'coffee'
require 'water'
require 'cup'
require 'carsten'
cup = Cup.new(:size => 'small')
cup.add(Coffee::Espresso.new(:shots => 3))
cup.add(Water::Ice.new(:cubes => 12))
cup.join
@rsl
rsl / gist:76227
Created March 9, 2009 12:21 — forked from radar/gist:76111
Please confirm the upgrade from
%strong= Plan[session[:old_plan_id]]
to
%strong= Plan[session[:new_plan_id]]
%br
%br
You are upgrading your
%strong Orchestrate
account located at
%string
module ActiveSupport
module CoreExtensions #:nodoc:
module String
module Conversions
def to_klass
self.classify.constantize
rescue NameError
nil
end
end
@rsl
rsl / snippet.txt
Created March 20, 2009 16:56 — forked from seivan/snippet.txt
class Person < ActiveRecord::Base
def self.find_recent
people = find(
:conditions => ["added_at > ? and deleted = ? and address is not null", Time.now.utc, false],
:order => "last_name, first_name")
end
# ...
end
Units = { :dollar_per_ffe => { :symbol => "$/ffe", :si_factor=>1.0 },
:dollar_per_ton => { :symbol => "$/T", :si_factor=>1.0e-3 }
}
Attribute_Units = { :default_transshipment_cost => :dollar_per_ffe,
:bunker_cost => :dollar_per_ton
}
Attribute_Units.each do |name, value|
define_method(name) do
>> e = DateTime.strptime('2009-05-07T01:33:23+01:00')
=> Thu, 07 May 2009 01:33:23 0100
>> f = DateTime.strptime('2009-05-06T23:33:23+01:00')
=> Wed, 06 May 2009 23:33:23 0100
>> e - f
=> Rational1, 12
>> a = Time.now
=> Thu May 07 10:25:53 -0400 2009
>> b = Time.now
def para (attributes = {}, &block)
method_missing(:p, attributes, &block)
end
para do
foo = <<-END_PARAGRAPH
Hello there. I love #{input 'inputting VARIOUS things'}. I also get a kick
out of #{code 'coding various things'}. There's such a thrill in
seeing all of the exciting #{output 'output you can get'} from a
well-written program.
def para (attributes = {}, &block)
method_missing(:p, attributes, &block)
end
para do
<<-END_PARAGRAPH
Hello there. I love #{input 'inputting VARIOUS things'}. I also get a kick
out of #{code 'coding various things'}. There's such a thrill in
seeing all of the exciting #{output 'output you can get'} from a
well-written program.
class ControllerHelper
include Singleton
include ActionView::Helpers
end
def url_helpers
ControllerHelper.instance
end
def can_edit?(this_user)
return true unless locked?
end