Skip to content

Instantly share code, notes, and snippets.

teams = {
thebest: {
colors: ["orange","purple"],
players:{
don: {
number: 1, shoe_size: 9, points: 5, rebounds: 6, assists: 7, steals: 8, blocks: 9, slam_dunks: 10
},
jon: {
number: 2, shoe_size: 8, points: 6, rebounds: 7, assists: 8, steals: 9, blocks: 10, slam_dunks: 11
teams = {
thebest: {
colors: ["orange","purple"],
players:{
don: {
number: 1, shoe_size: 9, points: 5, rebounds: 6, assists: 7, steals: 8, blocks: 9, slam_dunks: 10
},
jon: {
number: 2, shoe_size: 8, points: 6, rebounds: 7, assists: 8, steals: 9, blocks: 10, slam_dunks: 11
-- SQL Basic Syntax --
--initialize SQLite database w/ command line:
sqlite3 database_name.db
--helpful commands
.help -- list of commands
.tables -- see all tables
.mode column / .header on -- helpful for viewing
class Anagram
attr_accessor :word
def initialize(word)
@word = word
end
def match(array)
@word = @word.split("").sort
array.select { |element| element.split("").sort == @word }
class Jukebox
attr_accessor :songs
DefaultSongs = [
"The Phoenix - 1901",
"Tokyo Police Club - Wait Up",
"Sufjan Stevens - Too Much",
"The Naked and the Famous - Young Blood",
"(Far From) Home - Tiga",
"The Cults - Abducted",
class School
attr_reader :roster,:school
def initialize(school)
@school = school
@roster = {}
end
def roster
@roster
class TriangleError < Exception
end
class Triangle
attr_reader :side1, :side2, :side3
def initialize(side1, side2, side3)
@side1 = side1
@side2 = side2
@side3 = side3
def is_a_vowel?(v)
'aeiou'.include?(v)
end
class Integer
@@roman_numerals = {
1000 => "M",
900 => "CM",
500 => "D",
400 => "CD",
100 => "C",
90 => "XC",
50 => "L",
40 => "XL",
def initialize(attributes)
attributes.each do |attribute, value|
self.class.send(:define_method, attribute) do
@attribute = value
end
end
end
end