Blog Posts about Programming

One-keystroke Unicode characters in QMK on macOS

Written using QMK 0.6.0 on macOS High Sierra 10.13.3

I recently picked up an ErgoDox EZ keyboard, and was excited to add some Unicode characters to it. Some may know that I dabble with Esperanto, so I wanted the ability to type characters like ŝ and ŭ with a single shortcut. Plus, ✨ emoji ✨! I know macOS has an emoji picker with Cmd + Ctrl + Space, but that’s kinda painful to do repeatedly.

Read More…

How I Work: Tackling Advent of Code, Day 21

For the past three years, the amazing Eric Wastl has been running the Advent of Code - programming puzzles in the format of an advent calendar, a new puzzle every day for the month of December. They’re mindbending but great fun!

I wondered if people might be curious how I attack these kinds of puzzles - and by the reaction I got on Twitter, I guess the answer is yes! So here goes - this is day 21, the most recent puzzle I’ve completed in the 2017 edition.

Read More…

Internationalization using Gettext in the Phoenix framework

Written using Phoenix 1.1

Internationalization - what is it?

Internationalization (henceforth called i18n, because programmers are lazy and hate typing long words) is the process of adapting a web application for use in different languages or cultures. Any application that allows you to change your language has implemented i18n. It’s a close sibling of localization (L10n) - the process of actually implementing a different language/culture in a web app. Once support for i18n has been included in an app, it can be localized. This may involve adding new text strings in a different language, or configuring different date formats.

Read More…

Books, books, books!

I’m an avid reader. A really, really avid reader. I grew up reading everything I could get my hands on (including a lot of things that weren’t, ahem, age-appropriate) and as an adult I still love reading so many different things. I picked up a Kindle in about 2008, and never looked back.

Read More…

Using page-specific page titles in the Phoenix framework

Written using Phoenix 0.13.1

One common task in web apps is setting a custom page title for each URL - your homepage should have a different title than a page listing out all of your projects (for example), which should have a different title than a page showing details of a single project.

There isn’t a built-in way to do this in Phoenix, but after much reading around forums, GitHub issues, etc. I hit on two potential ways to do it.

Read More…

`add_foreign_key` gotchas in Rails 4.2

Rails 4.2 finally added native support for database-level foreign keys, which is great. You can write the following code in a migration (assuming the presence of a users table):

def change
  create_table :posts do |t|
    t.references :user, index: true
  add_foreign_key :posts, :users

Read More…

Slaying Dragons

The following is a complete piece of code from a real Rails app that is currently in production.

Read More…

Why you should be using Database Cleaner's `deletion` strategy

me: Your regularly scheduled reminder that Database Cleaner’s deletion strategy is so much faster than the truncation strategy.
my coworker: You should write a blog post about it!
— from Twitter

Read More…