Some tidbits from my programming journey
Printjs with fetch api and blobs
The Printjs library is awesome The first point to make is this library is / was / will be a life saver when it comes to printing from the web. “But why?” you ask? Well, for me, it was the ability to preview a PDF report and print this directly to a locally installed printer without having to download the file first (a pain for end users). Take a look at their site and try the demos https://printjs....
Go int to string performance
Why this post? It’s not exactly the sexiest of topics but it’s something we do a lot of as developers, outputting integers as strings. But there are some huge differences in performance depending on how you go about this in Go. Round 1 - fmt.Sprintf() The first contender here is fmt.Sprintf a handy goto for a lot of string formatting problems. So we have the code below, we’ll be using this simple loop and a string builder for all the examples to get a true measure of the differences....
Mediatr and logging
Introduction I’m a huge fan of “Clean” or “Hexagonal” architecture when writing applications. The reasons for this warrant their own blog post which I’ll get round to soon hopefully. But on a recent project for a client I came across a nice way to get transactional logging almost for free within the whole application, and I was delighted with how well it worked out. Mediatr There are a number of libraries available to help with implementing Hexagonal architecture, and in particular Command Dispatchers and Command Processors, Mediatr and Paramore Brighter are two that I know of, although I’m sure there are more out there....
Giving something back
Let’s get this started! Like most developers I’ve used a significant amount of open source libraries in the past across all technologies from Go to Javascript. It’s time to give a little back. I recently spun up the Hexosoft site and as part of this needed a simple mechanism to ensure that I didn’t get spammed by bots that accessed the form on the homepage. The site’s backend is very small, just handling this one concern and integrating with mailgun to get the message to me....