Skip to content

Instantly share code, notes, and snippets.

View cbrunsdon's full-sized avatar

Clarke Brunsdon cbrunsdon

View GitHub Profile
Paperclip.interpolates :s3_path_prefix do |attachment, style|
attachment.instance.s3_path_prefix
end
=> {"org"=>
{"mpris"=>{"MediaPlayer2"=>{}},
"gnome"=>
{"Rhythmbox3"=>
{"menus"=>{"appmenu"=>{}},
"window"=>{"1"=>{}},
"PlayQueue"=>{},
"RhythmDB"=>{},
"PlaylistManager"=>{}}}}}
@cbrunsdon
cbrunsdon / gist:5810498
Created June 18, 2013 23:40
lols caller()
class Foo
def hello
puts "Original Method"
puts caller(1)
end
end
class HijackStuff
def hijack
Foo.class_eval do
config.to_prepare do
# Load application's model / class decorators
['lib', 'app'].each do |dir|
Dir.glob(File.join(File.dirname(__FILE__), "../#{dir}/**/*_decorator*.rb")) do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
end
end
@cbrunsdon
cbrunsdon / gist:5687067
Created May 31, 2013 18:47
My nested routes don't play nicely with my namespaces
class Foo::Bar < ActiveRecord::Base
end
class Foo::Bar::Lols < ActiveRecord::Base
end
Routes.draw do
namespace :foo do
resources :bars do
resources :lols
@cbrunsdon
cbrunsdon / generic_notifier.rb
Created December 6, 2010 03:58
ruby generic_notifier
#!/usr/bin/ruby
#based off jhawthorn's python generic_nofity.py
require 'net/http'
def send_notify(ticker, title, body)
if Weechat.config_get_plugin('account_name') == ""
return Weechat::WEECHAT_RC_OK
end