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
# test | |
if Rails::VERSION::MAJOR == 2 | |
# make integration tests use rack response, so we can test our middlewares | |
# and not only the pure controller response | |
ActionController::Base.class_eval do | |
# this is usually done just-in-time by #process but we need to do it earlier | |
include ActionController::Integration::ControllerCapture | |
# then we hide last_instantiation from #process |
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
module MailWithMail | |
# stolen + made static from Rails 3.0 action_mailer/old_api.rb | |
def self.set_content_type(m, user_content_type, class_default, params) | |
case | |
when user_content_type.present? | |
user_content_type | |
when m.has_attachments? | |
if m.attachments.detect { |a| a.inline? } | |
["multipart", "related", params] | |
else |
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
# For Rails3, Rails.logger sync = false. Unicorn's log detection needs to accomodate this | |
module Unicorn | |
module Util | |
# :stopdoc: | |
def self.is_log?(fp) | |
append_flags = File::WRONLY | File::APPEND | |
! fp.closed? && | |
fp.stat.file? && |
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 audit(klass, method) | |
klass.class_eval do | |
define_method :"#{method}_with_audit" do |*args| | |
result = nil | |
time = Benchmark.realtime do | |
result = send(:"#{method}_without_audit", *args) | |
end | |
$time ||= {} | |
$time[klass] ||= {} | |
$time[klass][method] ||= 0 |
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
require "dogapi" | |
require "celluloid/autostart" | |
require "singleton" | |
class LazyDog | |
include Celluloid | |
include Singleton | |
def emit_point(*args) | |
client.emit_point(*args) |
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
rails3 = ENV["BUNDLE_GEMFILE"].to_s.include?("rails3") | |
... | |
if rails3 | |
# make bundler use a different cache dir | |
class << Bundler | |
def app_cache | |
root.join("vendor/cache_rails3") | |
end |
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
if Rails::VERSION::MAJOR == 2 | |
ActionController::Base.class_eval do | |
def params_with_nil_fix | |
params = params_without_nil_fix | |
unless params.instance_variable_get(:@nil_fixed) | |
params.instance_variable_set(:@nil_fixed, true) | |
# normal form params cannot include nil/empty hash/empty array, just json/xml | |
deep_munge(params) unless ["application/x-www-form-urlencoded", "multipart/form-data", nil].include?(request.try(:content_type)) | |
end |
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
#!/usr/bin/env ruby | |
# Complete rake tasks script for bash | |
# Save it somewhere and then add | |
# complete -C path/to/script -o default rake | |
# to your ~/.bashrc | |
# Xavier Shay (http://rhnh.net), combining work from | |
# Francis Hwang ( http://fhwang.net/ ) - http://fhwang.net/rb/rake-complete.rb | |
# Nicholas Seckar <[email protected]> - http://www.webtypes.com/2006/03/31/rake-completion-script-that-handles-namespaces | |
# Saimon Moore <[email protected]> |
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
`rm accounts/*` | |
ips = File.readlines('ips.txt') | |
accounts = File.readlines('accounts.txt') | |
mapping = {} | |
accounts.each_with_index.map do |subdomain, i| | |
ip = ips[i % ips.size].strip | |
mapping[ip] ||= [] | |
mapping[ip] << subdomain.strip |
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
Dir["tmp/*.txt"].each do |ip_file| | |
puts "-" * 50 | |
puts ip_file | |
ip = File.basename(ip_file).sub('.txt','') | |
puts "ip #{ip}" | |
puts "result:" | |
puts `cat #{ip_file} | ruby script/patch_dns #{ip}` | |
raise unless $?.success? | |
end |