View Gemfile
# no ruby gems required
View extract-migration
# Extract all new migrations from the current branch over to a new branch (suffixed with "-migration")
set -ev
export branch=`git rev-parse --abbrev-ref HEAD`
git checkout master
git pull
git checkout -b $branch-migration
git checkout $branch -- db engines/*/db
View rtt
#!/usr/bin/env ruby
# Run unit test for all added or changed app, lib and test files.
# Ex:
# * `rtt` will run tests for all files changed since the last commit
# * `rtt master` will run tests for all files different from master
if ARGV[0]
files = `git diff --name-only $(git merge-base HEAD #{ARGV[0]})..$(git rev-parse --abbrev-ref HEAD)`.split("\n")
files = `git status -s`.split("\n").map { |f| f.split(' ').last }
View mktest
#!/usr/bin/env ruby
DESC = "
Generate test file
Example: mktest app/services/user/create.rb will generate test/services/user/create_test.rb

Robust Rails Apps

Philippe Creux - @pcreux

#vanruby - March 29th, 2017

View 99bottles.rb
class Bottles
def verse(current)
#{bottles(current).capitalize} of beer on the wall, #{bottles(current)} of beer.
#{take_one_down(current)}, #{bottles((current - 1) % 100)} of beer on the wall.
def verses(start, finish)
(finish..start) { |number| verse(number) }.join("\n")
View rotate-aws-access-keys.rb
#!/usr/bin/env ruby
require 'json'
# 1. Generate new access key
new_access_key_json = `aws iam create-access-key`
new_access_key_attributes = JSON.parse(new_access_key_json).fetch("AccessKey")
new_access_key_id = new_access_key_attributes.fetch("AccessKeyId")
View publish_to_recurly_spec.rb
require "rails_helper"
require "recurly_mock"
describe Plan::PublishToRecurly do
let(:free_plan) { Plan.find_by_code("free_2016") }
let(:starter_monthly) { Plan.find_by_code("starter_monthly_2016") }
let(:plans) { [free_plan, starter_monthly] }
let(:recurly_plan_double) do
double(create: double("Recurly::Plan", errors: [], add_ons: double("Recurly::AddOns", "create!" => true)))
View index.sql
CREATE INDEX "index_patrons_on_amount_raised_in_cents" ON "patrons" ("amount_raised_in_cents" DESC)