Skip to content

Instantly share code, notes, and snippets.

View RhysStansfield's full-sized avatar

Rhys Stansfield RhysStansfield

View GitHub Profile
@RhysStansfield
RhysStansfield / output
Last active August 29, 2015 14:17
Trainification
r@rhyss-mbp:~/git_repos/trainz$ rbenv local 2.2.0
r@rhyss-mbp:~/git_repos/trainz$ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
r@rhyss-mbp:~/git_repos/trainz$ ruby trainz.rb
HERE#<App::TrainStatus:0x007fbfda84e5d0>
r@rhyss-mbp:~/git_repos/trainz$ rbenv local 2.2.1
r@rhyss-mbp:~/git_repos/trainz$ ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
r@rhyss-mbp:~/git_repos/trainz$ ruby trainz.rb
HERE#<App::TrainStatus:0x007fc00b127bb8>
@RhysStansfield
RhysStansfield / quiz.rb
Created December 15, 2015 10:46
Example quiz
class Quiz
attr_accessor :questions, :correct, :incorrect
def initialize
self.questions = []
end
def add_question(*args)
self.questions << Question.new(*args)
end
@RhysStansfield
RhysStansfield / recursive_hash.rb
Created January 21, 2016 16:08
Recursive Hash
# lib file contents
Hash.class_eval do
# how the hell do we get this to work with []
def recursive_find(key)
return self[key] if has_key?(key)
self
.values
r@rs-MacBook-Pro ~
$: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 15916 100 15916 0 0 251k 0 --:--:-- --:--:-- --:--:-- 282k
=> Downloading nvm from git to '/Users/r/.nvm'
=> Cloning into '/Users/r/.nvm'...
remote: Enumerating objects: 356, done.
remote: Counting objects: 100% (356/356), done.
remote: Compressing objects: 100% (303/303), done.