As the resident geek in our family, it won’t surprise you to hear that I am occasionally approached by Jocelyn and our kids to provide tech support. Sadly, most of these queries are invariably of the “how do I print from my phone” or “the Sky box stopped working” ilk, and rarely trouble my software skills. So it came as a pleasant surprise when I recently encountered a genuine reason to use .NET, APIs and Docker in support of one of Jocelyn’s craft projects.
Jocelyn has embarked on crocheting a Temperature Blanket throughout 2020. This will consist of 366 squares, one for each day of this leap year, in colours corresponding to the minimum, maximum and average temperatures that we experienced on that day.
And here was the rub – a notable absence of websites that provided these three daily data points for a location close to home. Some sites only had minimum and maximum, but no average. Others considered a “day” to run from, say, 4am to 4am, rather than midnight to midnight, which just isn’t in the spirit of the project. Still others offered the data points she needed, but not for any place close to home.
Here was my opportunity to help and earn some husbandly brownie points! I already had an account for the excellent Dark Sky API, which offers forecast and historical weather data by latitude and longitude. Further, Adam Weiss has made available dark-sky-core, a .NET Standard Nuget Package for accessing this API from .NET code. I fired up Rider, started a new console app, bashed out the following quick function, and proudly presented the desired figures to Mrs Nelson.
Scope creep inevitably presented itself at this point, as a console application didn’t meet UX requirements.
“That’s great Ian – now can you get it to email me the figures every day?”
Hmm. I didn’t want to get into that, but I could do one better, and make this into a simple self-service dedicated website. I launched a new Rider instance and created a boilerplate ASP.NET website to show the desired temperatures for the preceding 28 days. I added a standard Dockerfile, built and pushed a container image, and deployed it to an Azure App Service Plan. The final touch was to configure a memorable subdomain and so it was that http://blanket.iannelson.uk was born.
The (rough and ready) source code for both the console application and web version can be found on GitHub:
Photos of Jocelyn’s other colourful creations (and the occasional photobomb from our Miniature Schnauzer) can be found on her Instagram profile.