Skip to content

Instantly share code, notes, and snippets.

function arrayOfLight(x) {
var array = [];
for(var i = 0; i <= x; i++) {
array[i] = i;
}
return array;
}
source "https://rubygems.org"
gem 'rspec'
gem 'pry'
gem 'byebug'
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.
class Amphibian
end
# 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"
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,
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. :)
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
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"
@states = {
OR: 'Oregon',
FL: 'Florida',
CA: 'California',
NY: 'New York',
MI: 'Michigan'
}
@states[:OH] = 'Ohio'
@states[:TX] = 'Texas'