This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IMPORTANT: "this" is set when a function is CALLED, not defined. | |
// It also depends on how it is called. | |
// There are 4 ways to define a function (directly affect "this" as well) | |
// 1. Constructor | |
// "this" -> new object {} | |
var func = new User(); | |
// 2. Method | |
// "this" -> receiver (func) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This starter templates adds gems to your gemfile when creating a new rails app | |
# Usage: | |
# rails new <app name> -m <this gist's url>/raw | |
gem_group :development, :test do | |
gem 'rspec-rails' | |
gem 'better_errors' | |
gem 'binding_of_caller' | |
gem 'quiet_assets' | |
gem 'annotate' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TowersOfHanoi | |
def self.start | |
@n = 0 | |
puts "------------------------------------------------------------------------" | |
puts "Towers of HanooOoiiiii" | |
puts " " | |
puts "Your goal is to move all disk to peg 'c' in order. i.e. \"c\" => [3,2,1]" | |
puts " " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Found question from Best of Ruby Quiz - modified and created the following. | |
# Library to convert letters to phone numbers | |
@numbers_library = { "A" => 2, "B" => 2, "C" => 2, "D" => 3, "E" => 3, "F" => 3, "G" => 4, | |
"H" => 4, "I" => 4, "J" => 5, "K" => 5, "L" => 5, "M" => 6, "N" => 6, | |
"O" => 6, "P" => 7, "Q" => 7, "R" => 7, "S" => 7, "T" => 8, "U" => 8, | |
"V" => 8, "W" => 9, "X" => 9, "Y" => 9, "Z" => 9 | |
} | |