Skip to content

Instantly share code, notes, and snippets.

<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
</IfModule>
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
</IfModule>
Options +FollowSymLinks +ExecCGI
RewriteEngine On
@asalant
asalant / setup.sh
Created June 7, 2012 20:41
Good Eggs dev workstation setup with chef soloist
# bash <(curl -s https://raw.github.com/gist/2891426)
read -p "Install Xcode (from the App store) and gcc for Lion (http://github.com/kennethreitz/osx-gcc-installer) and press enter to continue."
# setup your ssh keys for github
if ! [ -e "$HOME/.ssh/id_rsa.pub" ]
then
echo "Generating ssh key..."
read -p "Please enter the email you want to associate with your ssh key: " email
ssh-keygen -t rsa -C "$email"
@gaizka
gaizka / null_param_patch_for_rails_2_series.rb
Created June 5, 2012 16:57
Patch for Rails null param vulnerability (CVE-2012-2660) ported to Rails 2.3.x versions
# Adapted patch for CVE-2012-2660 rails vulnerability to Rails 2 versions
# https://groups.google.com/group/rubyonrails-security/browse_thread/thread/f1203e3376acec0f
#
# 1- Drop it at your_app/config/initializers/
# 2- Remember to pass your tests/specs
# 3- Profit!
module ActionController
class Request < Rack::Request
alias_method :normalize_parameters_with_null_vulnerability, :normalize_parameters
worker = Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY'])
begin
worker.say "Starting job worker"
trap('TERM') { worker.say 'Exiting...'; $exit = true }
trap('INT') { worker.say 'Exiting...'; $exit = true }
loop do
result = nil
@rcrowley
rcrowley / unicorn.conf.rb
Created August 17, 2010 20:03
Unicorn logging to syslog
class Syslogger
def initialize
read, @write = IO.pipe
fork do
@write.close
$stdin.reopen read
exec *%w(logger -trails)
end
read.close
# Goal: Allow addition of instances to a collection in a factory-built object
# when those instances require references to the parent.
# Typically occurs in Rails when one model has_many instances of another
# See more at:
# http://stackoverflow.com/questions/2937326/populating-an-association-with-children-in-factory-girl
class Factory
def has_many(collection)
# after_build is where you add instances to the factory-built collection.
@mislav
mislav / update_counters.rb
Created December 2, 2009 19:32
One solution to update out-of-sync association counters
def update_counter(record, *names)
updates = names.each_with_object({}) do |name, memo|
counter = "#{name}_count"
diff = record.send(name).count - record.send(counter)
memo[counter] = diff unless diff.zero?
end
record.class.update_counters(record.id, updates) if updates.any?
end
Community.paginated_each(:per_page => 100) do |record|