Skip to content

Instantly share code, notes, and snippets.

View codeschool-courses's full-sized avatar

Code School Courses codeschool-courses

View GitHub Profile
class Tweet < ActiveRecord::Base
scope :recent, -> { order('created_at desc').limit(4) }
scope :graveyard, -> { where(show_location: true, location: "graveyard") }
end
@codeschool-courses
codeschool-courses / json.js
Last active December 12, 2015 00:28
Backbone 2 - Challenge 1-5
{ "appointment": { "title": "Ms. Kitty Hairball Treatment", "cankelled": false, "identifer": 1 }
@codeschool-courses
codeschool-courses / game.rb
Created October 13, 2012 20:40
RubyBits II 6-6 - game.rb
class Game
attr_reader :name, :tags
def initialize(name)
@name = name
@tags = []
end
def year(value)
@year = value
@codeschool-courses
codeschool-courses / game_dsl.rb
Created October 13, 2012 20:39
RubyBits II 6-5 - game_dsl.rb
LIBRARY = Library.new
def add_game(name, system = nil, year = nil, &block)
game = Game.new(name)
game.system(system) if system
game.year(year) if year
game.instance_eval(&block) if block_given?
LIBRARY.add_game(game)
end
@codeschool-courses
codeschool-courses / example.rb
Created October 13, 2012 20:38
RubyBits II 6-5 - example.rb
add_game "Super Metroid", "SNES", 1994
with_game "Super Metroid" do
play # we expect this to raise an exception
end
@codeschool-courses
codeschool-courses / game.rb
Created October 13, 2012 20:36
RubyBits II 6-4 - game.rb
class Game
attr_reader :name, :tags
def initialize(name)
@name = name
@year = nil
@system = nil
@tags = []
end
@codeschool-courses
codeschool-courses / library.rb
Created October 13, 2012 20:35
RubyBits II 6-4 - library.rb
class Library
def initialize
@games = []
end
def add_game(game)
@games << game
end
def find_by_name(name)
@codeschool-courses
codeschool-courses / example.rb
Created October 13, 2012 20:35
RubyBits II 6-4 - example.rb
add_game "Civilization" do
system "PC"
year 1991
strategy # These two method names
turn_based # should become tags
end
with_games_tagged "strategy" do
print_details
end
@codeschool-courses
codeschool-courses / game_dsl.rb
Created October 13, 2012 20:33
RubyBits II 6-3 - game_dsl.rb
LIBRARY = Library.new
def add_game(name, system = nil, year = nil, &block)
game = Game.new(name)
game.system(system) if system
game.year(year) if year
game.instance_eval(&block) if block_given?
LIBRARY.add_game(game)
end
@codeschool-courses
codeschool-courses / example.rb
Created October 13, 2012 20:32
RubyBits II 6-3 - example.rb
add_game "Civilization" do
system "PC"
year 1991
strategy # These two method names
turn_based # should become tags
end