This file contains hidden or 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/ruby | |
require 'Date' | |
print "How much to save? " | |
save = gets.chomp.gsub('$', '').to_f | |
puts '' | |
print "When do you need it? (2009 12 25) " | |
(year, month, day) = gets.chomp.split(/\s+/).map{|m| m.to_i} |
This file contains hidden or 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
23:19:18 /Users/jasonn/my_app $ rake test:plugins | |
(in /Users/jasonn/my_app) | |
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -Ilib:test "/Users/jasonn/.gem/ruby/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb" | |
23:19:34 /Users/jasonn/my_app $ script/plugin install git://github.com/jm/rails_upgrade.git | |
Initialized empty Git repository in /Users/jasonn/my_app/vendor/plugins/rails_upgrade/.git/ | |
remote: Counting objects: 20, done. | |
remote: Compressing objects: 100% (16/16), done. | |
remote: Total 20 (delta 0), reused 0 (delta 0) | |
Unpacking objects: 100% (20/20), done. | |
From git://github.com/jm/rails_upgrade |
This file contains hidden or 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
# Ops middleware, provides /ops/version that gives you information about your deployed application | |
# Use: | |
# Dump this code in lib/middleware/ops.rb | |
# Add the following line to your environment.rb: | |
# config.middleware.use Rack::Ops | |
# | |
module Rack |
This file contains hidden or 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
# Usage: | |
# Returns the index of the first element of the array | |
# that matches the regular expression provided | |
# | |
# lines.index_regex(/\d{4}\-\d{2}\-\d{2}/) | |
# | |
class Array | |
def index_regex(pattern) | |
self.each_with_index do |value,index| | |
return index if pattern.match(value) |
This file contains hidden or 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
# Add command in TextMate | |
# Mapped to F1 | |
# Update Path to File | |
Save: Nothing | |
Command(s): | |
A=${TM_PROJECT_DIRECTORY:-""} | |
B=${A##*/} |
This file contains hidden or 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
# rackup.ru | |
require 'faker' | |
app = proc do |env| | |
body = "#{Faker::Company.catch_phrase} in order to #{Faker::Company.bs}" | |
[ 200, {'Content-Type' => 'text/html'}, body ] | |
end | |
run app | |
# rackup rackup.ru |
This file contains hidden or 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 3.0.0 | |
# Rspec 2.0.0.beta.22 | |
# Is this what rspec failures look like now? Or am I missing an option | |
# somewhere? | |
01:12:58 /Users/jasonn/source/demo $ cat spec/helpers/say_helper_spec.rb | |
require 'spec_helper' | |
describe SayHelper do |
This file contains hidden or 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
# | |
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. | |
# The sum of these multiples is 23. | |
# | |
# Find the sum of all the multiples of 3 or 5 below 1000. | |
# puts (1..10).inject{|sum, n| sum + n if (n % 3 == 0 || n % 5 == 0)} | |
["9", "99", "999", "9999", "99999", "999999", "9999999", "99999999"].each do |num| | |
print "NUM: #{num}\n\t" |
This file contains hidden or 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
22:40:31 /Users/jasonn/source/ruby_koans $ irb | |
>> begin | |
?> nil.some_method_nil_doesnt_know_about | |
>> rescue Exception => ex | |
>> puts ex.class | |
>> puts ex.message | |
>> end | |
NoMethodError | |
undefined method `some_method_nil_doesnt_know_about' for nil:NilClass | |
=> nil |
This file contains hidden or 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
We work in release branches (rel_0052) for a given release. As we work on that | |
branch, we commit with the following format: | |
[PAIR INITIALS] [PIVOTAL STORY ID] Short summary of commit | |
We have a problem where the business wants a subset of the commits made on this | |
branch released to production (with all commits released at a later date). Let's | |
say they want all stories with the pivotal ID 5193923 in the next release, and | |
nothing else. Version v18.20.11 is currently in production. |
OlderNewer