Skip to content

Instantly share code, notes, and snippets.


Pat Allan pat

View GitHub Profile
pat / webmock_json_helpers.rb
Created Dec 14, 2021
Helpers for stubbing JSON requests with Webmock
View webmock_json_helpers.rb
# frozen_string_literal: true
require "delegate"
require "webmock/rspec"
module WebmockJSONHelpers
def stub_request(method, uri)
pat / settings.rb
Created Dec 14, 2021
Using dry-system for typed and verified Rails configuration settings
View settings.rb
# frozen_string_literal: true
require "dry/system/errors"
require "dry/system/settings"
require "dry/types"
module Types
include Dry.Types()
pat /
Last active Dec 17, 2021
Using MySQL 5.7 libraries on Heroku

Edit 2021-02-21: I've confirmed this solution works with both heroku-18 and heroku-20 stacks.

What follows is my solution for having mysql2 gem compiled and working against MySQL v5.7 (rather than v8+) on the heroku-20 stack. This is how I've managed to make it work:

  • Add the apt buildstack ahead of your standard buildpack (in my case, that's Ruby):
$ heroku buildpacks:add --index 1 heroku-community/apt
pat / letter.markdown
Created Oct 21, 2019
Letter to Senator Lambie about Medevac Repeal Bill
View letter.markdown

Dear Senator Lambie,

I am writing in regards to the Medevac Repeal Bill, and to strongly urge you to not allow the repeal to happen.

It is our Government that has imprisoned these people in these remote and unsafe situations, and thus it is our Government that should be providing medical support, especially given the imprisonment is a significant cause in the mental health issues so many of these detainees.

While I’m sure you’re aware of this already, it’s worth noting that the legislation that was passed earlier this year is only for the current set of detainees - it does not apply to any new arrivals, and I feel our Government has been rather obtuse in any suggestions otherwise. Any suggestion that the lack of a repeal makes our country any less safe is a cruel lie.

There have been clear cases of deaths in custody that could have been prevented had proper medical assistance been provided promptly and genuinely, rather than turning these detainees into political pawns. If the repeal goes ahead, it’s quit

View kms_placeholder.rb
require "openssl"
require "digest/sha2"
require "base64"
require "ostruct"
# Just like Aws::KMS::Client, this responds to decrypt and encrypt,
# using the same parameters and output objects (well, at least for
# the purposes of what I've used it for).
# So, you can inject this class in instead for test environments
View monolith.plugin.zsh
function ruby_files() {
xargs ls -1 2>/dev/null | grep '\.rb$'
function spec_files() {
xargs ls -1 2>/dev/null | grep '_spec\.rb$'
function uncommitted() {
# first command is staged changes, second is new files and unstaged changes
pat / parallel_processor.rb
Last active Aug 21, 2019
Thinking Sphinx parallel processing of real-time indices.
View parallel_processor.rb
# This will process each real-time index in parallel (using separate
# processes, up to the number of CPUs available).
# You will also need the 'parallel' gem, and what is currently the
# edge release of Thinking Sphinx (until there's been a release after
# v4.3.2).
# This could all go in an initialiser, or put the class wherever you
# like, and the assignment in the initialiser.
pat / minutes.markdown
Last active May 21, 2019
Ruby Australia Special General Meeting - 12th May 2019
View minutes.markdown


  • Pat Allan
  • Mark Glossop
  • Rebecca Le
  • Celia Colquhoun King
  • Steven Webb
  • Nimeshe Madanayake
  • Vanessa Nimmo
  • Lauren Hennessy
View ruby_australia_aabill_submission.markdown

To Whom It May Concern

RE: Telecommunication and Other Legislation Amendment (Assistance and Access) Act 2018

Ruby Australia is an industry body representing software developers who use the Ruby programming language across a range of businesses, industries, products and projects, and across Australia.

On behalf of our members generally (and specifically those who have supplied their signatures) we strongly condemn the Telecommunications and Other Legislation Amendment (Assistance and Access) Act 2018, which has recently passed both houses of Parliament.

The Act was hurried through without any serious consideration for industry concerns, and has a worrying lack of oversight. It shows a severe lack of technological understanding, no respect for citizens' privacy, nor any serious appreciation for digital security. And through its existence, it tars our entire profession. Because of what our Government may insist of us, our international peers and customers can no longer trust us or our products with their ow

pat / rubyconf-au-eoi-2020.markdown
Created Jan 20, 2019
RubyConf AU 2020 - Seeking Expressions of Interest
View rubyconf-au-eoi-2020.markdown

Ruby Australia

Seeking expressions of interest for RubyConf AU 2020

Expressions Required By: February 18th 2019.

One of the flagship events of the Australian Ruby community's calendar is RubyConf AU, which has been occurring annually since 2013. The Ruby Australia committee is seeking expressions of interest from people in the community to run the 2020 edition of the conference.

To support conference organisers, Ruby Australia offers event insurance and financial backing courtesy of previous events and sponsors. Also, previous organisers will be able to provide wisdom and suggestions from their past experiences, previous budgets, connections to vendors, suggested speakers to invite, and other general advice.