This file contains hidden or 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
var arr = [] | |
function arrayOfLight(number) { | |
i = 0; | |
do { | |
arr.push(i); | |
i++; | |
} | |
while (i <= number); | |
return arr |
This file contains hidden or 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
#1. | |
SELECT isbn | |
FROM editions AS e | |
JOIN publishers AS p | |
ON e.publisher_id = p.id | |
WHERE p.name = 'Random House'; | |
#2. |
This file contains hidden or 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
# A sample Gemfile | |
source "https://rubygems.org" | |
gem 'pry' | |
gem 'rspec' |
This file contains hidden or 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
### SETUP | |
require 'rspec' | |
### LOGIC (fix me) | |
def hello(who) | |
"hello " + who + "!" | |
end | |
### TEST CODE (don't touch me) |
This file contains hidden or 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
Create a Gist as a submission for this activity. Add a README.txt file to the Gist that includes a two to three paragraph explanation in your own words of how self refers to different objects depending on where it is in a Ruby program. | |
Self is an interesting object in the Ruby language. Depending on where the self is placed, self can | |
actually represent something completely different. If you were to call self on a class method, it means that the class itself can use that method. | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
for example: |
This file contains hidden or 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
# In this file we define the methods to help filter out candidates | |
# This way, we keep these methods separated from other potential parts of the program | |
class InvalidError < StandardError | |
end | |
def find(id) | |
unless @candidate.has_key?(:years_of_experience) | |
raise InvalidError, 'Candidate must have a :years_of_experience key' | |
end | |
@candidates.each do |candidate| |
This file contains hidden or 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
module Flight | |
def fly | |
puts "I'm a parrot, I'm flying!" | |
end | |
end | |
class Animal | |
attr_reader :name | |
def initialize(name) | |
@heart = 1 |
This file contains hidden or 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 'rubygems' | |
require 'rest-client' | |
wiki_url = "http://en.wikipedia.org/" | |
wiki_local_file = "downloaded_wiki_page.html" | |
File.open(wiki_local_file, "w") do |file| | |
file.write(RestClient.get(wiki_url)) | |
end |
This file contains hidden or 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 'colorize' | |
class Player | |
def initialize(name) | |
@name = name | |
@starting_life = 3 | |
@starting_points = 0 | |
end | |
def lose_life |
This file contains hidden or 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
@dollar = 0 | |
@starting_caps = 0 | |
@starting_bottles = 0 | |
@left_over_caps = 0 | |
@left_over_bottles = 0 | |
@current_caps = 0 | |
@current_bottles = 0 | |
@new_soda_amount = 0 | |
@current_soda = 0 | |
@total_sodas = 0 |
NewerOlder