Sean McLemon | Notes

Home | Czech | Blog | GitHub | Advent Of Code | Notes

This is a collection of notes on some books I've read and some smaller projects that are more more suited to notebook-style text-code-text presentation, or which are otherwise not worth a big write-up.

2020-05-15 - Web.config transforms

Update: I ended up writing my own version of a Web/App.config transform tool that does what I want: tpt

I found myself having to mess around with a lot of Web.config transforms recently, I was using ctt to check they worked as expected. I don't really like the tool though - the command line parameters are weird (PS> ctt s:"Web.config" t:"Web.Production.config" d:"test.config" pw - that {switch}:"value" format instead of --switch=value is weird) and I dislike that destination: is a mandatory param and that I can't just omit it to cause the transformed output to print to stdout.

The second issue is easy to fix - I can change ctt to do what I want by applying the following quick-n-hacky diff:

2020-05-11 - Calculating "value" of Whisky, age over cost

Over lunchtime today I was curious about the relationship between a whisky's age and its price. Of course an older whisky will usually be more expensive than a younger one, but I wanted to see how true that was, if there were many outliers and what the "best" age/price ratio was. Note: I'm aware that "older" does not necessarily imply "better" - this is just a little exercise for fun. I first had to scrape the page for whiskies with an age statement, I did this by opening, expanding the page fully (by scrolling down and hitting "Zobrazit dalších N" a few times, running the following and deleting any that didn't have text like "12 YO" or "8YO":

const rawWhiskies = $(".seznamZbozi section")
let whiskies = [];
for (const whiskyElement of rawWhiskies) { 
  whiskies.push({ name: whiskyElement.children[1].innerText, price: whiskyElement.children[2].innerText });

This is below (it's quite long):

2020-05-10 - Deanonymising SMWS casks with Greasemonkey

The Scotch Malt Whisky Society visit various whisky distilleries across the country selecting barrels to release to their members under their own label. They have interesting names like Muesli Mosh Pit or All-purpose wasp repellent or A choc ice melting on rhubarb crumble. However it's not immediately obvious which distillery each whisky comes from, all you have to go on is a "cask code":

SMWS before my script

SMWS members have over the years deciphered this however. The first part of this code identifies the distillery, so for "All-purpose wasp repellent" we can look up code "88" somewhere (many places list this, like here, here or here and find that it refers to Speyburn distillery. This can be a bit tedious though, so I picked up a tool I last touched many years ago - Greasemonkey - and wrote a little user-script to replace the actual Distillery name.

SMWS after my script

Some might argue that part of the fun is in not knowing this information, which is fair enough. But it's a fun exercise. Anyway here's the source code - the lookup and my stupidly verbose style makes it a bit long:

2020-02-01 - The Elements of Programming Style (1974)

The Elements of Programming Style was written by Brian Kernighan and P.J. Plauger and I've got a lot of respect for both of them. In addition to writing some of the most important software, Kernighan also wrote some books I really enjoyed - The C Programming Language, The AWK Programming Language and The UNIX Programming Environment. Plauger's company "Dinkumware Inc" implemented a C standard library back in the '80s which I worked with a bit back when I was in Analog Devices. I hadn't really heard anything about the book but I'm curious what was considered good practice back in 1974, and how relevant it is for developers in 2019.

2020-01-01 - Introduction

I wanted to try writing blog posts using a homebrew blogging platform. I really quite like using Jupyter Notebook, so I wrote a static site generator which produces a simple blog from a folder of .ipynb files. It's written in Python, uses the nbformat lib for handling the notebooks and jinja2 for page templating (yes, I know about nbconvert).