Migrating from Blogger to Jekyll and GitHub Pages

Tuesday, 11 June 2019

I’ve been in a bit of a blogging slump the last few months. Partly because I’ve been particularly busy, but also I’ve been a bit frustrated with Blogger. I used Windows Live Writer (later Open Live Writer), but sadly after all the effort to make it open-source, the project has kind of floundered with no one apparently leading the project now.

So what to do? Well maybe it’s time to move to a different platform. I’d see a few people with their blogs on GitHub, and after a bit of research I settled on using Jekyll with GitHub pages.

How I migrated from Blogger

I followed this useful checklist - https://thefriendlytester.co.uk/2017/07/blogger-to-jekyll-migration-timeline. Note that the jekyll-importer does not convert Blogger content to Markdown (that had me confused for a few hours).

I stuck with the same URL format for posts, so that should mean no broken links.

I made use of Windows Subsystem for Linux to run Jekyll locally (as I’d read it wasn’t so easy to get running natively on Windows). See below for more details of getting that all running.

Update Cloudflare to point to flcdrg.github.io - https://blog.cloudflare.com/secure-and-fast-github-pages-with-cloudflare/

Update FeedBurner settings to point to new source RSS feed.

What I forgot

I use dlvr.it to post to Twitter about new blog posts. I should have disabled that as it got confused by the change and thought I’d posted some new articles.

Still to do

The Blogger migration only copied text. Images are still living in their original locations. It would be good to migrate them over too.

My old blog had a nice Archive/history listing. I’ve started looking at Jekyll equivalents, but not found one that’s similar yet.

Getting Jekyll running on WSL

sudo apt update
sudo apt upgrade
sudo apt install ruby
sudo apt install ruby-dev
sudo apt install make gcc
sudo apt install g++
sudo apt install zlibc
sudo gem install pkg-config -v "~> 1.1"
sudo apt install libxml2-dev
sudo apt install libxslt-dev
sudo gem install nokogiri -- --use-system-libraries
sudo gem install jekyll-import
sudo gem install jekyll

With my locally cloned Git repo at C:\dev\git\flcdrg.github.io in Windows, in WSL I could change to the equivalent path at /mnt/c/dev/git/flcdrg.github.io, and then run jekyll server.

Anything else?

Let me know in the comments if something is broken that used to work!

Find where an object is unintentionally being converted to a string

Monday, 11 February 2019

I've been applying the Replace Primitive with Object pattern to a code base - changing what used to be strings into a custom type (which not only makes the code more readable, but now ensures through type safety that you can't accidentally pass in any old random values to methods that used to just take strings.

The code has tests, and after applying the refactoring, I have a failing test - which hints that somewhere there's an implicit conversion from the new strongly typed object back to a string. The test's failing assertion says it received "MyNamespace.TypedThing" (which is what the default implementation of ToString() returns), rather than the wrapped string value that TypedThing encapsulates.

My initial suspicion is that there's probably code similar to this that's causing the problem:

TypedThing thing = new TypedThing("thingy"); 
string s = $"{thing}";

ReSharper has a cool utility - "Structural Search and Replace". Unfortunately it doesn't work for single expressions like "{thing}".

If I was cluey, I might be able to write a Roslyn tool to search the code and find instances like that, but that's going to take a bit more effort than I want.

What about this: temporarily override the ToString() method on my custom type, and make it throw an exception!

It's a bit of a sledgehammer, but it worked!

As it turns out my suspicion was not quite correct. The offending code was actually assigning the custom type to an Object type (which explains the lack of compiler type warnings), which later on must be converted to a string.

Now that I could see an example, I could use ReSharper's SSR to confirm that was the only instance of that kind of assignment (SSR can be used as I'm searching for an assignment statement, not just a single expression). Just for good measure, I'll also re-run the entire test suite to make sure there aren't any other similar problems still hiding.

Choco list -localonly (Feb 2019 Edition)

Sunday, 3 February 2019

What software / applications am I using on my laptop (February 2019 Edition) according to Chocolatey? Here's an edited list of the output from choco list -localonly:

