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 'mechanize' | |
martine_ids = [] | |
agent = Mechanize.new | |
(1..20).each do |page_number| | |
page = agent.get("http://www.nintendo-town.fr/martine/index.php?p=#{page_number}&f=3&s=") | |
page.links.each do |link| |
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
alias git-compare='(git diff master...HEAD --stat --color && git diff master...HEAD --color) | less -R' |
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
#!/usr/bin/env ruby | |
# | |
# Pomodoro script. | |
# | |
# Displays a notification after 25 minutes. | |
# | |
# Don't forget to 'sudo apt-get install libnotify-bin' | |
# | |
system "notify-send -i face-cool 'Go go go!'" |
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
#!/user/env ruby | |
# | |
# Batch gitmine review a bunch of tickets. | |
# | |
# Usage: ruby batch_review.rb 7585 7603 7623 7640 7663 7665 | |
# | |
ARGV.each do |issue_id| | |
system("gitmine checkout #{issue_id} && git pull && git diff master...HEAD") | |
puts "Merge into 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
# RSpec matcher to spec delegations. | |
# | |
# Usage: | |
# | |
# describe Post do | |
# it { should delegate(:title).to(:name) } # post.title => post.name | |
# it { should delegate(:month).to(:created_at) } # post.month => post.created_at | |
# it { should delegate(:author_name).to(:author, :name) } # post.author_name => post.author.name | |
# 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
require 'rubygems' | |
require 'httparty' | |
class Github | |
include HTTParty | |
base_uri "https://api.github.com/repos/pcreux/test-pimp-my-changelog" | |
basic_auth "pcreux", ENV['GITHUB_PASSWORD'] | |
format :json | |
debug_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
class BankAccount < Model | |
end | |
# Decorate a model | |
class BankAccountDecorator | |
def human_name | |
end | |
end | |
# Present several models. Have built-in logic. |
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 a describe block and set its subject to 'instance_eval(@subject_name)' | |
# Example: | |
# | |
# Instead of: | |
# | |
# describe :transaction do | |
# subject { transaction } | |
# its(:state) { should == 'completed' } | |
# 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 ForeignKeyHelpers | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
# Add a foreign key constraint binding :table :column to the 'id' column of the target_table | |
# | |
# By default, a column called 'user_id' will be binded to the column 'id' of the | |
# table 'users' via a foreign key called 'fk_:table_:column_:target_table'. |
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 'spec_helper' | |
describe User do | |
# Use rspec-set to create a test user once | |
set(:user) { Factory(:user) } | |
describe "validations" do | |
it { should validate_presence_of :email } | |
it { should validate_confirmation_of :password } | |
end |