Postman-Paf-js

Postman-Paf-js We’ve recently released a library called postman-paf-js that we use to apply Royal Mail rules & exceptions to PAF (Postcode Address File) addresses when converting to a printable format. We also have a ruby implementation. Why is Postman Paf required? To put it simply, UK addresses are more complicated than they might seem. But aren’t addresses just a few set lines that appear on your letters? Unfortunately, it’s not that simple! Most addresses in the UK are stored in a database called the Postal Address File (PAF), which is owned and managed by the Royal Mail. This database includes over 30 million UK postal delivery addresses and 1.8 million postcodes. However, these addresses are not stored in the familiar format you see on your envelope. Instead, they are stored in a specific data structure, as shown here ...

February 6, 2025 · 4 min · 843 words · Nathan Morris

Toggling Ruby scenarios in Drone using secrets

TiL how to toggle Ruby scenarios to be run using CI pipeline secrets Scenario In a relatively niche scenario, we have functionality that is being temporarily removed while new code is being developed. While we still want to keep our current scenarios for function X to use them again when it’s reintroduced, if they are left to run in our pipeline, every build will fail until it is reintroduced again. ...

November 7, 2024 · 4 min · 707 words · Leighton Taylor

TiL: The difference between exec and system in Ruby

Ruby provides a few different ways to execute commands against the underlying kernel programmatically, but they all work slightly differently. The simplest way to execute a command againts the shell is to surround it in backticks. For example, the following will run the command date and return whatever was output to $stdout. current_date = `date` However, there are also more explict methods you can call. In particular, there is exec and system which look like they do the same thing at a quick glance. However, they actually work very differently once you get down into what they are doing. ...

September 23, 2024 · 2 min · 425 words · George Bell

TiL: Doing multiple replacements with gsub in Ruby

gsub is great. It lets you replace characters in a string. All you have to do is give it a regex that will match whatever it is you want to replace and the string that you’d like to replace each match with. For example, if you wanted to replace the time of 18:00 with something a bit more human-readable, you could do the following: 'As always, tea time is at 18:00.'.gsub(/18:00/, '6pm') # => "As always, tea time is at 6pm." But what if you wanted to do something different for each match? Well, because gsub returns a string you can chain the methods together, which looks like the following: ...

July 30, 2024 · 2 min · 245 words · George Bell

Non-Blocking Ruby Methods

There are lot of options for concurrency in Ruby, from spawning child processes to using threads, ractors and Async. Each have their merits and drawbacks, but one of the simplest and most effective ways to run code concurrently is to use Fibers. In my use-case, I want to do some work and, in the background, perform some network requests. Network I/O is blocking, so I want to make sure I’m doing productive work on the main thread while I wait for the network requests to complete. ...

July 26, 2024 · 4 min · 681 words · Nigel Brookes-Thomas