This file contains 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
def normalize_phone_number(phone) | |
if phone[/a-zA-Z/] == nil | |
phone.each_char do |x| | |
if !(x.match(/[\d]/)) | |
phone.delete! x | |
end | |
end | |
phone.insert(0, "(") | |
phone.insert(4, ") ") | |
phone.insert(9, "-") |
This file contains 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
######################## | |
# NYC PIGEON ORGANIZER # | |
######################## | |
pigeon_data = { | |
:color => { | |
:purple => ["Theo", "Peter Jr.", "Lucky"], | |
:grey => ["Theo", "Peter Jr.", "Ms .K"], | |
:white => ["Queenie", "Andrew", "Ms .K", "Alex"], | |
:brown => ["Queenie", "Alex"] |
This file contains 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 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 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 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 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 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 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 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" | |
] |