Skip to content

Instantly share code, notes, and snippets.

View johan--'s full-sized avatar

johan pretorius johan--

View GitHub Profile
@nazarhussain
nazarhussain / Readme
Created June 22, 2011 13:29
Enable conditional default_url for Paperclip, to set default url with some method in the model
In some cases you need to set the default_url of paper clip base on some condition. e.g. You want to set default image on basis of gender of user. For this purpose this gist can make it possible to use a method as default_url. Just copy paper_clip_default_url_fix.rb to initializers folder, and use default_url as mentioned in model.rb
@jdhollis
jdhollis / resque_async_handling.rb
Created June 9, 2010 21:43
handle_asynchronously for Resque
module Resque
module AsyncHandling
# To disable (in config.after_initialize):
# Resque::AsyncHandling.enabled = false
mattr_accessor :enabled
self.enabled = true
def handle_asynchronously(original_method, params = { })
if enabled
now_method = "#{ original_method }_now"
@rklemme
rklemme / tee.rb
Created April 20, 2009 19:25
Command line tool 'tee'.
#!/usr/bin/env ruby19
require 'optparse'
# Report erros that are caused by invoking a method when
# an instance is not in the proper state to do so.
class StateError < Exception
end
# Instances of class Tee can send output to several destinations