audacity2.3.0Audio editor
becyicongrabber2.30.0.20161027Icon extractor (for creating Chocolatey packages)
beyondcompare4.2.9.23626My favourite file comparison tool
beyondcompare-integration1.0.1Configure Beyond Compare for TortoiseGit/Svn
dellcommandupdate-uwp3.0.0Dell's driver update app
dns-benchmark1.3.6668.0Useful DNS checker
dotnetdeveloperbundle2.3.0.2563RedGate's .NET tools
FiraCode1.206Nice developer font
keepass2.41Password manager
mousewithoutborders2.1.8.105Share mouse across laptop and desktop PCs
notepadplusplus7.6.3Using this less now compared to VS Code
obs-studio22.0.2Video / screen recording
PDFXchangeEditor7.0.328.2My favourite
Pester4.4.1PowerShell unit tests
pingplotter5.8.10Useful visual ping network status
procmon3.50SysInternals Process Monitor
resharper-clt.portable2018.3.2ReSharper's free command-line tools
screentogif2.16Handy screen recorder
snagit2019.1.0Screen grabber
tailblazer0.9.0.536Text/log file viewer
ubiquiti-unifi-controller5.9.29Software for managing UniFi wireless access points
vagrant2.2.3Manage virtual machines
vsts-cli0.1.4.20190126Command line tool for managing Azure DevOps
windirstat1.1.2.20161210Where's all that disk space being used?
x-lite5.4.0.94388VoIP client
zoomit4.50.0.20160210Great for presentations

This is also a good basis for refreshing my Boxstarter scripts.

TimeoutException (aka Tour Down Under 2019 and a week off)

Sunday, 27 January 2019

Back at work for a couple of weeks of 2019 and I don't want to rush things too much, so I organised to take an extra week off after this year's Tour Down Under bike ride.

David, his son and his dad after completing the TDU
Last year's community ride (the 'Challenge Tour') had to be cancelled due to hot weather. We've had our share of hot weather again this year, but fortunately Saturday (previously Friday) turned out to be ideal. This year I rode with my dad and my son - 3 generations of Gardiners! Very proud of my son, who completed the 100km distance (his furthest ridden) plus (impressing a lot of our fellow riders) he did it on a mountain bike (as he doesn't have a road bike).

I didn't need the week off to recuperate from the ride - instead I was catching up with relatives visiting Adelaide! It was great to see them lots of time during the week.

We all just made it through the 46.6°C record maximum temperature for Adelaide on Thursday (that was a really, really hot day).
A ropes course
I watched as my son and his cousin did the ropes course at West Beach

Vanilla slice

French monopoloy game board
French Monopoly - Relying on my niece to translate

I'm finishing off the mini-break with the Australia Day long weekend. Caught up with the visiting rellies one last time (before they flew home) for morning tea/lunch/kicking the footy in the park (how Aussie is that!) following by dinner with my folks. A really nice day!

Installing .NET Core SDK for Azure Pipelines builds

Sunday, 13 January 2019

How do you ensure that the correct version of .NET Core SDK is installed for your Azure Pipeline builds? You could install it manually on your build agents, but wouldn't it be better to automate it?

The .NET Core Tool Installer Task can be used for this, and if you don't change the version of the SDK that you require frequently, very often that's enough.

When you're developing .NET Core applications, you can indicate which version of the SDK you require to build with by using a global.json file.

Unfortunately, the Installer Task doesn't currently know about global.json, so you might feel like you're doubling up - specifying the required version not only in that file but also in the configuration of the Installer Task. Don't do that!

With a bit of PowerShell, that can be done.. Create a PowerShell Task that runs before the Installer task and use it to set a variable that can then be used by the following task(s).

If you're using YAML, the task definitions would look something like this:

- powershell: |
    $PathToGlobalJson = Join-Path -Path $Env:BUILD_SOURCESDIRECTORY -ChildPath "global.json"
    $GlobalJson = Get-Content -Raw -Path  $PathToGlobalJson | ConvertFrom-Json
    $Version= $GlobalJson.sdk.version
    Write-Host ("##vso[task.setvariable variable=SdkVersion;]$Version")
  displayName: 'Parse global.json'

- task: [email protected]
  displayName: 'Use .NET Core sdk $(SdkVersion)'
    version: '$(SdkVersion)'