Skip to content

Instantly share code, notes, and snippets.

View TrevMcKendrick's full-sized avatar

Trevor McKendrick TrevMcKendrick

View GitHub Profile
@TrevMcKendrick
TrevMcKendrick / Profile Content
Created September 24, 2013 03:12
Profile Content – Due 9/24/13
Name: Trevor McKendrick
Github: http://github.com/TrevMcKendrick
Blog: http://trevormckendrick.com
Tagline: Gets to the point
Profile Picture: http://www.trevormckendrick.com/headshot.jpg
Treehouse Account: http://teamtreehouse.com/trevormckendrick
CoderWall Account: https://coderwall.com/trevmckendrick
CodeSchool Account: http://www.codeschool.com/users/trevmckendrick
Favorite Websites:
@TrevMcKendrick
TrevMcKendrick / Alien PB&J
Created September 24, 2013 03:35
Alien PB&J
def remove_bread(slices)
Place alien hand in bag
Grab slices
Remove alien hand from bag with slices in hand
Place_slices(prepare)
end
def place_slices(stage_of_meal)
if stage_of_meal == prepare
slices should be centered, next to each other. NOT on top of each other
@TrevMcKendrick
TrevMcKendrick / magical.db assignment
Created September 25, 2013 03:45
magical.db assignment
[23:35:51] code
-> mkdir artists
[23:35:55] code
-> cd artists/
[23:35:58] artists
-> sqlite3 artists.db
SQLite version 3.7.12 2012-04-03 19:43:07
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE artists(
#1 Define a fizzbuzz method to do the following:
def fizzbuzz_it(number)
if number % 3 == 0 && number % 5 == 0
return "FizzBuzz"
elsif number % 3 == 0
return "Fizz"
elsif number % 5 == 0
return "Buzz"
end
#From [rubeque](http://rubeque.com/problems/temperature-robot)
#Temperature bot is comfortable when it's room temperature (18-21C). Help him out by completing the method below:
#Temperature bot is American but takes Celsius temperatures.
def temperature_bot(temp)
if temp >= 18 && temp <= 21
puts "I like this temperature"
def my_each(array)
i = 0
while i < array.length do
yield(array[i])
i += 1
end
end
my_each(["boy",7,true,"awesome_sauce","YES"]) { |x| puts x}
# Let's go back to the exercise where we determined what is and isn't a vowel.
# With ruby, there's always more than one way to do something and get the same
# result.
# Assuming vowels `a,e,i,o,u`:
# 1. Write a method that returns whether a given letter is a vowel, using `if`
# and `elsif`
def is_vowel_one?(letter)
# You're hosting a conference and need to print badges for the speakers. Each
# badge should say: "Hello, my name is _____."
# **Write a method that will create and return this message, given a person's
# **name.**
def badge(name)
"Hello my name is #{name}"
end
#badge("Trevor")
@TrevMcKendrick
TrevMcKendrick / gist:6728872
Created September 27, 2013 13:49
todo parse phone #'s
def normalize_phone_number(str)
parsed_str = str.gsub(/[^0-9]/, "")
return str if parsed_str.length != 10
parsed_str.insert(0, "(")
parsed_str.insert(4, ") ")
parsed_str.insert(9, "-")
return parsed_str
@TrevMcKendrick
TrevMcKendrick / hashketball.rb
Created October 1, 2013 13:06
Hashketball Homework
game = {
:the_lakers => {
:name => "The Lakers",
:colors => ["purple","gold"],
:players => {
:daniel_mckendrick => {
:stats => {
:points => 25,
:rebounds => 5,
:assists => 3,