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
Gallery = new function() {...} //instead of using this, a function expression | |
function Gallery() {...} //...use this, a function declaration | |
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
<% provide(:title, 'Contact') %> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>RecipeApp | <%= yield(:title) %></title> | |
</head> | |
<body> | |
<h1><%= yield(:title) %></h1> | |
<p>Contents</p> | |
</body> |
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 'spec_helper' | |
describe "Static pages" do | |
. | |
. | |
. | |
describe "Contact page" do | |
it "should have the content 'Contact'" do | |
visit '/static_pages/contact' | |
expect(page).to have_content('Contact') |
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
# These are just to make the map easier for me to read. # "M" is visually more dense than "o". | |
M = 'land' | |
o = 'water' | |
world = [[o,o,o,o,o,o,o,o,o,o,o], | |
[o,o,o,o,M,M,o,o,o,o,o], | |
[o,o,o,o,o,o,o,o,M,M,o], | |
[o,o,o,M,o,o,o,o,o,M,o], | |
[o,o,o,M,o,M,M,o,o,o,o], | |
[o,o,o,o,M,M,M,M,o,o,o], | |
[o,o,o,M,M,M,M,M,M,M,o], |
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
# These are just to make the map easier for me to read. # "M" is visually more dense than "o". | |
M = 'land' | |
o = 'water' | |
world = [[o,o,o,o,o,o,o,o,o,o,o], | |
[o,o,o,o,M,M,o,o,o,o,o], | |
[o,o,o,o,o,o,o,o,M,M,o], | |
[o,o,o,M,o,o,o,o,o,M,o], | |
[o,o,o,M,o,M,M,o,o,o,o], | |
[o,o,o,o,M,M,M,M,o,o,o], | |
[o,o,o,M,M,M,M,M,M,M,o], |
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 sort arr | |
rec_sort arr, [] | |
end | |
def rec_sort unsorted, sorted | |
if unsorted.length <= 0 | |
return sorted | |
end | |
# So if we got here, then it means we still # have work to do. |
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
start_array = [] | |
puts "Enter as many words as you like, pressing Enter after each word has been input. type 'stop' to finish entering words." | |
while true | |
x = gets.chomp #had to put this within the while loop for code to work, not outside while loop | |
if x != "stop" | |
start_array.push x | |
else | |
def sort start_array # This "wraps" recursive_sort. | |
recursive_sort start_array, [] | |
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
start_array = [] | |
puts "Enter as many words as you like, pressing Enter after each word has been input. type 'stop' to finish entering words." | |
while true | |
x = gets.chomp.downcase #had to put this within the while loop for code to work, not outside while loop | |
if x != "stop" | |
start_array.push x | |
else | |
def do_shuffle start_array | |
shuffle start_array, [] | |
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
# This program should take a number, like 22, and return the English version of it | |
#(in this case, the string 'twenty-two'). | |
#For now, let’s have it work only on integers from 0 to 99999: | |
puts "Provide a number greater than or equal to 0 but less than 100,000" | |
num = gets.chomp.to_i | |
def englishnum number | |
if number < 0 || number > 99999 | |
puts "Please enter a number greater than or equal to 0 but less than 100,000" | |
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
# Write a program to read in names and birth dates from a text file. | |
# It should then ask you for a name. You type one in, and it tells you | |
# when that person’s next birthday will be (and, for the truly adventur- | |
# ous, how old they will be). The input file should look something like this: | |
# Christopher Alexander, Oct 4, 1936 | |
# Christopher Lambert, Mar 29, 1957 | |
# Christopher Lee, May 27, 1922 | |
# Christopher Lloyd, Oct 22, 1938 | |
# Christopher Pine, Aug 3, 1976 | |
# Christopher Plummer, Dec 13, 1927 |