Skip to content

Instantly share code, notes, and snippets.

View ahimmelstoss's full-sized avatar

Amanda Himmelstoss ahimmelstoss

View GitHub Profile
@ahimmelstoss
ahimmelstoss / fizzbuzzhw.rb
Last active December 23, 2015 23:19
fizzbuzz homework
def fizzbuzz
for n in 1..50
if (n % 3== 0) && (n % 5 == 0)
puts "FizzBuzz"
elsif n % 3 == 0
puts "Fizz"
elsif n % 5 == 0
puts "Buzz"
else
nil
@ahimmelstoss
ahimmelstoss / quiz.rb
Last active December 23, 2015 23:19
ruby lecture 1 quiz
def seconds_in_minutes(minutes)
minutes * 60
end
puts seconds_in_minutes(2)
def minutes_in_hours(hours)
hours * 60
end
puts minutes_in_hours(3)
@ahimmelstoss
ahimmelstoss / firstprogram.rb
Last active December 23, 2015 23:19
first program, ruby lecture 1
song1 = 223
song2 = 215
song3 = 378
song4 = 324
song5 = 254
total_length = song1+song2+song3+song4+song5
puts total_length
length_minutes = total_length / 60.0
@ahimmelstoss
ahimmelstoss / namelettercount.rb
Last active December 23, 2015 23:19
a program that counts the letters in your name, given input. from chris pine's learn to program ch6.
puts "What is your first name?"
first_name = gets.chomp
puts "What is your middle name?"
middle_name = gets.chomp
puts "What is your last name?"
last_name = gets.chomp
puts "Did you know that here are " + (first_name.length + middle_name.length + last_name.length).to_s + " characters"
puts "in your name, " + first_name.capitalize + " " + middle_name.capitalize + " " + last_name.capitalize + "?"
@ahimmelstoss
ahimmelstoss / angryboss.rb
Last active December 23, 2015 23:19
angry boss program, from chris pine's ch6
puts "WHAT DO YOU WANT?"
request = gets.chomp
puts "WHAT DO YOU MEAN, " + "'" + request.upcase.to_s + "'" + "?! YOU'RE FIRED!!"
require 'awesome_print'
songs = [
"The Magnetic Fields - 69 Love Songs - Parades Go By",
"The Magnetic Fields - Get Lost - Smoke and Mirrors",
"Neutral Milk Hotel - In An Aeroplane Over the Sea - Holland 1945",
"The Magnetic Fields - Get Lost - You, Me, and the Moon",
"The Magnetic Fields - 69 Love Songs - The Book of Love",
"Neutral Milk Hotel - In An Aeroplane Over the Sea - The King of Carrot Flowers"
]
@ahimmelstoss
ahimmelstoss / tweet-shortener.rb
Last active December 24, 2015 01:29
shortening tweets by turning them into arrays and iterating over them with a hash of substitutions.
require 'awesome_print'
tweet1 = "Hey guys, can anyone teach me how to be cool? I really want to be the best at everything, you know what I mean? Tweeting is super fun you guys!!!!"
tweet2 = "OMG you guys, you won't believe how sweet my kitten is. My kitten is like super cuddly and too cute to be believed right?"
tweet3 = "I'm running out of example tweets for you guys, which is weird, because I'm a writer and this is just writing and I tweet all day. For real, you guys. For real."
tweet4 = "GUISEEEEE this is so fun! I'm tweeting for you guys and this tweet is SOOOO long it's gonna be way more than you would think twitter can handle, so shorten it up you know what I mean? I just can never tell how long to keep typing!"
tweet5 = "to two too four for be you at and"
$substitutions_hash = { #global variable to work in method
"to" => "2", "two" => "2", "too" => "2", "for" => "4", "four" => "4", "be" => "b",
@ahimmelstoss
ahimmelstoss / conference-lab.rb
Created September 27, 2013 03:19
Conference Lab
$conference_speakers = ["Edsger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matz"]
def badge_printer(speaker_array)
speaker_array.each do |name|
puts "Hello, my name is #{name}!"
end
end
def room_assignments(speaker_array)
speaker_array.each_index do |index|
$songs = [
"The Phoenix - 1901",
"Tokyo Police Club - Wait Up",
"Sufjan Stevens - Too Much",
"The Naked and the Famous - Young Blood",
"(Far From) Home - Tiga",
"The Cults - Abducted",
"The Phoenix - Consolation Prizes"
]
def reverse_each_word(sentence)
sentence_array = sentence.split(" ")
sentence_array.collect {|word| word.reverse}.join(" ")
end
puts reverse_each_word("Hello there, and how are you?")
#=> "olleH ,ereht dna woh era ?uoy"