Skip to content

Instantly share code, notes, and snippets.

#!/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."
{
"controller": "AdvertSearchController",
"action": "results",
"params": {
"controller": "advert_search",
"action": "results",
"query": "stuff"
},
"format": "*/*",
"method": "GET",
@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'
@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
START=`date +%s`
function status {
set +x
ELAPSED=`expr $(date +%s) - $START` && true
echo "--- $1 T+$ELAPSED"
set -x
}
set -e

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)
# this is a DSL example, anonymized from a production usecase, showing
# deployment to an A/B shared server system from multiple sources.
# note that in this example that while there are many servers to restart,
# the code is deployed to a shared drive.
application 'example' do
server_set = environment.example_test_server
cgi_bin_dir = environment.example_dir + '/cgi_bin' + server_set
web_dir = environment.example_dir + '/web'
# remove some paths in the destination
# in config/environments/production.rb
config.after_initialize do
SshTunnel.establish
end
# in lib/ssh_tunnel.rb
class SshTunnel
@@process_id = nil
COMMAND = "ssh mpearson@redacted.locationB -R 9988:localhost:3000 -N -T -o PasswordAuthentication=no"

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.
[2010-11-09 11:42:08] ./installer -a /Users/mpearson/.rvm/rubies/ree-1.8.7-2010.02 --dont-install-useful-gems
./configure: line 4633: : command not found
rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
configure: WARNING: Could not find the PC. Will not output failed addresses...
In file included from src/base/commandlineflags.h:55,
from src/tcmalloc.cc:114:
./src/base/basictypes.h: In constructor ‘AssignAttributeStartEnd::AssignAttributeStartEnd(const char*, char**, char**)’:
./src/base/basictypes.h:251: warning: ‘_dyld_present’ is deprecated (declared at /usr/include/mach-o/dyld.h:237)
./src/base/basictypes.h:251: warning: ‘_dyld_present’ is deprecated (declared at /usr/include/mach-o/dyld.h:237)