Skip to content

Instantly share code, notes, and snippets.

View ahimmelstoss's full-sized avatar

Amanda Himmelstoss ahimmelstoss

View GitHub Profile
# 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
def full_library
{
:"U2" => {
:albums => {
:"The Joshua Tree" => {
:songs => ["With or Without You", "Still Haven't Found What I'm Looking For", "Bullet the Blue Sky"]
},
:"Zooropa" => {
:songs => ["Numb"]
}
require_relative './jukebox.rb'
def run
puts "Welcome to Ruby Console Jukebox!"
command = ""
while command.downcase != "exit" do
puts "Enter a command to continue. Type 'help' for a list of commands."
command = get_command
run_command(command) unless command.downcase == "exit"
end
require_relative './song_library.rb'
def jukebox(command)
if command.downcase == "list"
list_library
else
parse_command(command)
end
end
@ahimmelstoss
ahimmelstoss / to-scrape.txt
Created October 4, 2013 18:50
to scrape from student profile pages
#table/database 003-students
#student_name h4 class="ib_main_header"
#twitter_link div class="social-icons" ahref
#linkedin_link div class="social-icons" ahref
#github_link div class="social-icons" ahref
#quote div class="textwidget" h3
#biography div class="services" where h3(div class="services-title") is Biography (text for bio in p)
#education div class="services" where h3(div class="services-title") is Education (text for University in li)
#work div class="services" h4
#treehouse_link div class="column-fourth" ahref with img alt="Treehouse"