Skip to content

Instantly share code, notes, and snippets.

View jerome's full-sized avatar

Jérôme Lipowicz jerome

View GitHub Profile
@jerome
jerome / gist:564210
Created September 3, 2010 17:22 — forked from nicolasblanco/gist:513149
capistrano bundler
From 77883e5358e488d10daa34e8490a6c57b5e0a536 Mon Sep 17 00:00:00 2001
From: Nicolas Blanco <[email protected]>
Date: Sat, 7 Aug 2010 22:05:04 +0200
Subject: [PATCH 3/3] Adds basic Capistrano task for Bundler.
To use it, just require 'bundler/capistrano' in your Capistrano deploy file (deploy.rb).
Bundler will be activated after each new deployment.
---
lib/bundler/capistrano.rb | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
# Lets you define relations between ActiveRecord and Mongo objects
module MongoRelations
module InstanceMethods
# get an object representing the MongoMapper equivalent of this object
# for the purpose of access relations on the object
fattr(:mongo_obj) do
res = klass.mongo_class.new
my_id = id
res.class_eval do
@jerome
jerome / databases.yml
Created March 21, 2010 23:15 — forked from eladmeidar/databases.yml
actionmailer settings
# = Outgoing email settings
#
# Each environment has it's own configuration options. If you are only
# running in production, only the production block needs to be configured.
#
# == Common configurations
#
# === Sendmail command
#
# production:
@jerome
jerome / validates_uniqueness_of.rb
Created February 22, 2010 14:01 — forked from RISCfuture/validates_uniqueness_of.rb
Reimplementation of validates_uniqueness_of that works optimally with MySQL.
module ActiveRecord::Validations::ClassMethods
def validates_uniqueness_of(*attr_names)
configuration = { :case_sensitive => true }
configuration.update(attr_names.extract_options!)
validates_each(attr_names,configuration) do |record, attr_name, value|
# The check for an existing value should be run from a class that
# isn't abstract. This means working down from the current class
# (self), to the first non-abstract class. Since classes don't know
# their subclasses, we have to build the hierarchy between self and
@jerome
jerome / gist:285288
Created January 24, 2010 16:21 — forked from ultraspeed/gist:282826
apache gzip
# Requires mod_deflate
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
@jerome
jerome / Patch pg
Created December 17, 2009 15:25 — forked from jcf/Patch pg
# get rid of the pg if you have it already; you might want to do this for ruby-pg as well
gem uninstall pg
# change to some convenient working directory
cd ~/src
svn checkout http://ruby-pg.rubyforge.org/svn
cd svn/ruby-pg/trunk/ext
# download and install the patch
curl -O http://gist.github.com/raw/215956/54166b63f9cce030232b09397934315f004fb649/pg-patch.txt
@jerome
jerome / gist:229957
Created November 9, 2009 14:05 — forked from hassox/gist:131050
Warden::Strategies.add(:bcrypt) do
def valid?
params[:username] || params[:password]
end
def authenticate!
return fail! unless user = User.first(:username => params[:username])
if user.encrypted_password == params[:password]
success!(user)
@jerome
jerome / gist:229956
Created November 9, 2009 14:04 — forked from hassox/gist:131050
Warden::Strategies.add(:bcrypt) do
def valid?
params[:username] || params[:password]
end
def authenticate!
return fail! unless user = User.first(:username => params[:username])
if user.encrypted_password == params[:password]
success!(user)
# Install
#
# Move this file into config/preinitializer.rb
#
# Usage
#
# This line:
# config.github_gem "mislav-will_paginate"
# is equivalent to this line:
# config.gem "mislav-will_paginate", :lib => "will_paginate", :source => "http://gem.github.com"
class MigrateProductsToPaperclip < ActiveRecord::Migration
def self.up
# Rename the old "image" column to "old_file_name", since Product.image will now try to do Paperclip stuff
rename_column :products, :image, :old_file_name
# Rename asset directories to pluralize
File.rename("public/system/product","public/system/products")
File.rename("public/system/products/image","public/system/products/images")