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
# If your workers are inactive for a long period of time, they'll lose | |
# their MySQL connection. | |
# | |
# This hack ensures we re-connect whenever a connection is | |
# lost. Because, really. why not? | |
# | |
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar) | |
# | |
# From: | |
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/ |
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 'erb' | |
class MissingSpecGenerator | |
def spec_file(spec_path, file_name, spec_template, namespace) | |
spec_name = file_name.gsub('.rb', '') + '_spec.rb' | |
if File.exist?("#{spec_path}/#{spec_name}") | |
puts "#{spec_path}/#{spec_name} exists" | |
else | |
puts "#{spec_path}/#{spec_name} missing" |
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 'open-uri' | |
require 'digest/md5' | |
# Get your external IP address from IP Chicken to send to the Quova service request URL below | |
ip_address = (open("http://ipchicken.com") {|f|f.read.scan(/([0-9]{1,3}\.){3}[0-9]{1,3}/);$~}) | |
# Your API credentials from http://developer.quova.com/apps/mykeys | |
API_KEY = 'yougottagetyourownforthispartrighthere' | |
SHARED_SECRET = 'yespleasegetyourown' |
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
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
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
- http://www.coffeepowered.net/2009/06/13/fine-tuning-your-garbage-collector/ | |
- http://snaprails.tumblr.com/post/241746095/rubys-gc-configuration | |
article’s settings: ("spec spec" took 17-23!sec) | |
export RUBY_HEAP_MIN_SLOTS=1250000 | |
export RUBY_HEAP_SLOTS_INCREMENT=100000 | |
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 | |
export RUBY_GC_MALLOC_LIMIT=30000000 | |
export RUBY_HEAP_FREE_MIN=12500 |
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
# Support running Whenever cron jobs with Lockrun | |
# Lockrun: http://www.unixwiz.net/tools/lockrun.html | |
# lockrun typically installed at /usr/bin/lockrun | |
# On Mac, install with: brew install lockrun | |
# Lockrun prefix for cronjobs: /usr/bin/lockrun --lockfile=/path/to/tmp/JOBNAME.lockrun -- sh -c "COMMAND" | |
def wrap_with_lockrun command | |
"/usr/bin/env lockrun --lockfile=:path/tmp/:lockfile.lockrun -- sh -c \"#{ command }\"" | |
end | |
#redefine the three default job types to use Lockrun (i.e. just add 'lockrun_' in front of the existing job names) |
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
#!/usr/bin/env ruby | |
# Installs a gem in a specific RVM ruby/gemset, and helps you create | |
# an alias to a CLI/bin script to always use that gemset. | |
# Wonderfully useful for utility scripts (engineyard's ey or github-gem's gh) | |
# | |
# USAGE: | |
# freeze_gem_cli engineyard ey | |
# freeze_gem_cli github gh ruby-1.8.7p334 | |
# |
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
namespace :assets do | |
task :check => :environment do | |
paths = ["app/assets", "lib/assets", "vendor/assets"] | |
paths.each do |path| | |
dir_path = Rails.root + path | |
if File.exists?(dir_path) | |
dir_files = File.join(dir_path, "**") |
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
# Add New Relic instrumentation | |
# ** define this before the lib/tasks are included | |
def task_with_new_relic_and_hoptoad(options) | |
caller_method = options.keys.first | |
task(options) do | |
require 'newrelic_rpm' | |
include NewRelic::Agent::Instrumentation::ControllerInstrumentation | |
NewRelic::Agent.manual_start | |
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
#~/.janus.rake file | |
vim_plugin_task "autoclose", "git://github.com/Townk/vim-autoclose.git" | |
#~/vimrc.local file | |
let g:AutoClosePairs = {'(': ')', '{': '}', '[': ']', '"': '"', "'": "'", '#{': '}', '|':'|' } | |
let g:AutoCloseProtectedRegions = ["Character"] | |
OlderNewer