Skip to content

Instantly share code, notes, and snippets.

View tommeier's full-sized avatar

Tom Meier tommeier

View GitHub Profile
@tommeier
tommeier / resque.rb
Created February 28, 2012 02:30
Resque initializer
# Why use RAILS_ROOT and RAILS_ENV? Because this way we can tell our Sinatra app about the config file:
# $ RAILS_ENV=production resque-web rails_root/config/initializers/resque.rb
require 'resque'
rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
rails_env = ENV['RAILS_ENV'] || 'development'
resque_config = YAML.load_file(rails_root + '/config/resque.yml')
Resque.redis = resque_config[rails_env]
@tommeier
tommeier / resque.rake
Created February 28, 2012 02:34
Resque fails on rake tasks due to env not loaded
require 'resque/tasks'
task "resque:setup" => :environment do
ENV['QUEUE'] = '*'
Resque.before_first_fork do
ActiveRecord::Base.send(:subclasses).each do |klass|
klass.columns if klass.table_exists?
end
end
@tommeier
tommeier / Gemfile
Created March 1, 2012 01:24
Bundle installing by platform
source "http://rubygems.org"
gem 'fastercsv', :platforms => :ruby_18
gemspec
@tommeier
tommeier / speed_up_rails.sh
Created March 7, 2012 23:03
Speed up Rails
rvm get head && rvm install 1.9.3-perf --patch falcon,debug
echo 'export RUBY_HEAP_MIN_SLOTS=1000000' >> ~/.bash_profile
echo 'export RUBY_HEAP_SLOTS_INCREMENT=1000000' >> ~/.bash_profile
echo 'export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1' >> ~/.bash_profile
echo 'export RUBY_GC_MALLOC_LIMIT=1000000000' >> ~/.bash_profile
echo 'export RUBY_HEAP_FREE_MIN=500000' >> ~/.bash_profile
rvm use 1.9.3-perf
gem install bundler
@tommeier
tommeier / rsync_backup.sh
Created March 20, 2012 00:05
RSync backup script for Mac OSX from External drive
#!/bin/sh
echo "Running..."
PROG=$0
RSYNC="/usr/bin/rsync"
SCRIPT_MOUNTED='false'
MOUNT_VOLUME="/Volumes/Qdownload"
SRC="$MOUNT_VOLUME/transmission/completed/"
DST="/Users/tom/Dumping Ground/Qnap Downloads"
@tommeier
tommeier / some_spec.rb
Created April 16, 2012 04:20
VCR with placeholders
use_vcr_cassette 'some/cassette', :tag => :bad_staging_api
@tommeier
tommeier / spec_helper.rb
Created April 16, 2012 10:43
after_http_request
c.after_http_request(lambda { VCR.current_cassette && VCR.current_cassette.tags.include?(:bad_staging_api) }) do |req, res|
puts "OVERWRITING WILDCARDS"
res.body.gsub!('<TOTAL_RATE>', "836.00")
puts res.body
end
@tommeier
tommeier / some_spec.rb
Created April 17, 2012 01:45 — forked from myronmarston/some_spec.rb
VCR with placeholders
use_vcr_cassette 'some/cassette', :tag => :bad_staging_api
(function($) {
window.Album = Backbone.Model.extend({
isFirstTrack: function(index) {
return index == 0;
},
isLastTrack: function(index) {
return index >= this.get('tracks').length - 1;
}
});
@tommeier
tommeier / error.log
Created April 23, 2012 08:23
Stack trace from error in staging
File to import not found or unreadable:skin/icons/*.png. Load paths: Sass::Rails::Importer(/data/releases/20120423050001/app/assets/stylesheets/search.css.sass) /data/shared/bundled_gems/ruby/1.9.1/gems/compass-0.12.1/frameworks/compass/stylesheets /data/shared/bundled_gems/ruby/1.9.1/gems/compass-0.12.1/frameworks/blueprint/stylesheets (in /data/releases/20120423050001/app/assets/stylesheets/search.css.sass)
app/assets/stylesheets/skin/common/constants.css.sass:4
app/assets/stylesheets/search.css.sass:3
[GEM_ROOT]/gems/sass-3.1.15/lib/sass/tree/import_node.rb:64:in `rescue in import'
[GEM_ROOT]/gems/sass-3.1.15/lib/sass/tree/import_node.rb:42:in `import'
[GEM_ROOT]/gems/sass-3.1.15/lib/sass/tree/import_node.rb:25:in `imported_file'
[GEM_ROOT]/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:149:in `rescue in visit_import'
[GEM_ROOT]/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:154:in `visit_import'
[GEM_ROOT]/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'