Pragmatism in the real world

Iteration in fixed-everything projects

There are three main variables when setting up a project with a client: price, scope and time. The more flexibility we have here, the easier it is to run an agile project. This is especially true when the scope is not fixed as agile development techniques really start to come into their own. Short development cycles of small, minimal, features allow the client to see the progress of the project earlier and so direct the… continue reading.

Notes on keyboard only use of macOS

It's been a while since I could use a trackpad without pain and even longer since I could use a mouse or trackball. Currently I use a Wacom tablet as my mouse which works really well as long as I don't use it too much. Fortunately, keyboard usage doesn't seem to be a problem (yet?), so I try to use only the keyboard as much as possible on macOS (née OS X). These are some… continue reading.

View an SSL certificate from the command line

I recently had some trouble with verifying an SSL in PHP on a client's server that I couldn't reproduce anywhere else. It eventually turned out that the client's IT department was presenting a different SSL certificate to the one served by the website. To help me diagnose this, I used this command line script to display the SSL certificate: getcert.sh #!/bin/bash echo | openssl s_client -showcerts -servername !$ -connect $1:443 2>/dev/null \ | openssl x509… continue reading.

Cross-platform Makefile for Swift

I'm mostly building Swift applications for deployment to Linux, but sometimes it's easier to build and test directly on OS X rather than spinning up a VM. To facilitate this, I use a Makefile that means that I don't have to remember the compiler switches. It looks like this: # This Makefile assumes that you have swiftenv installed # To get going, start with `make init` SWIFT_VERSION = DEVELOPMENT-SNAPSHOT-2016-05-03-a # OS specific differences UNAME =… continue reading.

View header and body with curl

I recently discovered the -i switch to curl! I have no idea why I didn't know about this before… Curl is one of those tools that every developer should know. It's universal and tends to be available everywhere. When developing APIs, I prefer to use curl to view the output of a request like this: $ curl -v -H "Accept: application/json" https://api.joind.in/ * Trying 178.208.42.30… * Connected to api.joind.in (178.208.42.30) port 443 (#0) * TLS… continue reading.

swiftenv: Swift version manager

Swift 3 development is so fast at the moment, that a new development snapshot is coming out every couple of weeks. To manage this, Kyle Fuller has rather helpfully written swiftenv which works on both OS X and Linux. Once installed, usage is really simple. To install a new snapshot: swiftenv install {version} Where {version} is something like: DEVELOPMENT-SNAPSHOT-2016-05-09-a, though you can also use the full URL from the swift.org download page. The really useful… continue reading.

Filtering the PSR-7 body in middleware

Sometimes, there's a requirement to alter the data in the Response's body after it has been created by your controller action. For example, we may want to ensure that our brand name is consistently capitalised. One way to do this is to create middleware that looks like this: $brandFilter = function ($request, $response, $next) { // call next middleware $response = $next($request, $response); $content = (string)$response->getBody(); $newContent = str_ireplace('nineteen feet', 'Nineteen Feet', $content); $response->getBody()->rewind(); $response->getBody()->write($newContent);… continue reading.

Slim 3.4.0 now provides PSR-7!

I've been neglecting Slim's PR queue recently, so this weekend I dedicated a lot of time to merging all the good work that our contributors have done. As a result, I'm delighted to release version 3.4.0! This release has a larger set of changes in it than I would have ideally liked which is a direct consequence of having gone two months between releases rather than one. One particularly interesting addition that we have a… continue reading.

Compiling Swift on Linux

Swift is open source, which means that we can build it ourselves. This isn't too hard to do, but takes some time. Set up the dependencies and grab the code Firstly, you need a lot of memory and as it takes ages, give your VM plenty of CPUs! My Macbook Pro has a quad core process, so I tell Virtualbox that it can use all 4 using this configuration in my Vagrantfile: config.vm.provider "virtualbox" do… continue reading.

DI Factories for Slim controllers

When using classes for route actions in Slim 3, I recommend using a single class for each route. However you can use a single class for multiple routes. To register a class method to a route you pass a string as the route callable where the class name is separate from method by a colon like this: $app->get('/list', 'MyController:listAction'); Slim will retrieve MyController from the DI container and then call the listAction method using the… continue reading.