Skip to content

Instantly share code, notes, and snippets.

View louisgillies's full-sized avatar

Louis Gillies louisgillies

View GitHub Profile
@louisgillies
louisgillies / my_auth_test.rb
Created April 6, 2011 08:54
helper method for testing omniauth strategies with Test::Unit and Shoulda
require 'test_helper'
class OmniAuth::Strategies::MyAuthTest < Test::Unit::TestCase
it_should_behave_like_an_oauth_strategy
end
@louisgillies
louisgillies / paperclip_migration.rake
Created October 26, 2010 11:36
Quick and dirty one off migration task for paperclip plugin to move files from local filesystem to Amazon S3.
# First configure your models to use Amazon s3 as storage option and setup the associated S3 config.
# Then add the classes your want to migrate in the klasses array below.
# Then run rake paperclip_migration:migrate_to_s3
# Should work but this is untested and may need some tweaking - but it did the job for me.
namespace :paperclip_migration do
desc "migrate files from filesystem to s3"
task :migrate_to_s3 => :environment do
klasses = [:model_1, :model_2] # Replace with your real model names. If anyone wants to this could be picked up from args or from configuration.
klasses.each do |klass_key|
@louisgillies
louisgillies / patch.rb
Created March 28, 2010 10:16
Allows easy patching and editing of files with strings
# Allows easy patching and editing of files with strings
#
# Extracted from methods seen in adva cms setup.rb
# See http://github.com/svenfuchs/adva_cms
# Thought it would be useful to extend the String and File classes to include this functionality.
# I find it useful when running install hooks for plugins.
module Patch
module InstanceMethods