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
# | |
# Cookbook Name:: delayed_job | |
# Recipe:: default | |
# | |
if ['solo', 'app', 'app_master'].include?(node[:instance_role]) | |
# be sure to replace "app_name" with the name of your application. | |
run_for_app("maloca") do |app_name, data| | |
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
rails_root = "/data/github/current" | |
20.times do |num| | |
God.watch do |w| | |
w.name = "dj-#{num}" | |
w.group = 'dj' | |
w.interval = 30.seconds | |
w.start = "rake -f #{rails_root}/Rakefile production jobs:work" | |
w.uid = 'git' |
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
#app/presenters/article_presenter | |
module ArticlePresenter | |
def fancy_name | |
end | |
end | |
#app/presenters/comment_presenter | |
module CommentPresenter | |
def fancy_name | |
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 Show | |
attr_reader :games | |
def initialize | |
@games = [] | |
end | |
def first_pick(door) | |
@current_game = Game.new(door) | |
@current_game.first_pick(door) |
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
# Suppose you were designing a library named "Zippo". | |
# How would you organize the exceptions thrown by the library. | |
# Option 1 | |
# All library errors inheriting from a common base | |
module Zippo | |
class ZippoError < StandardError; end | |
class ZippoArgumentError < ZippoError; end | |
class ZippoTypeError < ZippoError; 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 FormHelper | |
attr_accessor :form | |
def initialize(nsform=nil) | |
@form = nsform | |
end | |
def length | |
form.numberOfRows | |
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
#!/usr/bin/env ruby | |
module TopLevel | |
CONST_D = :d_from_top_level | |
module MiddleLevel | |
class BottomLevel | |
CONST_A = :foo | |
CONST_B = :bar | |
CONST_C = :c_from_bottom_level |
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 Credential | |
include ActiveModel::Validations | |
attr_accessor :screen_name, :oauth_token, :oauth_secret, :token, :description | |
validates_presence_of :screen_name, :oauth_token, :oauth_secret, :message => 'required' | |
validate :user_exists, :unless => :errors? | |
def initialize(attributes = {}) | |
attributes.each {|k, v| set_recognized_attribute(k, v) } |
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
### | |
# This is a JSON building library. It allows you to build data structures | |
# to dump as JSON. Here is a sample of how to use it: | |
# | |
# def person_hash(person) | |
# { | |
# 'name' => person.name, | |
# 'age' => person.age, | |
# 'friends' => person.friends.map { |x| person_hash x } | |
# } |
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
# autoload concerns | |
module YourApp | |
class Application < Rails::Application | |
config.autoload_paths += %W( | |
#{config.root}/app/controllers/concerns | |
#{config.root}/app/models/concerns | |
) | |
end | |
end |
OlderNewer