Teach Your API Test Platform to Send Callbacks

I already wrote about using Prism as an API test platform but I didn’t include an example with callbacks so this post is to fill that gap! If you didn’t read the previous post, the tl;dr is that Prism is a nodejs open source tool that can take your OpenAPI specification and then do an impression of your live API, validating the API calls sent to it and responding with the example data described in the spec. It can also follow up the API response and send an HTTP request of its own to mock the callbacks described in your OpenAPI spec. Continue reading

Make Thumbnails of PDF Pages with ImageMagick

All my talk slides are PDF – I use rst2pdf to transform text-based ReStructuredText content into presentation slides. With all these PDFs hanging around, it can be very handy to have them as thumbnails. I use the images both in the printable speaker notes that I produce (and I should blog that too now I’ve mentioned it), and to share on twitter – especially the resources slide that everyone photographs! My image file is much more readable than your cameraphone picture in terrible lighting :) So here’s my script for thumbnails in case you want to do the same; most presentation tools will export to PDF if you’re not already working in that format. Continue reading

Instant Test API Platforms with Prism

I’ve been writing a bit about OpenAPI lately and I realised that I didn’t share how I’m creating local, test versions of production APIs to work with while I develop new client code or test SDK features. The recipe is simple: you will need an API spec, the excellent open source tool Prism and an HTTP client. Mix it up and be ready to change your API development workflows forever. Continue reading

Grab Annotations from a PDF with pypdf2

If you’ve noticed a lot of PDF content around here lately, that’s because I work with PDF a lot! Most of all, all my slide decks are in PDF and in the last year or so I’ve started using speaker notes in my presentations. Yes, this means that if you saw me speak in the first ten years of my speaking career, that was without speaker notes.

There are some situations where I don’t have access to my speaker notes. Usually this is a good reason, such as I have mirrored my displays so I can demo or play a video without fiddling with my display settings in the middle of a talk. Sometimes, it’s because something bad happened and I’m presenting from someone else’s machine or a laptop that’s completely off stage and I only have the comfort monitor. For those situations I use a printed set of backup speaker notes so I thought I’d share the script that creates these.

Continue reading

Raspberry Pi SenseHat Night Clock

I recently upgraded my smartwatch and the new model needs charging daily (whether that’s really an upgrade is a separate discussion!) so I drop it on the charger by my bed overnight. As a result, I can’t tell the time if I wake up in the night which is only annoying because I don’t know if it’s midnight or if the alarm is going to go off in ten minutes! So I made myself a colourful fuzzy time clock with a raspberry pi and a SenseHat that were lying around in my office. Continue reading

Counting Duplicate Commit Messages

When chatting about source control good practice the other day, I got a question about repeated git commit messages. In general, I would always advise that the same commit messages appearing multiple times in a project’s history is a definite red flag – and if I’m responsible for that repository I will probably make fun of you for doing it. Continue reading

Ruby for non-Rubyists with Snap

I’m an Ubuntu user and I enjoy most server-side scripting languages but I haven’t done much Ruby and I never get the feeling that Ruby is pleased to see me when I do. Something is always out of date or has an incompatible dependency or … and since I don’t use it regularly, I don’t have the familiarity that enables me to easily debug these things with other platforms.

I’ve been using the Ruby Snap on Ubuntu for a while now, and I think it’s a bit better? I’ve referred to my notes every time I’ve done it though so I thought I had better put them somewhere I’ll find them even when I’m using a new notebook :)

What versions are available?

snap info ruby will show your choices of versions to install. I usually just need a major.minor version combination so I set the version with:

sudo snap switch ruby --channel=2.5/stable
sudo snap refresh

If you see a lot of “extension not built” anger then try this: ruby.gem pristine --extensions

Using Ruby and Gem and Bundle

The snap actually ships with all these commands available as separate commands:

  • ruby (just check this is the right one! Should be the same as /snap/bin/ruby – if it’s not check what order things are in your $PATH)
  • ruby.gem is the gem executable for this snap ruby
  • ruby.bundle is the bundler gem for this snap ruby (I use this one the most since my ruby usage is basically bundle exec jekyll serve most of the time!)

Beware that the 2.5 channel has bundler v2 and the 2.6 channel has v1, I have no idea why but it’s tripped me up at least four times now

Sniglet is a Font for Avoiding Font Loading Mistakes

I am not a designer, nor will I ever be. Things look perfectly fine to me a very long time before they look OK to anyone else! Along with that, I don’t always find it easy to tell fonts apart. I can do serif-ish and sans-ish but if the fixed-width font has serifs on it I sometimes miss that detail if I’m not looking for it – which also means that I have no idea if I’ve loaded the fonts I was thinking of or not.

To get around this, I test everything by switching the font to Sniglet from the League of Moveable Type. It’s … umistakable! Continue reading

OpenAPI Description using API key and secret

I’ve been working on a few OpenAPI descriptions of APIs lately, and really enjoying the benefits they bring. In particular the ability to import into Postman as a collection I think is a “killer feature” for APIs looking to get developers up and running quickly. The catch? I found that an API that needs an API key and secret, or a username and password/token, is supposed to be described with multiple security schemes – but this does not play nicely with tools like Postman. Continue reading

The Laravel Synchronous Queue

Using queues for asynchronous processing is one of my favourite tricks for offloading hard work from web servers. When working with Laravel recently I was pleased to find that it supports beanstalkd out of the box. I’ve got opinions about frameworks with Opinions but I did find one thing I really liked in the way Laravel uses queues: the sync queue option that runs your queue synchronously on your development platform so you can develop and debug your work, then switch the queue platform you use later. Continue reading