Skip to content

Instantly share code, notes, and snippets.

View george's full-sized avatar

George george

View GitHub Profile
@george
george / inline_rescue.rb
Created March 23, 2011 21:24
playing around with inline rescues
#!/usr/bin/env ruby -wKU
# describe "enigma" do
# it "fails, but why" do
# lambda { begin; 2 / 0 rescue NoMethodError; end }.
# should raise_error(ZeroDivisionError)
# end
# the inline rescue is swallowing the ZeroDivisionError exception and
stc_partner_plan ∴ cap staging deploy
triggering start callbacks for `staging'
* executing `moonshine:configure'
* executing `staging'
triggering start callbacks for `deploy'
* executing `moonshine:configure'
* executing `multistage:ensure'
triggering after callbacks for `multistage:ensure'
* executing `moonshine:configure_stage'
* executing `deploy'
ruby-1.9.2-p180 :001 > Order.find_or_create_by_id(999999)
=> #<Order id: 999999, customer_id: nil, status: nil, created_at: "2011-07-06 16:01:08", updated_at: "2011-07-06 16:01:08">
ruby-1.9.2-p180 :002 > Order.find_or_create_by_id(nil)
=> #<Order id: 1000000, customer_id: nil, status: nil, created_at: "2011-07-06 16:01:16", updated_at: "2011-07-06 16:01:16">
ruby-1.9.2-p180 :003 > Order.find 999999
=> #<Order id: 999999, customer_id: nil, status: nil, created_at: "2011-07-06 16:01:08", updated_at: "2011-07-06 16:01:08">
ruby-1.9.2-p180 :004 > Order.find_or_create_by_id(nil)
=> #<Order id: 1000001, customer_id: nil, status: nil, created_at: "2011-07-06 16:02:38", updated_at: "2011-07-06 16:02:38">
ruby-1.9.2-p180 :005 >
module ProductsHelper
def print_price(price)
number_to_currency(price)
end
def print_stock(quantity)
if quantity > 0
content_tag :span, "In Stock (#{quantity})", :class => "in_stock"
else
content_tag :span, "Out of Stock", :class => "out_stock"
class Order < ActiveRecord::Base
attr_accessible :customer_id, :status
has_many :order_items
def total
order_items.inject(0) do |acc, order_item|
acc += order_item.subtotal
end
end
@george
george / optionalclass.haml
Created January 4, 2012 18:33 — forked from scottmessinger/optionalclass.haml
optional class?
%table
%tr
%td.optional_class_name
Text
Text
Text
@george
george / gist:2122240
Created March 19, 2012 18:10
output from: ( set -x ; . "$HOME/.rvm/scripts/rvm" ) 2>&1
+-zsh:15> . /Users/george/.rvm/scripts/rvm
+/Users/george/.rvm/scripts/rvm:9> [[ ":$SHELLOPTS:" -regex-match ":posix:" ]]
+/Users/george/.rvm/scripts/rvm:9> true
+/Users/george/.rvm/scripts/rvm:12> export HOME rvm_prefix rvm_user_install_flag rvm_path
+/Users/george/.rvm/scripts/rvm:13> HOME=/Users/george
+/Users/george/.rvm/scripts/rvm:15> : rvm_stored_umask:022
+/Users/george/.rvm/scripts/rvm:16> (( 0 == 0 ))
+/Users/george/.rvm/scripts/rvm:18> rvmrc=/etc/rvmrc
+/Users/george/.rvm/scripts/rvm:20> [[ -f /etc/rvmrc ]]
+/Users/george/.rvm/scripts/rvm:18> rvmrc=/Users/george/.rvmrc
~ ∴ source "$HOME/.rvm/scripts/rvm"
/Users/george/.rvm/scripts/initialize:50: __rvm_cleanse_variables: function definition file not found
~ ∴ (source "$HOME/.rvm/scripts/rvm")
~ ∴ set -x source "$HOME/.rvm/scripts/rvm"
+omz_termsupport_precmd:1> title '%15<..<%~%<<' '%n@%m: %~'
+title:1> [ '' '!=' true ']'
+title:2> [[ xterm == screen* ]]
+title:4> [[ xterm == xterm* ]]
+title:5> print -Pn '\e]2;%n@%m:\ %\~\a'
+title:6> print -Pn '\e]1;%15\<..\<%\~%\<\<\a'
+-zsh:8> git_prompt_info
+git_prompt_info:1> ref=+git_prompt_info:1> ref=''
~ ∴ set -x ; . "$HOME/.rvm/scripts/rvm"
+-zsh:1> . /Users/george/.rvm/scripts/rvm
+/Users/george/.rvm/scripts/rvm:9> [[ ":$SHELLOPTS:" -regex-match ":posix:" ]]
+/Users/george/.rvm/scripts/rvm:9> true
+/Users/george/.rvm/scripts/rvm:12> export HOME rvm_prefix rvm_user_install_flag rvm_path
+/Users/george/.rvm/scripts/rvm:13> HOME=/Users/george
+/Users/george/.rvm/scripts/rvm:15> umask
+/Users/george/.rvm/scripts/rvm:15> : rvm_stored_umask:022
+/Users/george/.rvm/scripts/rvm:16> (( 0 == 0 ))
+/Users/george/.rvm/scripts/rvm:18> rvmrc=/etc/rvmrc