Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First Version #10

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions MichaelHanscom-elderhan/d2/99bot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
botnum = 99
botnum2 = botnum - 1

while (!(botnum == 0))
if (botnum2 == 1)
puts botnum.to_s + " bottles of beer on the wall, " + botnum.to_s +
" bottles of beer, you take one down and pass it around, " + botnum2.to_s +
" bottle of beer on the wall"
botnum = botnum - 1
botnum2 = botnum2 - 1
elsif (botnum == 1)
puts botnum.to_s + " bottle of beer on the wall, " + botnum.to_s +
" bottle of beer, you take one down and pass it around, " + botnum2.to_s +
" bottles of beer on the wall"
botnum = botnum - 1
botnum2 = botnum2 - 1
else
puts botnum.to_s + " bottles of beer on the wall, " + botnum.to_s +
" bottles of beer, you take one down and pass it around, " + botnum2.to_s +
" bottles of beer on the wall"
botnum = botnum - 1
botnum2 = botnum2 - 1
end
end

6 changes: 6 additions & 0 deletions MichaelHanscom-elderhan/d2/angry_boss.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
puts "What do you want?"

response = gets.strip.upcase;


puts "WHADDAYA MEAN \"" + response + "\"?!? YOU'RE FIRED!!"
19 changes: 19 additions & 0 deletions MichaelHanscom-elderhan/d2/answers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
1. You would have to type pry, and then x = 5

2. It is a string.

3. No, we didn't use quotation marks around 5, so x is read as an integer

4. It evaluates to the string "YOLO" (it would have to be typed in pry)

5. It reads "Coolio" because . the () make no difference to strings

6. You get an error message because you can't add a string and a number

7. "Batwoman"

8. "Miley"

9. rapper.chars.first

10. rapper[0,3]
7 changes: 7 additions & 0 deletions MichaelHanscom-elderhan/d2/bigger_num.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
puts "What is your favorite number?"

fav_number = gets.to_i

bigger_number = fav_number + 1

puts "Your actual favorite number is " + bigger_number.to_s
14 changes: 14 additions & 0 deletions MichaelHanscom-elderhan/d2/dfgr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
puts "Say something to your Grandma"

yourspeech = gets.strip

while (!(yourspeech == "BYE"))
if ((yourspeech.upcase) == yourspeech)
rnum = 1930 + rand(20)
puts "Grandma: NO, NOT SINCE #{rnum}"
yourspeech = gets.strip
else
puts "HUH?! SPEAK UP SONNY!"
yourspeech = gets.strip
end
end
13 changes: 13 additions & 0 deletions MichaelHanscom-elderhan/d2/full_name_hello.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
puts "What is your first name?"

first_name = gets.strip

puts "What is your middle name?"

middle_name = gets.strip

puts "What is your last name?"

last_name = gets.strip

puts " Hello, " + first_name + " " + middle_name + " " + last_name
25 changes: 25 additions & 0 deletions MichaelHanscom-elderhan/d2/leapyear.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
puts "Leap Year Calculator! Please input a year"

start = gets.to_i

puts "Please put in an end year"

ender = gets.to_i

puts " "

if (start > ender)
temp = start
start = ender
ender = temp
end

while !(((start%4) == 0))
start = start + 1
end

while (start <= ender)
puts start.to_s
start = start.to_i + 4
end

Binary file not shown.
Binary file added MichaelHanscom-elderhan/profile/images/image1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MichaelHanscom-elderhan/profile/images/image2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MichaelHanscom-elderhan/profile/images/image4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MichaelHanscom-elderhan/profile/images/image5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MichaelHanscom-elderhan/profile/images/image6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MichaelHanscom-elderhan/profile/images/image7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions MichaelHanscom-elderhan/profile/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!doctype html>
<html>
<link href="stylesheets/style.css" rel="stylesheet">
<head>
<title>Michael Hanscom</title>
</head>
<body>
<header>
<h1>Michael Hanscom</h1>
<ul>
<li><u><a href="http://dash.ga.co/elderhan/build-your-own-personal-website">About Me</a></u></li>
<li><u><a href="http://images.everytrail.com/pics/fullsize/634183-DSC00384.JPG">My Favorite Place</a></u></li>
<li><u><a href="https://www.youtube.com/watch?v=06koEdJiwZg">Music</a></u></li>
</ul>
</header>
<div class="academics">
<h3>Academics and Work</h3>
<p>University of Michigan</p> </br>
<img src="images/image2.jpg">
<p>Massachusetts General Hospital</p> </br>
<img src="images/image3.jpg">
</div>
<div class="pursuits">
<h3>Outside Pursuits</h3>
<p> Photography</p> </br>
<img src= "images/image5.jpg">
<p>Community Service</p> </br>
<img src= "images/image4.jpg">
</div>

<div class="others">
<h3>Other Things</h3>
<p> You know nothing, Jon Snow</p> </br>
<img src= "images/image7.jpg">
<p>#sharks</p> </br>
<img src= "images/image1.jpg">
</div>
</body>
</html>
Binary file not shown.
46 changes: 46 additions & 0 deletions MichaelHanscom-elderhan/profile/stylesheets/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<style>
body{
margin: 0 auto;
}
h1 {
font-size: 60px;
padding: 0 0 100px 0;
color: white;
}
header{
text-align: center;
background: url("http://i.imgur.com/kCHYHiv.jpg");
background-size: cover;
background-position: center;
}
img {
width: 200px;
position: center;
}

