Skip to content

Instantly share code, notes, and snippets.

View iRonin's full-sized avatar

Cyprian Kowalczyk iRonin

View GitHub Profile
@iRonin
iRonin / after.rb
Created September 12, 2012 08:16 — forked from mperham/after.rb
Thread-friendly shared connection
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || ConnectionPool::Wrapper.new(:size => 1) { retrieve_connection }
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
@iRonin
iRonin / deployments.rake
Created September 6, 2012 07:05 — forked from neilmiddleton/deployments.rake
Integrates CodebaseHQ deployment notifications into Heroku-san
desc 'After_deploy callback'
task :before_deploy => :environment do |t, args|
username = `git config codebase.username`.chomp.strip
api_key = `git config codebase.apikey`.chomp.strip
if username == '' || api_key == ''
puts " * Codebase is not configured on your computer. Bundle the codebase gem and run 'codebase setup' to auto configure it."
puts " * Deployments will not be tracked."
next
class ApplicationController < ActionController::Base
...
# FORCE to implement content_for in controller
def view_context
super.tap do |view|
(@_content_for || {}).each do |name,content|
view.content_for name, content
end
end
end
@iRonin
iRonin / gist:3189378
Created July 27, 2012 17:58 — forked from hipertracker/gist:214210
NGinx -> TorqueBox
/etc/hosts:
127.0.0.1 myhost jboss_server
NGINX:
server {
listen myhost:80;
server_name myhost;
location / {
proxy_set_header X-Real-IP $remote_addr;