View doccsv.rb
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
# encoding: utf-8 | |
require 'csv' | |
def is_suffix? name | |
case name | |
when "Jr" | |
true | |
when "JR" | |
true |
View gist:1784841
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
<table> | |
<tr> | |
<th>Player Name</th> | |
<th>action</th> | |
</tr> | |
<% @players.each do |player| %> | |
<tr> | |
<td><%= link_to player.name, player %></td> | |
<td><%= button_to "Remove from team", :action => "update" %></td> | |
</tr> |
View game.rb
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 | |
has_many :gamelocations | |
has_many :locations, :through => :gamelocations | |
has_many :gameingredients | |
has_many :ingredients, :through => :gameingredients | |
belongs_to :source | |
def self.find_by_criteria(params) | |
View spec_helper.rb
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
def login_user(email = 'kori', password = 'kori') | |
user = User.create!(:email => email, :password => password) | |
post session_path(:email => user.email, :password => user.password) | |
response.should redirect_to(root_path) | |
end | |
def make_valid_post | |
post posts_path(:title => "whee", :site_link => "whee") |
View change.rb
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 Changer | |
attr_accessor :change | |
def initialize | |
@change = [] | |
end | |
def make_change(num) |
View hard_coded.rb
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
<div class="span12"> | |
<div class="row"> | |
<div class="span3">Not Yet Started | |
<% story.tasks.each do |task| %> | |
<%= render task if task.not_yet_started? %> | |
<% end %> | |
</div> | |
<div class="span3">In Progress | |
<% story.tasks.each do |task| %> | |
<%= render task if task.in_progress? %> |
View return_procs.rb
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
def compose proc1, proc2 | |
Proc.new do |x| | |
proc2.call(proc1.call(x)) | |
end | |
end | |
squareIt = Proc.new do |x| | |
x**2 | |
end |
View gist:2304137
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
# create & checkout branch in one step | |
$ git checkout -b branch_name | |
# push new branch to remote repo | |
$ git push remote_repo_name branch_name | |
# example of above: | |
$ git push origin branch_name |
View stack_attack.rb
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 Stack | |
attr_accessor :stack | |
def initialize(input) | |
self.stack = input | |
end | |
def pop(*args) | |
return stack.pop if args.empty? | |
stack.pop.reverse # This shouldn't work. |
View tallant-amazon.rb
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
shopping_cart = [ | |
{:name => "iPad 2", :price => 499, :quantity => 5}, | |
{:name => "iMac 27", :price => 1699, :quantity => 1}, | |
{:name => "MacBook Air 13", :price => 1299, :quantity => 1} | |
] | |
sales_tax = { | |
"IL" => 0.115, | |
"IN" => 0.09, | |
"MI" => 0.06, |
OlderNewer