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
echo "How many inches?" | |
read inches | |
echo "Okay" | |
echo -n "8" | |
sleep .5 | |
number=0 | |
until [ "$number" -ge $inches ]; 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
array1 = ['a', 'b', 'c'] | |
array2 = ['d', 'e', 'f'] | |
array3 = ['g', 'h', 'i'] | |
permutations = [] | |
array1.each do |a1| | |
array2.each do |a2| | |
array3.each do |a3| | |
permutations << [a1, a2, a3] |
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
# assuming email addresses are unique and other User attributes are first_name, last_name, | |
# city, and state | |
User.find_or_create_by(email: "john.smith@gmail.com").update(first_name: "John", last_name: "Smith", city: "Quincy", state: "MA") | |
User.find_or_create_by(email: "jill.bob@yahoo.com").update(first_name: "Jill", last_name: "Bob", city: "Randolph", state: "MA") | |
User.find_or_create_by(email: "jane.doe@google.com").update(first_name: "Jane", last_name: "Doe", city: "Canton", state: "MA") | |
User.find_or_create_by(email: "johnny.bolo@sam.com").update(first_name: "Johnny", last_name: "Bolo", city: "Sharon", state: "MA") | |
User.find_or_create_by(email: "bill.james@gmail.com").update(first_name: "Bill", last_name: "James", city: "Canton", state: "MA") | |
User.find_or_create_by(email: "jim.mcmanus@gmail.com").update(first_name: "Jim", last_name: "McManus", city: "Quincy", state: "MA") |
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 factorial(n) | |
if n == 1 | |
1 | |
else | |
n * factorial(n - 1) | |
end | |
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
list = [75, 100, 85, 65, 84, 87, 95] | |
def highest(list_given) | |
maximum = 0 | |
list_given.each do |item| | |
if item > maximum | |
maximum = item | |
end | |
end | |
return maximum |
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
favorite_movies = [ | |
{ title: 'The Big Lebowski', year_released: 1998, director: 'Joel Coen', imdb_rating: 8.2 }, | |
{ title: 'The Shining', year_released: 1980, director: 'Stanley Kubrick', imdb_rating: 8.5 }, | |
{ title: 'Troll 2', year_released: 1990, directory: 'Claudio Fragasso', imdb_rating: 2.5 } | |
] | |
favorite_movies.each do |movie| | |
puts "#{movie[:year_released]}: #{movie[:title]}" | |
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
name = "" | |
characters = {} | |
def add_name | |
puts "What name would you like to add?" | |
name = gets.chomp | |
return name | |
end | |
def add_house(hash, name) |
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
commit 35ffcf6de2328f8b1ad87de4f834eb7a0e4f206c | |
Author: Eve <eve.adele.asher@gmail.com> | |
Date: Thu Feb 20 17:49:53 2014 -0500 | |
Made another small change | |
commit ec121fa34503552ded3d7c2f9272746384ecd936 | |
Author: Eve <eve.adele.asher@gmail.com> | |
Date: Thu Feb 20 17:46:08 2014 -0500 |
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
#!/usr/bin/env ruby | |
#Choose a word | |
word_bank = ["mountains", "madness", "colour", "unknown", | |
"dream", "witch", "house", "quest", "horror", "west", "reanimator", | |
"red", "hook", "case", "ward", "space", "shadow", "time", "over", "shunned", | |
"whisperer", "darkness"] | |
word = word_bank.sample | |
chances = 8 |
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
number = rand(1...1000) | |
guess = "" | |
while guess != number | |
print "Guess a number between 0 and 1000. " | |
guess = Integer(gets) rescue nil | |
if guess == nil || guess <= 0 || guess >= 1000 | |
puts "Invalid input, must enter a number between 0 and 1000." | |
break |
NewerOlder