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 Player | |
def play_turn(warrior) | |
if warrior.feel.enemy? | |
warrior.attack! | |
else | |
if warrior.health < 20 && !taking_damage?(warrior) | |
warrior.rest! | |
else | |
warrior.walk! | |
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
BEFORE DECENT EXPOSURE | |
def create | |
@person = Person.new(params[:person]) | |
if @person.save | |
... | |
AFTER DECENT EXPOSURE |
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 CreateUsers < ActiveRecord::Migration | |
def self.up | |
create_table "users" do |t| | |
t.column :login, :string, :limit => 40 | |
t.column :name, :string, :limit => 100, :default => '', :null => true | |
t.column :email, :string, :limit => 100 | |
end | |
def self.down | |
drop_table "users" |
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 Builder | |
def initialize | |
@tag_stack = [] | |
end | |
def method_missing(name, *args, &blk) | |
print " "*@tag_stack.size | |
print "<#{name}" + attributes(args) + ">" | |
@tag_stack.push name | |
if block_given? |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
Feature: Some terse yet descriptive text of what is desired | |
Textual description of the business value of this feature | |
Business rules that govern the scope of the feature | |
Any additional information that will make the feature easier to understand | |
Scenario: Some determinable business situation | |
Given some precondition | |
And some other precondition | |
When some action by the actor | |
And some other action |
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
Given /^I am logged in/ do | |
Given /^I login to a ([Ss]ecure|[Cc]ontrol) account/ do |accountType| | |
Given /^I login to (?:a|an) ([Uu]n)?[Rr]estricted secondary account/ do |negate| | |
Given /^I login to a suspended account$/ do | |
Given /^I press the Sign In button$/ do |
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
FileUtils.cd('/System/Library/Speech/Voices/') do | |
@voices = Dir.glob("*.SpeechVoice") | |
end | |
@voices.map{|v| v.scan(/[A-Z][a-z]+/) } | |
@voices.reject{|v| v.include? "Compact"} |