Skip to content

Instantly share code, notes, and snippets.

View Fosome's full-sized avatar

Ryan Foster Fosome

View GitHub Profile
@Fosome
Fosome / gist:7329822
Last active December 27, 2015 12:59
Rubs refactoring
class TrafficLight
def initialize
@state = lights.first
end
def change_to(change)
light = lights.find{|l| l.color == change.to_sym }
raise ArgumentError, "Invalid traffic light: #{change}" unless light
@Fosome
Fosome / gist:7090617
Created October 21, 2013 20:41
dat stank
class Stank
MONTHS = {
"january" => 1,
"jan" => 1,
"february" => 2,
"feb" => 2,
"march" => 3,
"mar" => 3,
"april" => 4,
"apr" => 4,
ruby-1.9.3-p0 :011 > base = {:a => "a", :b => "b"}
=> {:a=>"a", :b=>"b"}
ruby-1.9.3-p0 :012 > other = base
=> {:a=>"a", :b=>"b"}
ruby-1.9.3-p0 :013 > other[:c] = "c"
=> "c"
ruby-1.9.3-p0 :014 > base
=> {:a=>"a", :b=>"b", :c=>"c"}
ruby-1.9.3-p0 :015 >
@Fosome
Fosome / gist:3901163
Created October 16, 2012 18:44
Learn Ruby The Hard Way - Workshop Primer

Bootstrapping for Rails Workshop

Go to Zed Shaw's guide on learning Ruby. http://ruby.learncodethehardway.org/book/

Read the preface. It will be better for you if you follow his advice. At some point or another, you are going to feel confused, frustrated, and disappointed ALL AT ONCE. This is normal. Keep calm, step away for a few hours, or days and then get back in there.

Exercise 0

You all should have relatively new Macs. Check your ruby version is 1.9.2 in Terminal. If you don't have 1.9.2 or higher, stop and send me a message. Install the text editor. The 2 commands he wants you to learn are

  • cd said change directory. Google for more information. Learn what these commands are doing cd ~, cd .., and cd .
  • mkdir said make directory. Google again. Run this command mkdir ~/ruby. Figure out what that did.
@Fosome
Fosome / gist:3729572
Created September 15, 2012 20:17
ryan's bash prompt
function parse_git_branch {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\w\n\u@\h\e[0;36m\$(parse_git_branch)\e[m ‡ "