Skip to content

Instantly share code, notes, and snippets.

Name: Michael Polycarpou
Github: http://github.com/polycarpou
Blog: http://michaelpolycarpou.com/
Tagline: Engineering The Future
Profile Picture: https://scontent-a-lga.xx.fbcdn.net/hphotos-ash3/1013112_10153019457290517_719698305_n.jpg
Treehouse Account: http://teamtreehouse.com/michaelpolycarpou
CoderWall Account: https://coderwall.com/polycarpou
CodeSchool Account: http://www.codeschool.com/users/polycarpou
Favorite Websites:
@polycarpou
polycarpou / earthly-sandwich-tutorial
Created September 24, 2013 03:59
alien sandwich
Welcome to Earth!
The following is a tutorial on how to make peanut butter and jelly sandwiches exactly how real humans make them in 10 easy steps!
1. Open the bread wrapper. The bread is the large, yellow, soft object on the table that also has bread written on it. The actual bread is wrapped around a thin and clear wrapper that contains the bread within. The easiest way to get to the bread is to create a hole in the wrapper by applying a large force (approximately 40 newtons to an area the size of a finger (50cm squared). Do this without harming the bread inside.
2. Place a slice of bread on the plate. To do this we need to widen the hole in the wrapper and gently take out one of the sections of the bread without ripping it apart. Place this slice on the plate which is the circular hard flat object on the table.
3. Open Peanut butter jar. To open the peanut butter jar (the brown hard cylinder container that says peanut butter) we grip the bottom of the jar with one hand so that it is stationary and w
@polycarpou
polycarpou / SQL Schema and Tables
Created September 25, 2013 04:34
SQL schema and Tables homework for Day 2, week 1
CREATE TABLE artists(
name TEXT,
age INTEGER,
genre TEXT,
sales, INTEGER,
weight, REAL
);
ALTER TABLE artists ADD COLUMN language TEXT;
ALTER TABLE artists ADD COLUMN description TEXT;
@polycarpou
polycarpou / assignment.rb
Created September 25, 2013 22:33
fizzbuzz day 3 homework assignment
def fizzbuzz(x)
if x%3 ==0 && x%5 ==0
puts "fizzbuzz"
elsif x%3 ==0
puts "fizz"
elsif x%5 ==0
puts "buzz"
end
end
fizzbuzz(5)
@polycarpou
polycarpou / my_each.rb
Created September 27, 2013 03:42
creating my own each method
def my_each(arr)
count = 0
while count <= arr.length
yield(arr[count])
count += 1
end
end
my_each([1,2,3,4,6]) do |x|
puts x
@polycarpou
polycarpou / vowels.rb
Created September 27, 2013 03:45
week 1 day 4 vowels homework
def is_a_vowel1(letter)
if letter == "a"
return true
elsif letter == "e"
return true
elsif letter == "i"
return true
elsif letter == "o"
return true
elsif letter == "u"
@polycarpou
polycarpou / badges.rb
Created September 27, 2013 03:46
week1 day4 homework badges
def print_badge(name)
"Hello, my name is #{name}."
end
#puts print_badge("Michael")
speakers = "Edsger, Ada, Charles, Alan, Grace, Linus, Matz"
speakers = speakers.split(", ")
#p speakers
@polycarpou
polycarpou / ruby_phone_format.rb
Created September 27, 2013 13:49
invalid phone numbers
# Download this file:
# https://gist.github.com/scottcreynolds/ac1b5c8d96de0c91bf7c/download
# Run it from your terminal with:
# ruby ruby_phone_format.rb
# (Just make sure you are in the right directory)
# ======================================
# Ignore All This Code
# ======================================
@polycarpou
polycarpou / tweet_shortener.rb
Created September 27, 2013 14:32
tweet shortener week 1 day 4
def shorten_tweet(tweet)
return tweet if tweet.length < 140
tweet = tweet.split(" ")
out = []
tweet.each do |word|
case word
when "to", "two", "too"
out << '2'
when "for", "four"
out << '4'
@polycarpou
polycarpou / hasketball.rb
Created October 1, 2013 05:15
Hasketball question without the bonus
# Hashketball Nests
#
# Great news! You're going to an NBA game! The only catch is that you've been
# volunteered to keep stats at the game.
#
# Using Nested Hashes, define a game, with two teams, their players, and the players stats:
#
# The game has two teams.
#
# A team has: