Software Development

A Faster Git fixup Flow in Vim
Sun, Jun 26, 2022 - ~600 Words
As I work on a branch I often issue fixup commits for changes that I would have wanted to belong to an earlier commit in that branch. For example if I add some tests and then later tweak something small such as the description for the test then I’d like to just fix up that original commit rather than add a new commit just to record the improvement to the test description.
Read more →
From RSpec to Minitest: first impressions
Sun, Jun 19, 2022 - ~600 Words
In testing Ruby/Rails systems I have used (and enjoyed) RSpec. In my current work RSpec is used but the principal testing framework is intended to be Minitest. Over the years I have heard it said many times that “Minitest is just Ruby” and so it has the advantage that everything you know about organising Ruby code can be applied to your tests, with no need to learn how a DSL such as RSpec approaches this problem.
Read more →
Showing users friendly errors when using Liquid templating in Rails
Fri, May 7, 2021 - ~800 Words
When allowing users to work with templates in your system, e.g. for a CRM where you might want email templates, Liquid is a very widely-used option. If it has worked for Shopify all this time then there’s a good chance it will work for our users. In this post I’ll touch on how to use Liquid in your Rails application, but the main problem solved here is how to make the template syntax error messages friendlier for your users.
Read more →
Automating some steps of the conversion of an existing codebase to TypeScript
Wed, Sep 2, 2020 - ~300 Words
Below is a simple script which will take the list of .jsx files (in this case under the app/javascript directory and for each file it will rename it to have a .tsx extension, and then if webpack compiles (which means that the code type checks) and all tests pass, then this rename can be converted. If either fail, then the rename is reversed and the next file is tested. The motivation for this is that in a codebase of some hundreds of JS(X) files, the majority can actually be renamed cleanly, in part as currently we allow the any type implicitly.
Read more →
Zero Downtime Migrations With Rails and Mysql 5.6+
Sat, Apr 18, 2020 - ~700 Words
As the size of your tables increases the risk of downtime also increases as MySQL will by default apply a full table lock for many typical DDL operations. If you find yourself in the position where adding a column to a table will cause downtime for your application then you may avoid transformation of your schema in general, which can stop a major part of the system design from evolving.
Read more →
Setting Up React and Bootstrap 4 on Rails 6
Sun, Sep 8, 2019 - ~800 Words

In this post we will take a freshly-created Rails 6 app and set up React with Bootstrap 4 such that both the Rails and React-based views can use Bootstrap components.

Read more →
Initial Thoughts on Ruby Pattern Matching
Tue, Jul 2, 2019 - ~800 Words
This post represents a first attempt to evaluate the new pattern matching feature in Ruby 2.7 with a view to determining what use cases it might be a good fit for, both in general and in the context of Ruby. Thanks to @mametter for corrections to this post. Use case: processing JSON This is perhaps the most directly useful application of pattern matching that I could find. Taken from this slide.
Read more →
Improving Vim/Neovim Rendering Performance
Mon, Apr 15, 2019 - ~400 Words

A work in progress, but if you’re experiencing slow rendering performance in vim or neovim (particularly in Ruby files) then here is a list of things to try for a hopefully smoother experience.

Read more →
Recurring Issues Installing Ruby C Extensions on OSX Mojave
Thu, Mar 7, 2019 - ~400 Words

Recently I have had to take the time to fix failed installations of Ruby libraries which build C extensions on Mojave in multiple development environments and across multiple versions of Ruby. The solution(s) are in the end thankfully quite straightforward.

Read more →
My Development Setup
Sat, Mar 2, 2019 - ~300 Words
Terminal / Shell Dotfiles use the Thoughtbot collection as a lightweight base, with all customisation performed in a separate dotfiles-local repository. This gets me: Basic configuration of zsh A basic tmux setup vim/nvim integrated with tmux such that moving between vim and tmux panes is seamless, using the same motions. And most importantly, with this approach there are no lines in the config that I do not understand. Using Alacritty for a lower-latency experience.
Read more →
Readline Problems With Ruby on OSX
Fri, Mar 1, 2019 - ~200 Words
A recurring issue with running a Ruby development environment on OSX is integrations with external libraries, particularly readline. As various elements of the setup evolve (e.g. OSX, Homebrew, Ruby, rbenv) breakage occurs which causes development time to be spent debugging basic machine issues. The relevant error message and failure, issued by byebug was: Sorry, you can't use byebug without Readline. To solve this, you need to rebuild Ruby with Readline support.
Read more →
Install MacVim on OSX
Sat, Feb 16, 2019 - ~100 Words


brew cask install macvim

Read more →
Simpler Handling of AJAX Form Errors in Rails 4
Thu, Aug 18, 2016 - ~1500 Words
The Problem With unobtrusive Javascript, converting a form in Rails to use AJAX is as easy as setting remote: true: = form_for, remote: true do |form| = form.text_field :name This will cause our form to submit asynchronously, and expect a Javascript response, which will be executed directly to e.g. update the page appropriately. DHH recommends that we design our apps in this manner, where in the Javascript response we re-render the model using its template and use jQuery to update the HTML on the page.
Read more →
Kinesis Freestyle 2 Keyboard Review
Sun, Mar 6, 2016 - ~200 Words
First Impressions First impression upon unboxing the keyboard is that all of the reviews that I had read were out of date–Kinesis have clearly paid attention to feedback and some of the gripes that I had read about (e.g. having a browser ‘home’ hotkey, making the insert function require the pressing of fn) had been addressed. As such, the keyboard layout is easily standard enough to allow for a smooth transition from a regular keyboard (Apple wired and wireless keyboards) to the Kinesis–thus far I have not experienced any real slowdown in typing speed.
Read more →
Using the ES7 Spread Operator with Webpack
Fri, Feb 5, 2016 - ~300 Words
A short post on configuring Webpack to enable use of the ES7 spread operator
Read more →
Reinstalling MySQL on OSX using Homebrew
Thu, Jan 28, 2016 - ~300 Words
If you find that you need to have a particular version of MySQL installed on your OSX machine (e.g. to match the version running in production) but you already have a different version of MySQL installed via Homebrew, then the notes below may help you to replace the installed version with the one you need. DISCLAIMER: The following instructions involve the complete removal of the existing MySQL installation, including any databases.
Read more →
Robust Integration Testing in Rails 4 with RSpec, Capybara and Selenium
Wed, Aug 20, 2014 - ~2900 Words
The Problem Using RSpec and Capybara to test your Rails apps can make writing tests easier which is good both from a perspective of getting people to actually write tests but also for our general productivity as developers. While it has its detractors, I like the terse syntax and ease with which we can define our own helpers which help set up certain contexts such as in this case setting up the default account and switching into its subdomain:
Read more →