Skip to content

Instantly share code, notes, and snippets.

View joegiralt's full-sized avatar
💣
:p

Joseph Giralt joegiralt

💣
:p
View GitHub Profile
@joegiralt
joegiralt / day6homework1.rb
Last active December 18, 2015 08:09
homework
# Construct an array with your favorite foods. It should have at least 5 elements.
favorite_foods = ["Chicken tikka Masalla",
"Roasted Rabbit",
"Fried Ocra",
"Chanterelle Mushroom Soup",
"Pan Seared Skirt Steak"]
# Write a puts which returns your most favorite food out of the array.
# Create Hashes for the following use-cases.
# A movie collection that organizes by genres
movies = {
"horror" => ["night of the living dead", "exorcist"],
"adventure" => ["return of the jedi", "romancing the stone"],
"comedy" => ["dumb and dumber", "fargo"]
@joegiralt
joegiralt / day6homework3.rb
Created June 10, 2013 22:08
method chaining
# Chain at least 5 method calls to an object. Reduce this operation one chain at a time.
# Don't just use the methods below, make up your own chain and try to see if you can do something fun with Ruby like in the example.
# Example:
# puts "start".reverse.slice(0,2).concat("uth").capitalize
# # => Truth
# Because:
@joegiralt
joegiralt / day6homework4.rb
Created June 10, 2013 22:13
tempaturebot
# Temperature bot is American but takes Celsius temperatures.
#
def temperature_bot(temp)
case temp
when temp <= 21 && 18 <= temp
"I like this temperature"
else
"This is uncomfortable for me"
end
end
@joegiralt
joegiralt / day6homework5.rb
Created June 11, 2013 00:44
hashkett ball
# 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:
# A name
# Two colors
# Each team should have at least 5 players
# Each player should have a:
require 'nokogiri'
require 'sqlite3'
require 'open-uri'
# def comb_page
# page = Nokogiri::HTML(open("http://students.flatironschool.com/students/chrisgonzales.html"))
# student_name = page.search("h4").first.text
# quote = page.search("h3").first.text
# scraped_database = SQLite3::Database.new ":scraped_data:"
@joegiralt
joegiralt / scraper2.rb
Created June 13, 2013 16:30
scraper2.rb
require 'nokogiri'
require 'sqlite3'
require 'open-uri'
# def comb_page
# page = Nokogiri::HTML(open("http://students.flatironschool.com/students/chrisgonzales.html"))
# student_name = page.search("h4").first.text
# quote = page.search("h3").first.text
# scraped_database = SQLite3::Database.new ":scraped_data:"
@joegiralt
joegiralt / codebreaker.rb
Created June 13, 2013 19:13
What Chris and I worked on on Weds
##Objectives:
Use String, Hash, Array, and Enumerable methods to decode a string and discover a secret message
INSPIRATION: http://www.youtube.com/watch?v=Wj1d85CLDOQ
##Skills:
String.split, Array.each, Hash.each, Hash.sort_by, Range.to_a, Array.reverse, Array.push, Array.join, String.gsub, Array.index
##Instructions:
#Comments explain steps to manipulate string
@joegiralt
joegiralt / prime.rb
Created June 14, 2013 20:24
prime.rb
def sqrt(y)
y = y ** 0.5
return y
end
def is_prime(x)
return false if x <= 1
2.upto(sqrt(x).to_i).any do |x|
return false if x %x == 0
@joegiralt
joegiralt / OOjukebox.rb
Created June 15, 2013 19:30
object oriented juke box
# jukebox.rb