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
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 | |
[33m[44m[1mWelcome to the Ruby Enterprise Edition installer[0m[37m[40m | |
This installer will help you install Ruby Enterprise Edition 1.8.7-2012.02. | |
Don't worry, none of your system files will be touched if you don't want them | |
to, so there is no risk that things will screw up. | |
You can expect this from the installation process: | |
[1m1.[0m[37m[40m Ruby Enterprise Edition will be compiled and optimized for speed for this | |
system. |
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 'rubygems' | |
require 'benchmark' | |
objects = ["string", %w(array), { :key => 'value' }, 9000] * 100 | |
GC.disable | |
Benchmark.bm do |x| | |
x.report('map => uniq') do | |
10000.times { objects.map { |object| object.class }.uniq } |
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 RedisConnector | |
def self.connection | |
return $redis if $redis | |
case Rails.env | |
when /production/ | |
# Don't use waterfall connection here because we don't want | |
# production inconsistencies | |
connect_with_failover |
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 'benchmark' | |
require 'pp' | |
require 'active_record' | |
require 'sequel' | |
require 'data_mapper' | |
@start = Date.parse("2012-12-01") | |
@end = Date.parse("2012-12-31") | |
ActiveRecord::Base.establish_connection(adapter: 'mysql2', database: 'escobar_development', cast: false, username: 'root', password: nil, pool: 5, timeout: 5000) |
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 'resque/pool/tasks' | |
# this task will get called before resque:pool:setup | |
# preload the rails environment in the pool master | |
task "resque:setup" => :environment do | |
# generic worker setup, e.g. Hoptoad for failed jobs | |
end | |
task "resque:pool:setup" do | |
# Close any sockets or files in pool master |
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 'resque/pool/tasks' | |
# this task will get called before resque:pool:setup | |
# preload the rails environment in the pool master | |
task "resque:setup" => :environment do | |
# generic worker setup, e.g. Hoptoad for failed jobs | |
end | |
task "resque:pool:setup" do | |
# close any sockets or files in pool master |
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
#!/bin/sh | |
set -e | |
# Setup current directory path | |
APP_ROOT=/path/to/your/app/current | |
# Unicorn needs to know to write the PID file here. Adjust this for your own setup. | |
PID=$APP_ROOT/tmp/pids/unicorn.pid |
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
# 4 workers is enough for our app | |
worker_processes 4 | |
# App location | |
@app = "/var/rails/myapp/current" | |
# Listen on fs socket for better performance | |
listen "#{@app}/tmp/sockets/unicorn.sock", :backlog => 64 | |
# Nuke workers after 30 seconds instead of 60 seconds (the default) |
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 "benchmark" | |
n = 1000000 | |
puts "Running include? vs regex 1 million times.\n" | |
Benchmark.bmbm do |results| | |
results.report("include? ") { n.times { "banana".include?('nana') } } | |
results.report("match w/ regex") { n.times { "banana".match(/nana/) } } | |
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
# Just because you can do something like this doesn't mean you should. | |
# Executing code via backticks using input from the user is a good way to wreck the host machine. | |
class GenerateSomeC | |
attr_accessor :program_name | |
def initialize(program_name) | |
@program_name = program_name | |
end | |