Skip to content

Instantly share code, notes, and snippets.

@ivanbrennan
ivanbrennan / alien-sandwich-ivanbrennan
Created September 24, 2013 02:34
Alien Sandwich. Step-by-step instructions for an alien to make a peanut-butter and jelly sandwich. -Ivan Brennan
1. Look at the objects on the table.
2. Find the cylinder containing brown stuff. This is the jar of peanut-butter.
3. Wrap your left hand firmly around that jar and place your right hand over the top of the jar.
4. Your right hand is resting on the jar's lid. Squeeze your right hand around the lid and maintain that pressure to hold the lid firmly in place.
5. Curl your left hand so your palm turns toward your body, rotating the jar while the lid stays in place.
6. Try to lift the lid upwards off the jar with your right hand.
7. If the lid doesn't lift freely off the jar, stop trying to pull it off, open your left hand and bring it back to its in initial position wrapped around the jar (as in step 3), and repeat from step 4.
8. Lift the lid off the top of the jar with your right hand and put the lid down on the table, beside that jar.
9. Release both hands and find the other cylinder, which contains either red or purple stuff. This is the jar of jelly.
10. Repeat steps 3 through 8 with the jar of jel
@ivanbrennan
ivanbrennan / profile-content
Created September 24, 2013 03:11
profile content
Name: Ivan Brennan
Github: https://github.com/ivanbrennan
Blog Url: githubivanbrennan.github.io
Tagline: Tag!
Profile Picture: http://m.c.lnkd.licdn.com/mpr/mpr/shrink_200_200/p/8/000/1c4/3a6/23d8826.jpg
Treehouse Account: http://teamtreehouse.com/ivanbrennan
Coderwall Account: https://coderwall.com/ivanbrennan
Codeschool Account: http://www.codeschool.com/users/ivanbrennan
Favorite Websites:
@ivanbrennan
ivanbrennan / fizzbuzz.rb
Last active December 23, 2015 23:09
FizzBuzz baby!
def fizzbuzz(number)
if (number % 3 == 0) && (number % 5 == 0)
puts "FizzBuzz"
elsif number % 3 == 0
puts "Fizz"
elsif number % 5 == 0
puts "Buzz"
else
puts number
end
@ivanbrennan
ivanbrennan / quiz.rb
Created September 26, 2013 00:50
Quiz submission
# Write a program that tells you the following:
#
# Hours in a year. How many hours are in a year?
# Minutes in a decade. How many minutes are in a decade?
# Your age in seconds. How many seconds old are you?
#
# Define at least the following methods to accomplish these tasks:
#
# seconds_in_minutes(1)
# minutes_in_hours(1)
@ivanbrennan
ivanbrennan / simple-array.rb
Created September 26, 2013 19:16
Simple array
favorite_foods = ['chicken', 'rice', 'peach', 'nectarine', 'zuchini']
most_fav_food = favorite_foods[2]
puts most_fav_food
colors_of_rainbow = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']
red, orange, yellow = colors_of_rainbow[0..2]
empty_arr = []
empty_arr[1] = "b"
empty_arr[5] = "f"
@ivanbrennan
ivanbrennan / the-second-program.rb
Created September 26, 2013 22:45
The Second Program
# Given this List of Songs, Construct Arrays by Artist and Album
# Hint: Make use of the split() String Method
# http://www.ruby-doc.org/core-1.9.3/String.html#method-i-split
# Simple Example of Data Parsing
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",
@ivanbrennan
ivanbrennan / badges.rb
Created September 26, 2013 23:27
Conference Badges and Schedules
def get_badge(name)
"Hello, my name is #{name}."
end
def get_badges(names_arr)
badges_arr = []
names_arr.each do |name|
badges_arr << get_badge(name)
end
badges_arr
@ivanbrennan
ivanbrennan / vowels-etc.rb
Created September 27, 2013 00:05
Different ways to discover what's true
#1
def is_vowel_elsif?(letter)
if letter == "a"
true
elsif letter == "e"
true
elsif letter == "i"
true
elsif letter == "o"
true
@ivanbrennan
ivanbrennan / tweet-shortener.rb
Created September 27, 2013 04:01
Tweet shortening!
subs = {"to" => "2", "two" => "2", "too" => "2",
"for" => "4", "four" => "4", "be" => "b",
"you" => "u", "at" => "@", "and" => "&"}
def string_shortener(str, subs)
punks = [" ", ".", "?", "!", ","]
current_word = ""
shortened_str = ""
return str if str.length <= 140
@ivanbrennan
ivanbrennan / my_each.rb
Created September 27, 2013 04:52
Handmade yield
def my_each(array)
empty = (array.length == 0)
i = 0
while (i < array.length) && !empty
yield array[i]
i += 1
end
array
end