Pragmatism in the real world

2018 in pictures

As 2018 draws to a close, I take the time to look at the past year as I have done in years past, I look at the photos that I've taken and reminisce about all that I've done this year. January I started the year with ongoing efforts to reduce the pain in my joints and then visited America for CodeMash in Ohio. This was my second consecutive year speaking at CodeMash and I really… continue reading.

Autojump is magic

One of my favourite command line utilities is autojump. It's a small command line utility that allows you to change directory without having to remember exactly where that directory is. For example, to start working on OpenWhisk, I simply type: j openw And the current directory is changed to /Users/rob/Projects/openwhisk/incuator-openwhisk for me. This is much easier than typing cd ~/Pro{tab}op{tab}in{return}! Biasing towards a particular directory When you have a directory that's a common one that… continue reading.

Upgrading to Bash 4 on macOS

Incredibly, macOS Mojave comes with Bash 3.22 by default still. Apparently this is due to licensing reasons, however Bash 4 has lots of lovely features including associative arrays that I'd like use. Hence, after reading the Internet for a bit, I've installed it on my Mac. This turned out to require just 3 commands: $ brew install bash $ sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells' $ chsh -s /usr/local/bin/bash Close the terminal and open… continue reading.

Route specific configuration in Slim

Note: This article was updated on 14 October 2019 to cover Slim 4 in additional to Slim 3. A friend emailed me recently asking about route specific configuration in Slim. He wants to be able to set properties when creating the route that he can pick up when the route is matched. The way to do this is using route arguments. I've written about route arguments before in the context of setting default values for… continue reading.

Migrating to password_verify

I've recently been updating a website that was written a long time ago that has not been touched in a meaningful way in many years. In addition to the actual work I was asked to do, I took the opportunity to update the password hashing routines. This site is so old that the passwords are stored using MD5 hashes and that's not really good enough today, so I included updating to bcrypt hashing with password_hash()… continue reading.

Replacing a built-in PHP function when testing a component

Recently I needed to test part of Slim that uses the built-in PHP functions header() and headers_sent(). To do this, I took advantage of PHP's namespace resolution rules where it will find a function within the same namespace first before finding one with the same name in the global namespace. The idea of how to do this came courtesy of Matthew Weier O'Phinney where this approach is used for similar testing in Zend-Diactoros. This is… continue reading.

Analysing the focal length of my photos

I'm currently thinking about upgrading my camera to an EOS R or Z6 and, as result, I'm thinking about which lenses I should get. While discussing options with Stuart, I wondered which were my favourite focal lengths for the photos that I've taken in the past. To work this out, I decided to use the wonderful exiftool and some scripting. This is the analyse.sh script: #!/bin/bash DIR="$1" if [ "$DIR" == "" ]; then echo… continue reading.

Using .vimrc for project specific settings

I'm more of a spaces person than a tabs person when it comes to source code and in Vim, I like to see the tab characters, so I have this setting: set listchars=tab:\⇥\ ,trail:·,extends:>,precedes:<,nbsp:+ This places a handy ⇥ character so that I can see the tabs: I'm currently working on a codebase where the coding style is to use tabs, so I need to change my settings. One option is to use EditorConfig, for… continue reading.

Notes for working on the OpenWhisk PHP Runtime

These are some notes for working on the OpenWhisk PHP Runtime, but are probably applicable to the other runtimes too. Setting up I have a clone of the runtimes I'm interested in and core side-by-side in a directory. You then need various tools for development, which are documented here for macOS & Ubuntu in the Prerequites section. Build the container The PHP runtime creates two containers, one for PHP 7.1 and one for PHP 7.2.… continue reading.

Using Fractal as your OpenWhisk API's view layer

When writing an API, it's common to produce an output that conforms to a known media type such as JSON API or HAL, etc. I'm a strong believer that even though I'm writing an API, my application has a view layer. It's not the same as building an HTML page, but you still need to separate out the code that creates the structured output from your model layer. For a couple of APIs that I've… continue reading.