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
function arrayOfLight(x) { | |
var array = []; | |
for(var i = 0; i <= x; i++) { | |
array[i] = i; | |
} | |
return array; | |
} |
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
source "https://rubygems.org" | |
gem 'rspec' | |
gem 'pry' | |
gem 'byebug' |
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
When the "self" keyword is used in class methods, it refers to the class itself. | |
When the "self" keyword is used in instance methods, it refers to the particular instance of the class. | |
When the "self" keyword is used outside of both class and instance methods, but within a class definition, it still refers to the class itself. |
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 Amphibian | |
end |
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
# require 'rest-client' | |
# require 'open-uri' | |
# require 'pry-byebug' | |
# EXERCISE 1 | |
# File.open("wiki-page.html", "w") { |my_file| my_file.write(RestClient.get("http://en.wikipedia.org/wiki"))} | |
# EXERCISE 2 | |
# full_url = "http://ruby.bastardsbook.com/files/fundamentals/hamlet.txt" |
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
require 'active_support/all' | |
@candidates = [ | |
{ | |
# qualified, same exp as 10, diff github points | |
id: 1, | |
years_of_experience: 3, | |
github_points: 250, | |
languages: ['Java', 'Ruby', 'JavaScript'], | |
date_applied: 12.days.ago.to_date, |
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
def benchmark | |
# Your benchmarking code goes here. | |
start_time = Time.now | |
yield | |
end_time = Time.now | |
end_time - start_time | |
end | |
# Be careful, pasting this into IRB will take a long time to print. | |
# It's a loooong string. :) |
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
PRICE_PER_BOTTLE = 2 | |
EMPTIES_FOR_FREE_BOTTLE = 2 | |
CAPS_FOR_FREE_BOTTLE = 4 | |
@num_bottles = 0 | |
@free_bottles_from_returned_bottles = 0 | |
@free_bottles_from_returned_caps = 0 | |
@total_free_bottles_from_returned_bottles = 0 | |
@total_free_bottles_from_returned_caps = 0 | |
@leftover_bottles = 0 |
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
def convert_ones_position(digit) | |
case digit | |
when 1..3 | |
"I" * (digit%4) | |
when 4 | |
"IV" | |
when 5..8 | |
"V" + "I" * (digit%5) | |
when 9 | |
"IX" |
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
@states = { | |
OR: 'Oregon', | |
FL: 'Florida', | |
CA: 'California', | |
NY: 'New York', | |
MI: 'Michigan' | |
} | |
@states[:OH] = 'Ohio' | |
@states[:TX] = 'Texas' |
NewerOlder