Skip to content

Instantly share code, notes, and snippets.

@mipearson
mipearson / lib__npm_check.rb
Last active September 1, 2016 07:21
Simple NPM version checker
class NpmCheck
# Checks package.json against the local node_modules directory
# to assert that every package specified in package.json is
# present in node_modules. If possible, it performs a basic
# "newer or equal than" check on the package's version. Without
# access to npm's semver primitizes & parsing it is a bit more difficult
# to perform proper version matching checks.
#
# Requires https://github.com/jlindsey/semantic to parse versions.
#

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.

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)
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 August 29, 2015 14:16
libsass/sassc working with Rails sprockets - rough impl, Rails 3.2
config.before_initialize do
require_relative '../lib/sassc_template'
Sprockets::Engines #force autoloading
Sprockets.register_engine '.scss', SasscTemplate
Sprockets.register_engine '.sass', SasscTemplate
end
@mipearson
mipearson / trello2github.rb
Created January 4, 2015 10:49
trello2github
#!/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'
{
"controller": "AdvertSearchController",
"action": "results",
"params": {
"controller": "advert_search",
"action": "results",
"query": "stuff"
},
"format": "*/*",
"method": "GET",
#!/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."
# 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 September 12, 2014 04:04
TEG Developer / Operator position

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: