Skip to content

Instantly share code, notes, and snippets.

@pcreux
pcreux / postgresql.conf
Last active August 29, 2015 13:56
Speed up Rails test suite!
fsync = off
synchronous_commit = off
full_page_writes = off
@pcreux
pcreux / import-sepa-mandates-to-ca.rb
Last active August 29, 2015 13:56
Hack to import SEPA mandates from a CSV file to the Crédit Agricole bank. Fun times...
#encoding: utf-8
# This HACK imports SEPA Mandates from a CSV file to
# Crédit Agricole SEPA System via their HTML API. :)
#
# Good luck with this!
#
require 'mechanize'
require 'virtus'
@pcreux
pcreux / this-week-in-rails-sample
Last active August 29, 2015 14:13
Output for latest this week in rails
---
layout: post
title: "This week in Rails: 4.2.0 Final, autoload explained, deep_munge and more!"
categories: news
author: chancancode
published: true
date: 2015-01-09 14:04:54 -0800
---
Welcome to _This week in Rails_, your weekly inside scoop of interesting commits, pull requests and more from [Rails](https://github.com/rails/rails).
@pcreux
pcreux / dependencies.rb
Last active August 29, 2015 14:22
Generate graph of dependency for scss stylesheets
#!/usr/bin/env ruby
#
# Generate a graph of dependencies for your stylesheets.
#
# Requires graphviz
#
# Run `ruby dependencies.rb | fdp -Tpng > out.png; open out.png`
PATH = "app/assets/stylesheets/"
@pcreux
pcreux / chpwd_update_git_vars.sh
Created November 30, 2009 18:13 — forked from scelis/chpwd_update_git_vars.sh
Zsh prompt with git status
update_current_git_vars
#!/usr/bin/env ruby
require 'csv'
require 'date'
CSV::Reader.parse(File.open(ARGV[0])) do |row|
date = row[0].match(/^\d{4}-\d{2}-\d{2}/) ? Date.strptime(row[0], "%Y-%m-%d") : row[0]
hours = row[2]
memo = "#{row[3]} #{row[4]}"
puts "#{date} | #{hours} | #{memo}"
end
@pcreux
pcreux / migrate_rubygems_to_ruby_enterprise_edition.rb
Created February 12, 2010 22:14
Migrate rubygems to Ruby Enterprise Edition (REE) - Make REE install the gems used by your default ruby environment.
#!/usr/bin/ruby
# Migrate rubygems to Ruby Enterprise Edition (REE)
# Make REE install the gems used by your default ruby environment.
REE_PATH = ENV['REE_PATH'] || Dir.glob('/opt/ruby-enterprise-*').last
unless REE_PATH
puts "Can't find path to ruby enterprise edition. Please use the following command:"
puts "REE_PATH=/path/to/ruby-enterprise ruby migrate-rubygems-to-ree"
@pcreux
pcreux / runner.rb
Created May 20, 2010 00:11
script/runner for Rails 3
#!/usr/bin/env ruby
# script/runner for rails 3.0
APP_PATH = File.expand_path('../../config/environment', __FILE__)
require 'rubygems'
require 'rails/commands/runner'
require 'rspec'
def set(attribute, &block)
before(:all) do
instance_variable_set("@#{attribute}", yield)
end
let(attribute) { instance_variable_get("@#{attribute}") }
end
# Set @@variable_name in a before(:all) block and give access to it
# via let(:variable_name)
#
# Example:
# describe Transaction do
# set(:transaction) { Factory(:transaction) }
#
# it "should be in progress" do
# transaction.state.should == 'in_progress'
# end