This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_fastcgi.c> | |
AddHandler fastcgi-script .fcgi | |
</IfModule> | |
<IfModule mod_fcgid.c> | |
AddHandler fcgid-script .fcgi | |
</IfModule> | |
Options +FollowSymLinks +ExecCGI | |
RewriteEngine On |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Syslogger | |
def initialize | |
read, @write = IO.pipe | |
fork do | |
@write.close | |
$stdin.reopen read | |
exec *%w(logger -trails) | |
end | |
read.close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
NewerOlder