This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
# ====================================== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def version_sort | |
array = [] | |
array << filenames.split(.) | |
array.each |x| | |
x.drop("foo") | |
end | |
array.each |pieces| | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
number = 10007 | |
# def prime?(number) | |
# tries = 0 | |
# while i < number | |
# prime = false if number % high == 0 | |
# tries += 1 | |
# end | |
# end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SecretHandshake | |
attr_accessor :signal | |
def initialize(signal=str) | |
@@commands = [] | |
@@commands << "wink" if @signal.include?(/"1"/) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative './song_library.rb' | |
def jukebox(command) | |
if command.downcase == "list" | |
list_library | |
else | |
parse_command(command) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'simplecov' | |
SimpleCov.start | |
require 'json' | |
require 'rspec' | |
require_relative 'jukebox' | |
require_relative 'song' | |
#use this song data for your tests | |
songs = [ |