Start time: 11:20am from Days Bay Pavillion Finish time: ~ 2:30pm at Cheviot Bay Road + 15 minutes to cycle back to Days Bay Time: approximately 3 hours with a few breathers and a 15 minute stop for lunch An unexpected change in our weekend plans last weekend (mostly a sense of laziness that persisted all through Saturday) let us...
Something I have grown accustomed to when debugging Ruby code is the ability to jump into an irb session right from a breakpoint. With byebug this pretty much happens immediately. With pry, running irb will have the desired effect. When I started getting to the point where I needed to debug Python code I was writing, I almost immediately had...
One of the toughest part of writing tests is how to go about handling dependencies on external dependencies. Aside from databases, probably the most common type of external dependency is a network request - usually HTTP (or HTTPS). requests is a very, very popular library for performing HTTP requests in Python. It’s popular because of its easy to use API...
Not a super common occurrence, but exposing a Django model property under an alternative name is occasionally useful. I have used it before to assist in polymorphism, where several very similar models needed to have the same attribute. Given a Django model like: from django.db import models class Widget(models.Model): email = models.CharField(max_length=254) We can naievy try and alias the attribute...
I regularly complete little side projects in React - normally convenience shortcuts or data visualisation projects. My preferrred deployment platform for such static sites is Gitlab Pages, as it allows for flexible builds, and I can use custom SSL certificates so that I don’t need to terminate my SSL with Cloudflare. Here is the template I use to build my...
Note: This numbering system is known as “TMS” (even though TMS stands for “Traffic Management System”) of which the numbering system is just a small, bespoke part. I travel on the Greater Wellington Metlink transit system nearly every weekday, and am often curious about what train I happen to be travelling on. I was recently checking out the Wikipedia page...
Shell expansion is an incredibly handy shortcut. Previously to today, I’ve only ever used glob (*), which will expand to include all directories and files within the glob scope (e.g. * would list all files and directories in the current directory, test/* would list all files and directories in test/). There are more though! Today I’m covering { range }...
A VIM mode I did not know about for quite some time during my VIM usage is “paste” mode. This mode doesn’t do much, but is invaluable if you are moving code around, copy and pasting between files outside vim. Paste mode can be activated using set :paste and deactivated with set :nopaste. This mode by default simply deactivates autoindentation,...
I recently learned of a useful technique when processing large text files that have a consistent separator using awk. awk is a text processing programming language dating all the way back from 1977. While the format string passed to awk technically represents a full programming language, it is most typically used directly from the command line or from shell scripts....
ActiveRecord callbacks are pretty popular in the Rails community, but they do have pitfalls. Probably the most significant one is that the responsibilities of a model can creep quite a lot once callbacks begin getting defined. Callbacks can also be hard to test, since they are triggered under a range of conditions, and have multiple phases per condition (before/around/after initialize,...