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
Here's a description that is roughly the problem I'm having: | |
The ember.js site I'm working on has a number of different screens | |
(deliberately using a word that has no ember connotations). | |
Let's say, for the sake of argument, 3 of them. | |
Each of these screens has their own normal route, controller, model, | |
template structure. This is all standard. | |
Now I want a dashboard. For the sake of argument, let's say I want |
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
# Combined left and right prompt configuration. | |
local smiley="%(?,%{$fg[green]%}☺%{$reset_color%},%{$fg[red]%}☹%{$reset_color%})" | |
PROMPT=' | |
%~ | |
${smiley} %{$reset_color%}' | |
RPROMPT='%{$fg[gray]%} $(~/.rvm/bin/rvm-prompt)$(~/bin/git-cwd-info.rb)%{$reset_color%}' | |
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[blue]%} (%{$fg[red]%}" |
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 Restaurant | |
attr_accessor :ratings, :cuisine, :price | |
def initialize(cuisine = nil, price = 0) | |
@ratings = [] | |
@cuisine = cuisine | |
@price = price | |
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
module AcceptsDelimtedIdStringFor | |
# accepts_delimited_id_string_for :careers | |
# | |
# becomes | |
# | |
# def career_id_strings=(delimited_string) | |
# self.careers = Career.where(:id => delimited_string.split(",")).all | |
# 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
# from the erb2haml gem by David Leung | |
# copied to a gist for easier integration into our Rails 2 training | |
require 'find' | |
RED_FG ="\033[31m" | |
GREEN_FG = "\033[32m" | |
END_TEXT_STYLE = "\033[0m" | |
# Helper method to inject ASCII escape sequences for colorized output |
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
# based on an idea by Gavin Mulligan | |
# http://gavin-mulligan.tumblr.com/post/3825225016/simple-rails-3-enumerations | |
# this version differs because | |
# * it returns StringInquirers rather than symbols, | |
# because I'll take any excuse to use StringInquirers | |
# * It uses meta program methods directly rather than class_eval | |
# * It auto-loads itself into ActiveRecord::Base | |
# * It supports a default option that uses default_value_for to set a default | |
# |
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
set :stages, %w(staging production) | |
set :default_stage, 'staging' | |
require 'capistrano/ext/multistage' rescue 'YOU NEED TO INSTALL THE capistrano-ext GEM' | |
require "bundler/capistrano" | |
set :application, "new_futuro" | |
set :repository, "git@github.com:obtiva/New-Futuro.git" | |
default_run_options[:pty] = true | |
set :scm, "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
cap staging deploy:cold rvm:ruby-1.9.2-p180@new_futuro | |
* executing `staging' | |
triggering start callbacks for `deploy:cold' | |
* executing `multistage:ensure' | |
* executing `deploy:cold' | |
* executing `deploy:update' | |
** transaction: start | |
* executing `deploy:update_code' | |
updating the cached checkout on all servers | |
executing locally: "git ls-remote git@github.com:obtiva/New-Futuro.git master" |
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
require 'rubygems' | |
require 'rspec' | |
require 'sequence' | |
describe Sequence do | |
describe "validation" do | |
it "should be able to sum its items" do | |
sequence = Sequence.new(1, 2, 3, 4) |
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 Sequence | |
class << self | |
def sequences | |
Enumerator.new do |y| | |
sequence = Sequence.new | |
while sequence | |
sequence = sequence.next | |
break unless sequence |