Skip to content

Instantly share code, notes, and snippets.

@mipearson
mipearson / .rspec_parallel
Created December 10, 2013 22:33
Parallel rspec w/ re-run of failing specs.
--colour
--format ParallelTests::RSpec::SummaryLogger
--format ParallelTests::RSpec::RuntimeLogger --out tmp/parallel_runtime_rspec.log
--format ParallelTests::RSpec::FailuresLogger --out tmp/rspec_failures.log
@mipearson
mipearson / application_controller.rb
Last active December 26, 2015 22:49
Tracking default route usage with Rollbar
class ApplicationController < ActionController::Base
# ...
before_filter :check_for_default_route
class DefaultRouteException < Exception
# Placeholder exception so that we can report request & person data back
# to rollbar
end
def with_retries(timeout = 5.seconds, retry_delay: 0.1.seconds, &blk)
start = Time.now
begin
blk.call
rescue
if Time.now > start + timeout
raise
else
sleep retry_delay
retry

So, minor history lesson:

One of the things Howard was brilliant at when he was Prime Minister was causing "the Left" to utterly apeshit so he could point at them and laugh. Generally the media would do this too because, let's face it, we would get utterly pissed off, yell at Howard and all that. But then the media wouldn't pay attention and Howard would just raise his standing with not only "the Right" but a section of the middle too because "he stood his ground and didn't take any shit from those hippies".

Now, let's look at this "Tony Abbott is the Minister for Women" thing and think back to Abbott saying he saw Howard as his mentor.

He wants us to go crazy and post ranty things about him. He wants us to get upset. He's almost relying on it because by going nuts we give him a level of legitimacy.

We need to be more creative if we're going to do anything like make sure he's a one-term PM, if that's even possible. We also need to convince people outside our general echo-chamber of friends. None of this i

@mipearson
mipearson / mini_profiler_instrumenter.rb
Created July 18, 2013 09:01
Wrap methods in rack-mini-profiler steps
# Usage:
# class MyClass
# extend MiniProfilerInstrumenter
#
# def my_slow_method
# ...
# end
# instrument_method :my_slow_method
module MiniProfilerInstrumenter
@mipearson
mipearson / assets_helper.rb
Created July 12, 2013 04:24
Helper & Rake task for SVG fallback usage & generation. Assumes Rails w/asset pipeline, your svgs are all in app/assets/images/vector, and imagemagick & optipng are installed.
module AssetsHelper
# SVG with PNG fallback for IE8.
# Run rake app:svg_fallback to generate fallbacks
def svg_image_tag source, *args
options = args.extract_options!
svg_class = options.fetch(:class, '')
svg_class += ' svg'
content = image_tag "vector/" + source, *args, options.merge(class: svg_class)
content << "\n<!--[if lt IE 9]>\n".html_safe
# It's called visit_external, but it should really be called visit_paypal.
# A cucumber tag to use when external sites & sandboxes, with their own
# JavaScript errors & slow responses, enter your tests.
Capybara.register_driver :poltergeist_js_tolerant do |app|
Capybara::Poltergeist::Driver.new(app, js_errors: false)
end
Around('@visit_external') do |scenario, block|
oldjs = Capybara.javascript_driver

The Exchange Group are hiring a systems administrator / developer to help us secure, scale, and strengthen our existing Ruby on Rails infrastructure.

The Exchange Group are best known for bikeexchange.com.au, the popular online bike & accessories marketplace which reached one million unique visitors per month in July last year. We've recently expanded: check out tinitrader.com.au, renoexchange.com.au and bikeexchange.co.nz. Right now The Exchange Group employs approximately 40 people, of which 6 are in the combined design/development team. Our office is located in South Melbourne near great food, coffee and public transport.

We're looking for somebody who has:

  • experience administering Linux servers on both 'bare metal' and in the cloud
  • experience with configuration management and automated provisioning (eg. Puppet, Chef, Ansible)
  • experience with SaaS and IaaS technologies (eg. NewRelic, Scout.app, pingdom)
  • basic programming ability in at least one loosely typed language (eg. Perl, Python, R
@mipearson
mipearson / cookie_helper.rb
Last active July 26, 2018 04:06
Persist a paypal developer sandbox login over multiple cucumber & capybara & selenium runs.
@mipearson
mipearson / line_item.rb
Last active December 16, 2015 11:59
Testing - I think I'm doing it wrong. 25 lines of test for very little logic. Fork & tell me how you'd do it instead.
class LineItem < ActiveRecord::Base
belongs_to :invoice
def allocated?
status == 'allocated'
end
def refundable?
allocated? && invoice.refundable?