Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Pearson mipearson

View GitHub Profile
View infrastructure.md

Senior Infrastructure Engineer @ Marketplacer

Would you like to work with a small and motivated team where your decisions matter? Would you like to take an existing server & deployment architecture and help us rebuild it from the ground up?

Marketplacer is building one of Australia's leading eCommerce platforms and we are looking for an exceptional Infrastructure Engineer to join our team.

Here's a few reasons why working for us is awesome:

  • Our large, well furnished office is in South Melbourne and is near the excellent cafes of Bay St and only a couple of minutes walk from the 109 tram.
  • You'll be provided with a top-of-the-line laptop or desktop (Apple or otherwise) and any software that you need to do your job.
View goservice.md

Requirements:

  • Be restartable without denying or prematurely closing requests (unicorn's SIGUSR2 being the "gold standard")
  • Log information about requests in logstash compatiable JSON, including request path, request time & status code. Optionally should include request parameters, content length, content type & time spent in DB, views, external services
  • Report exceptions to Rollbar & not die if an exception is encountered
  • Connect to external resources via environment variables, optionally also via command line flags (cf 12factor app)
  • Allow for automatic destruction/creation of database tables in tests
  • Allow for programmatic migration of database tables in production (standard: rake db:migrate)
  • Require no filesystem resources other than its own binary (eg, no db.yml or migrations directory)
View gist:8a27fe64a06014b908fb
START=`date +%s`
function status {
set +x
ELAPSED=`expr $(date +%s) - $START` && true
echo "--- $1 T+$ELAPSED"
set -x
}
set -e
@mipearson
mipearson / config_application.rb
Last active Aug 29, 2015
libsass/sassc working with Rails sprockets - rough impl, Rails 3.2
View config_application.rb
config.before_initialize do
require_relative '../lib/sassc_template'
Sprockets::Engines #force autoloading
Sprockets.register_engine '.scss', SasscTemplate
Sprockets.register_engine '.sass', SasscTemplate
end
View trello2github.rb
#!/usr/bin/env ruby
# Copyright (c) 2015 The Exchange Group Pty Ltd
# Code licensed under http://opensource.org/licenses/MIT
require 'bundler/setup'
require 'octokit'
require 'trello'
require 'pry'
View logstasher.json
{
"controller": "AdvertSearchController",
"action": "results",
"params": {
"controller": "advert_search",
"action": "results",
"query": "stuff"
},
"format": "*/*",
"method": "GET",
View rubocop.rb
#!/usr/bin/env ruby
changed = `git diff --numstat origin/master | awk '{ print $3 }' | grep -E '(\\.rb|\\.rake)$' | grep -v db/schema`
changed = changed.split("\n").select { |c| File.exist?(c) }
if changed.length > 0
system "bundle exec rubocop #{ARGV.join(' ')} #{changed.join(' ')}"
else
puts "No changes."
View benches
# serve is via a simple net.HTTP go server
# cmd is running the binary and piping stdin/out
# serve maxes out at 3000/s, cmd at 130/s regardless of input
# npm.sh.raw is 5000 lines of coloured npm install output and is
# more representative of the sorts of inputs buildbox would be dealing with
➜ terminal git:(GoRewrite) ✗ ./script/benchmark spec/fixtures/npm.sh.raw
2014/11/08 13:44:47 Listening on port 1337
Calculating -------------------------------------
@mipearson
mipearson / dev_op_job_ad.md
Created Sep 12, 2014
TEG Developer / Operator position
View dev_op_job_ad.md

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

We're looking for somebody who has:

  • a strong operations background, preferably experience with bare metal / co-located hosting
  • understanding & experience with configuration management (eg Puppet, Chef, Ansible, Babushka)
  • a basic understanding of Ruby, or sufficient experience with a similar language (eg Python) that they could cross-skill easily

You'll get bonus points for an interest in or experience with:

View rails_4_find_by.rb
# Add this to your Rails 3.2 project to add in approximations of the Rails 4
# finders and disable Rails 2/3 'dynamic' finders.
module ActiveRecord
# Approximations of the new Rails 4 finders
class Relation
def take
first
end
You can’t perform that action at this time.