List memory usage per Unicorn worker

I have been using this snippet recently to show the amount of memory currently being consumed by each Unicorn worker. This is a convenient way of checking: The expected number of workers is being run The memory usage of workers is fairly uniform The average memory usage of Unicorn workers (if you are considering adding or removing workers) Here’s the...

My notes from Devops Days Wellington, Day Two

A little disclaimer: These notes are mostly for me to refer back to in the future, and are based on quick handwritten notes I took at the conference. They shouldn’t be used as a general reference since I may have misquoted, misremembered, or ventured an opinion that isn’t quite right. My DevOps ticket was funded by my employer, Ackama. DevOps...

My notes from Devops Days Wellington, Day One

A little disclaimer: These notes are mostly for me to refer back to in the future, and are based on quick handwritten notes I took at the conference. They shouldn’t be used as a general reference since I may have misquoted, misremembered, or ventured an opinion that isn’t quite right. My DevOps ticket was funded by my employer, Ackama. Moving...

Open all files as tabs in in vim

Just a quick trick I learned yesterday: I often glob files into vim from my terminal to view them quickly - for example, given the following files exist: > ls file1.txt file2.txt file3.txt When I run: vim *.txt Then I expect file1.txt, the first file, to be opened When I run the command :tab all within vim I then see...

RSpec's `have_attributes` matcher

I’ve been working on rewriting some legacy feature tests that have been unmaintained for several years as system tests. One of the most convenient methods I have found while creating these tests is have_attributes. The RSpec documentation I linked to above is a great overview of the matcher. I have found that it’s useful to matching the result of a...

Mitre Flats: Tararua Forest Park

This trip was a bit opportunistic, making the most of a fine weekend in late winter to start getting back into the Forest Park before the official start of the summer season! Mitre Flats is one of the more popular spots to visit from the Wairarapa side of the Tararua range, and has been on our to-do list for some...

Sending DHT22 readings from a Raspberry Pi Zero to MQTT

I spent a couple of hours last weekend getting a RaspberryPi Zero (W) up and running as a home automation node, joining my existing fleet of MySensor Arduino nodes. The Raspberry Pi is being used instead of an Arduino as it is eventually going to perform a number of functions along with climate sensing - for example, bluetooth presence detection...

Automatic text wrapping in vim

This is something I use all the time. I don’t have it in my ~/.vimrc yet - partially because I haven’t got around to it, partially because I sometimes want to use different line lenghts, and partially because I don’t want to bikeshed myself trying to decide on what line length I want for different file formats. Vim supports soft...

An access token state store in Elixir

I’ve recently been working on a small project that uses OAuth for authentication, which is proving to be a great approach for what I need it for. After I got the OAuth authentication layer working through, I realised that I needed a place to store the hash of user data I receive back from the OAuth provider, along with some...

Generating error messages using ActiveModel::Errors

ActiveModel::Errors are widely used in ActiveRecord and therefore Rails, and while custom messages can be provided to each validation using the message key, it’s much more flexible to instead pass a symbol as the message, which will cause the message to be looked up using the internationalisation framework provided by the i18n gem that is a dependency of Rails. Here...

I'm Josh McArthur, a web developer specializing in Ruby on Rails and Phoenix. I contribute code on GitHub and write blog posts about technology and tramping here.