li {
color: white;
background: black;
display:inline;
padding: 5px;
border: 6px solid black;
border-radius: 10px;
}
a {
color: white;
}
div{
position: relative;
width: 400px;
display: inline;
margin: 0 auto;

}
.academics{
float: left;

}
.others{
float: right;
}
</style>
40 changes: 40 additions & 0 deletions michael_hanscom/d3/better_bouncer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
def lenient_bouncer
answer = true
end

def bouncer(age, country)
if country.upcase.strip == "USA"
if age >= 21
puts "You in."
else
puts "You out."
end
end
if country.upcase.strip == "SOUTHAFRICA"
if age >= 18
puts "You in."
else
puts "You out."
end
end
end

def strict_bouncer(people, letter)
people_in = Array.new

people.each do |name, age|
get_in = ((name[0] != letter) && (age >= 21))
if get_in
people_in.push name
end
end

people_in
end

people_array = Array.new
people_array[0] = ['erica', 20]
people_array[1] = ['ian', 24]
people_array[2] = ['john', 25]

puts strict_bouncer(people_array, 'j')
19 changes: 19 additions & 0 deletions michael_hanscom/d3/fizzbuzz.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def fizzbuzz(max_val)
count = 1
while (count <= max_val)
if (count%15 == 0)
puts "fizzbuzz"
else
if (count%3 == 0)
puts "fizz"
elsif (count%5 == 0)
puts "buzz"
else
puts count
end
end
count +=1
end
end

fizzbuzz(100)
17 changes: 17 additions & 0 deletions michael_hanscom/d3/hash_on_hash.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
recipes = {
"Hash Browns" => {
:description => "Cooked, delicious potatoes",
:ingredients => ["Potatoes, Butter"]
:steps => ["Put the ingredients in a frozen package", "Cook the frozen food in the oven"]
},
"Quiche " => {
:description => "A healthy option for a full dinner"
:ingredients => ["Crust, Spinach, Milk, Egg"]
:steps => ["Mix ingredients in a bowl", "Drain spinach", "Cook for one hour", "Serve"]
},
"Pizza" => {
:description => "A solid lunch choice"
:ingredients => ["Crust", "Tomato Sauce", "Cheese"]
:steps => ["Buy frozen pizza", "Cook pizza in oven"]
}
}
10 changes: 10 additions & 0 deletions michael_hanscom/d3/map.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
engines = ["Google", "Bing", "Ask Jeeves"]
engines.map do |e|
if e == "Google"
e ="OK"
elsif e== "Bing"
e ="Bad!"
else
e = "What is that?"
end
end
12 changes: 12 additions & 0 deletions michael_hanscom/d3/mumble_jumble.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def jumble(sentence)
return sentence if sentence == ''

sentence.split('').shuffle.join
end

def mumble(sentence)
return sentence if sentence.empty

sentence.downcase
end

5 changes: 5 additions & 0 deletions michael_hanscom/d3/recipes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
hash_browns = ["Potatoes", "Butter", "Other things"]
quiche = ["Spinach", "Egg", "Cheese", "Cream"]
pizza = ["Tomato Sauce", "Crust", "Cheese", "Pepperoni"]

dishes = { "Hash Browns" => hash_browns, "Quiche" => quiche, "Pizza" => pizza }
10 changes: 10 additions & 0 deletions michael_hanscom/d3/reverse.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def reverse array
new_array = Array.new
array.each do |value|
new_array.unshift(value)
end
new_array
end

fruits = ["apples", "bananas", "kiwis", "pears"]
puts reverse fruits
6 changes: 6 additions & 0 deletions michael_hanscom/d3/scope_it_out.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
1. 20 (you would see the output "IT'S SO LOUD")
2. It creates a variable called loudness which is equal to 20,
it outputs a string ("IT'S SO LOUD"), and then it returns the loudness variable
that is equal to 20
3. The value of loudness is still 10 because the scope of loudness = 20 is only
inside the method
Binary file added michael_hanscom/d4/calculator_app/.DS_Store
Binary file not shown.
38 changes: 38 additions & 0 deletions michael_hanscom/d4/calculator_app/calc_app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require "sinatra"

get "/" do
"Welcome to the calculator


In order to use the calculator, add a / in the url above, followed by
the operation/first number/secondnumber.


For example, to add 4 and 7, the address would be localhost/4567/add/4/7"
end

get "/add/:first/:second" do |first, second|
sum = first.to_i + second.to_i
"The sum of #{first} and #{second} is #{sum}"
end

get "/divide/:first/:second" do |first, second|
divide = first.to_i/second.to_i
"The division of #{first} and #{second} is #{divide}"
end

get "/multiply/:first/:second" do |first, second|
multiply= first.to_i*second.to_i
"The multiplication of #{first} and #{second} is #{multiply}"
end

get "/subtract/:first/:second" do |first, second|
subtract = first.to_i -second.to_i
"The difference of #{first} and #{second} is #{subtract}"
end

get "/exponent/:first/:second" do |first, second|
exponent = first.to_i^second.to_i
"#{first} to the power of #{second} is #{exponent}"
end

Loading