Skip to content

Instantly share code, notes, and snippets.

View rosiehoyem's full-sized avatar

Rosie Hoyem rosiehoyem

View GitHub Profile
@rosiehoyem
rosiehoyem / ruby.basics.rb
Created October 13, 2013 20:56
Ruby basics TODO, day 3
# Download this file:
# https://gist.github.com/aviflombaum/28534c5d69edd2439a7d/download
# Run it from your terminal with:
# ruby ruby.basics.rb
# (Just make sure you are in the right directory)
# ======================================
# Ignore All This Code
# ======================================
@rosiehoyem
rosiehoyem / person_class.rb
Created October 13, 2013 19:04
Mass-assignment of attributes at initialization, day 14.
attributes = {
:name => "Avi",
:birthday => "01/29/1984",
:hair_color => "brown",
:eye_color => "brown",
:height => "tall",
:weight => "good",
:handed => "lefty",
:complexion => "decent",
:t_shirt_size => "medium",
@rosiehoyem
rosiehoyem / tower_of_hanoi.rb
Last active December 25, 2015 10:59
Tower of Hanoi, Day 7
#Tower of Hanoi
# Recursive solution:
# http://www.sparknotes.com/cs/recursion/examples/section6.rhtml
def toh(n, source = 'A', temp = 'B', dest = 'C')
toh(n - 1, source, dest, temp) if n > 1 # move all n - 1 disks to temp pole
puts "Move top disc #{n}: #{source} => #{dest}." # move bottom disk to destination pole
toh(n - 1, temp, source, dest) if n > 1 # move all n - 1 disks to destination pole
end
@rosiehoyem
rosiehoyem / version_sort.rb
Created October 13, 2013 18:37
Version sort TODO, Day 7
class Array
def version_sort
array = []
array << filenames.split(.)
array.each |x|
x.drop("foo")
end
array.each |pieces|
end
@rosiehoyem
rosiehoyem / prime.rb
Created October 13, 2013 18:01
Prime number example from day 7
number = 10007
# def prime?(number)
# tries = 0
# while i < number
# prime = false if number % high == 0
# tries += 1
# end
# end
@rosiehoyem
rosiehoyem / insert.sql
Created October 13, 2013 17:53
SQL Build Kickstarter, Day 9
INSERT INTO users(id, name, age)
VALUES
(1, "Casey", 24),
(2, "Angie", 20),
(3, "Samantha", 17),
(4, "Greg", 40),
(5, "Andrew", 43),
(6, "John", 64),
(7, "Camille", 20),
(8, "Cynthia", 50),
@rosiehoyem
rosiehoyem / handshake.rb
Created October 13, 2013 17:44
Secret Handshake TODO, Day 12
class SecretHandshake
attr_accessor :signal
def initialize(signal=str)
@@commands = []
@@commands << "wink" if @signal.include?(/"1"/)
end
end
@rosiehoyem
rosiehoyem / jukebox.rb
Created October 13, 2013 17:32
Debug TODO, Day 12
require_relative './song_library.rb'
def jukebox(command)
if command.downcase == "list"
list_library
else
parse_command(command)
end
end
@rosiehoyem
rosiehoyem / jukebox_oo_refactored.rb
Created October 13, 2013 17:28
Object Oriented Jukebox, Day 12
songs = ["Miley Cyrus - We Can't Stop",
"Katy Perry - Roar",
"Robin Thicke - Blurred Lines",
"Daft Punk - Get Lucky",
"Miley Cyrus - Wrecking Ball",
"Lady Gaga - Applause",
"Miley Cyrus - Party in the USA",
"Avicii - Wake Me Up"
]
@rosiehoyem
rosiehoyem / jukebox_spec.rb
Created October 13, 2013 17:24
Jukebox Rspec code coverage lab
require 'simplecov'
SimpleCov.start
require 'json'
require 'rspec'
require_relative 'jukebox'
require_relative 'song'
#use this song data for your tests
songs = [