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 Game < ActiveRecord::Base | |
belongs_to :category | |
validates_presence_of :title, :category_id, :description, | |
:price, :platform, :year | |
def price | |
price = read_attribute(:price) | |
unless price.present? | |
update_attribute(:price, GamePriceService.new(self).get_price) | |
read_attribute(:price) |
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
# Expand print panel by default | |
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true | |
# Disable the “Are you sure you want to open this application?” dialog | |
defaults write com.apple.LaunchServices LSQuarantine -bool false | |
# Enable subpixel font rendering on non-Apple LCDs | |
defaults write NSGlobalDomain AppleFontSmoothing -int 2 | |
# Disable press-and-hold for keys in favor of key repeat |
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
Install XCode *and* Command Line Tools (just CLT won't be enough, readline won't work =[) | |
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2 | |
sudo ln -s /usr/bin/g++ /usr/bin/g++-4.2 | |
brew install wget openssl readline libyaml curl libxslt | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz | |
tar xzvf ruby-1.9.3-p392.tar.gz | |
cd ruby-1.9.3-p392 |
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 Game < ActiveRecord::Base | |
belongs_to :category | |
validates_presence_of :title, :category_id, :description, | |
:price, :platform, :year | |
end | |
class GamePriceService | |
attr_accessor :game | |
# we could use a config file |
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 Game < ActiveRecord::Base | |
belongs_to :category | |
validates_presence_of :title, :category_id, :description, | |
:price, :platform, :year | |
end | |
class GamePriceService | |
attr_accessor :game, :json_parser | |
# we could use a config file |
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 Game < ActiveRecord::Base | |
belongs_to :category | |
validates_presence_of :title, :category_id, :description, | |
:price, :platform, :year | |
end | |
class GamePriceService | |
attr_accessor :game | |
# we could use a config file |
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
# WARNING: pseudo code | |
class Authenticator | |
def initialize(user_repository = User) | |
@user_repository = user_repository | |
end | |
def authenticate(identifier, hashed_password) | |
@user_repository.find(:username => identifier, :password => hashed_password).present? | |
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 UserController < ApplicationController | |
def create | |
@user_creation = UserCreation.new(self) | |
@user_creation.on_success { redirect_to users_path } | |
@user_creation.on_failure { render :new } | |
@user_creation.please_create_an_user_as_admin(params[:user]) | |
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
class CardData | |
def initialize(node) | |
@card_data = node | |
end | |
def name | |
@card_data.search("name").text | |
end | |
def image |
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
# on spec/helpers | |
module FormHelper | |
def fill_in_autocomplete(selector, value) | |
page.execute_script %Q{$('#{selector}').focus().val('#{value}').keydown()} | |
end | |
def choose_autocomplete(text) | |
find('ul.ui-autocomplete').should have_content(text) | |
page.execute_script("$('.ui-menu-item:contains(\"#{text}\")').find('a').trigger('mouseenter').click()") | |
end |