Skip to content

Instantly share code, notes, and snippets.

View ahimmelstoss's full-sized avatar

Amanda Himmelstoss ahimmelstoss

View GitHub Profile
@ahimmelstoss
ahimmelstoss / pigeon.rb
Created October 11, 2013 18:50
currently refactoring
# Start with the following collected data on NYC pigeons.
pigeon_data = {
:color => {
:purple => ["Theo", "Peter Jr.", "Lucky"],
:grey => ["Theo", "Peter Jr.", "Ms .K"],
:white => ["Queenie", "Andrew", "Ms .K", "Alex"],
:brown => ["Queenie", "Alex"]
},
:gender => {
def my_each(array)
i = 0
while i < array.length
raise (yield(array[i])).inspect
i+=1
end
array
end
array = [1, 2, 3]
# Write a method that returns whether a given letter is a vowel, using if and elsif
def is_vowel1(letter)
letter.downcase!
if letter == "a"
return true
elsif letter == "e"
return true
elsif letter == "i"
return true
def my_each(array)
i = 0
while i < array.length
raise (yield(array[i])).inspect
i+=1
end
array
end
array = [1, 2, 3]
# Download this file:
# https://gist.github.com/aviflombaum/872638777f7511d2a30a/download
# Run it from your terminal with:
# ruby ruby.basics.rb
# (Just make sure you are in the right directory)
# ======================================
# Ignore All This Code
# ======================================
class Person
attr_accessor :name, :birthday, :hair_color, :eye_color, :height, :weight, :handed,
:complexion, :t_shirt_size, :wrist_size, :glove_size, :pant_length, :pant_width
def initialize(attributes)
attributes.each do |key, value|
self.instance_variable_set("@#{key}", value)
end
end
require 'sqlite3'
class Student
attr_accessor :name, :twitter, :linkedin, :facebook, :website, :id
@@db = SQLite3::Database.new 'students.db'
@@students = []
def initialize
class TriangleError < Exception
end
class Triangle
attr_accessor :side1, :side2, :side3
def initialize(side1, side2, side3)
@side1 = side1
@side2 = side2
@side3 = side3
songs = {
"The Phoenix - 1901" => "https://www.youtube.com/watch?v=gvss3uhSKjw",
"Tokyo Police Club - Wait Up" => "https://www.youtube.com/watch?v=ZAxRozTgoXM",
"Sufjan Stevens - Too Much" => "https://www.youtube.com/watch?v=K0g7R3xqdcM",
"The Naked and the Famous - Young Blood" => "https://www.youtube.com/watch?v=0YuSg4mts9E",
"(Far From) Home - Tiga" => "https://www.youtube.com/watch?v=jTwQbc9kkUc",
"The Cults - Abducted" => "https://www.youtube.com/watch?v=9i1MXHGB8g0",
"The Phoenix - Consolation Prizes" => "https://www.youtube.com/watch?v=gnkVUReUVpQ"
}
@ahimmelstoss
ahimmelstoss / anagram.rb
Created October 7, 2013 14:51
anagram class using chars.sort to match a word's anagram in an array of words. chars.sort sorts the characters in a string.
class Anagram
attr_accessor :word
def initialize(word)
@word = word
end
def match(words_array)
words_array.select {|element| element.chars.sort == @word.chars.sort}
end