This file contains 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
task :logrotate do | |
require 'erb' | |
upload_path = "#{shared_path}/system/logrotate" | |
template = File.read("deploy/logrotate.erb") | |
file = ERB.new(template).result(binding) | |
put file, upload_path, :mode => 0644 | |
run "if [ -e /etc/logrotate.d ]; then sudo cp #{shared_path}/system/logrotate /etc/logrotate.d/#{name}; fi" | |
end | |
after 'deploy:symlink', 'deploy:logrotate' |
This file contains 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
EM.run do | |
Fiber.new do | |
# Do everything with Bunny in here | |
# it will use Fibers + EM | |
b = Bunny.new(...) | |
b... | |
end.resume | |
end | |
# Out here, it will use standard Socket-based, synchronous Bunny |
This file contains 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
~> rvm 1.9.1 | |
~> gem -v | |
1.3.5 | |
~> gem update --system | |
Updating RubyGems | |
Updating rubygems-update | |
Successfully installed rubygems-update-1.3.6 | |
Updating RubyGems to 1.3.6 | |
Installing RubyGems 1.3.6 | |
RubyGems 1.3.6 installed |
This file contains 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
There's got to be a faster way. This is with a production db dump from a few days ago. | |
% time rake gemcutter:migrate:downloads | |
> gemcutter (0.5.0) 131783 | |
>> 0.5.0 19314 | |
>> 15 | |
>> 0.5.0.pre.2 64 | |
>> 15 | |
>> 0.5.0.pre 45 | |
>> 14 |
This file contains 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
# Don't query each rubygem version separately | |
rows = AR::Base.connection.select_rows "select count(*), version_id, date(created_at) from downloads group by version_id, date(created_at)" | |
rows.each do |(count, version_id, date)| | |
# do stuff | |
end |
This file contains 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
# \u00A0 is a Unicode non-breaking space and \s should match it if everything is Unicode-# enabled. | |
> irb | |
>> RUBY_VERSION | |
=> "1.9.1" | |
>> "\u00A0" | |
=> " " | |
>> s = _ | |
=> " " | |
>> s.bytes.to_a |
This file contains 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
# After rvm upgrade --head... | |
~> rvm install rbx | |
Installing pre-requisites | |
Extracting rubinius-1.0.0-20100514.tar.gz ... | |
Configuring rbx | |
Compiling rbx | |
Installing gems for rbx-1.0.0-p20100514. | |
Installing rdoc to /Users/mike/.rvm/gems/rbx-1.0.0-p20100514@global | |
Installing rdoc to /Users/mike/.rvm/gems/rbx-1.0.0-p20100514 | |
Installing rake to /Users/mike/.rvm/gems/rbx-1.0.0-p20100514@global |
This file contains 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 'sanitize' | |
STRIPPERS = %w(br p).freeze | |
def cleaner | |
lambda do |env| | |
return nil if !STRIPPERS.include?(env[:node_name]) | |
n = env[:node] | |
txt = Nokogiri::XML::Text.new(' ', n.document) | |
n.children.each do |c| |
This file contains 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
# encoding: utf-8 | |
# AR adapter for using a fibered mysql2 connection with EM | |
# This adapter should be used within Thin or Unicorn with the rack-fiber_pool middleware. | |
# Just update your database.yml's adapter to be 'em_mysql2' | |
module ActiveRecord | |
class Base | |
def self.em_mysql2_connection(config) | |
client = ::Mysql2::Fibered::Client.new(config.symbolize_keys) |
This file contains 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
task :test do | |
puts `knife cookbook test -a -u foo -c test_config.rb` | |
end |