Skip to content

Instantly share code, notes, and snippets.

View mscottford's full-sized avatar
🔎
hunting for code to clean up

M. Scott Ford mscottford

🔎
hunting for code to clean up
View GitHub Profile
# This file is used by Rack-based servers to start the application.
map '/' do
require ::File.expand_path('../config/environment', __FILE__)
run LocomotiveInstance::Application
end
# This class reverses environment modifications that were performed by Rack::URLMap
class RestoreScriptAndPathInfo
def initialize(app)
@mscottford
mscottford / heroku.rake
Created March 13, 2012 12:46
Rake task for restarting Heroku workers
# Add `gem 'heroku-api', :git => 'https://github.com/heroku/heroku.rb.git'` to your Gemfile
# Set the APP_NAME environment variable to the name of the Heroku app you wish to control.
# Set the HEROKU_API_KEY environment variable to the API key found on the Heroku 'My Account' page.
# You can now create a scheduler instance that runs `bundle exec rake heroku:workers:restart` to automate
# restarting workers at a regular interval.
namespace :heroku do
namespace :workers do
task :restart do
@mscottford
mscottford / heroku.rake
Created April 4, 2012 12:18
Rake task to restart one heroku web instance every 10 minutes
# Add `gem 'heroku-api', :git => 'https://github.com/heroku/heroku.rb.git'` to your Gemfile
# Set the APP_NAME environment variable to the name of the Heroku app you wish to control.
# Set the HEROKU_API_KEY environment variable to the API key found on the Heroku 'My Account' page.
# You can now create a scheduler instance that runs `bundle exec rake heroku:web:restart` to automate
# restarting workers. The task will select a different web instance every 10 minutes, based on the number of instances that are running.
namespace :heroku
namespace :web do
task :restart do
Call 4...N: GetOrders
ShipWorks will continue making GetOrders calls, repeatedly, until no orders are returned in the response. If orders are continually returned to ShipWorks, the download will proceed infinitely.
The maxcount parameter is simply a requested batch size, or number of orders desired to be in this call’s response. Please beware this is simply a recommended response size – when the download strategy is ByModifiedTime care must be taken to ensure that orders with matching Modified Time do not span batches. This would result in orders being skipped since ShipWorks would re-request orders with a new start value on the next GetOrders call which would not include those skipped orders. If this scenario arises, simply return as many orders as necessary without regard to the maxcount value.
Once again, downloading will be considered complete when no orders are returned.
2012-05-02T21:33:01+00:00 heroku[web.1]: Starting process with command `rails server thin -p 25855 -e production`
2012-05-02T21:33:25+00:00 app[web.1]: DEPRECATION WARNING: class_inheritable_attribute is deprecated, please use class_attribute method instead. Notice their behavior are slightly different, so refer to class_attribute documentation first. (called from <class:Attribute> at /app/vendor/bundle/ruby/1.9.1/bundler/gems/active_shipping-6be70c68574a/lib/vendor/quantified/lib/quantified/attribute.rb:107)
2012-05-02T21:33:25+00:00 app[web.1]: DEPRECATION WARNING: class_inheritable_attribute is deprecated, please use class_attribute method instead. Notice their behavior are slightly different, so refer to class_attribute documentation first. (called from <class:Attribute> at /app/vendor/bundle/ruby/1.9.1/bundler/gems/active_shipping-6be70c68574a/lib/vendor/quantified/lib/quantified/attribute.rb:107)
2012-05-02T21:33:33+00:00 app[web.1]: => Booting Thin
2012-05-02T21:33:33+00:00 app[web.1]: => Rails 3.1.1 a
@mscottford
mscottford / app_boot_benchmark.rb
Created May 10, 2012 15:09
A way to measure how long it takes Rails to boot
require 'date'
require 'open3'
require 'timeout'
require 'socket'
class AppBootBenchmark
RAILS_PORT = 9191
def initialize(options = {})
@stream_output = options[:stream_output]
@mscottford
mscottford / .bash_profile
Created May 17, 2012 01:56
My .bash_profile
export PATH=$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
# Use sublime text 2 for opening gems
export GEM_OPEN_EDITOR=subl
export BUNDLER_EDITOR=subl
# Puts npm libraries in the node path
export NODE_PATH=/usr/local/lib/node:/usr/local/lib/node_modules
# Ruby performance settings from https://gist.github.com/1688857
@mscottford
mscottford / gist:2775927
Created May 23, 2012 15:33
Install migrations from all engines
ruby -e "%x(rake -T install:migrations).gsub(%r(#.*),'').each_line { |c| puts %x{#{c}} }"
@mscottford
mscottford / gist:2776419
Created May 23, 2012 17:09
Generates a random string suitable for a promo code
ruby -e "puts Array.new(8) {(('A'..'Z').to_a + ('0'..'9').to_a)[Random.rand(0..35)]}.join()"
@mscottford
mscottford / output.txt
Created May 24, 2012 14:34
Spree::Order#variant should trigger update!
Subtotal: 0.0
Total: 0.0
Spree Bag: 22.99
Subtotal: 0.0
Total: 0.0