How I Built My Custom Hugo Pagination

· Reading time: ~5 minute(s) (1011 words) post programming gohugo.io

I’ve been planning on improving the pagination control for my blog for some time, but it always seemed a bigger job than I really wanted to work on in my spare time, but I was wrong. The only complexity was around the weird templating syntax that I hadn’t really got to grips with fully yet.

So I did some research first, why re-invent the wheel right? And I came across a really good tutorial from Glenn McComb where he went through how he built his, and seeing his examples, along with his explanations, made the syntax sink in better. I’d recommend giving his page a read first, as mine is based upon his with a few changes.

(Continue reading)

View Hugo served content on another device on network

· Reading time: ~1 minute(s) (190 words) post gohugo.io web

When you want to view content served by a locally running instance of Hugo on another device, you have to specify a few extra things so it will work correctly.

When you start the Hugo server locally, it will show the following output:

$ hugo server -w
...
(some output omitted here for brevity)
...
Web Server is available at //localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Because it’s bound to your localhost IP, you can’t just open port 1313 on your computer via a firewall and access Hugo from another device. You have to bind Hugo to the network IP instead (To find out the IP, try ipconfig on Windows or ip a on Linux).

(Continue reading)

Debugging a dotnetcore application hosted in a local IIS server

· Reading time: ~1 minute(s) (153 words) programming visualstudio dotnet core

When debugging a dotnet framework application that is hosted in a local IIS server, you would usually identify the w3wp.exe instance running the Application Pool and attach your Visual Studio instance to it. Sure you might get some issues with modules not loading, but on the whole this technique allows you to debug your application through IIS.

However, with dotnet core applications, things are a little different as they’re not ran as managed code from within a w3wp.exe instance but instead from within a dotnet.exe instance, so this is the process you should attach your Visual Studio instance to when debugging dotnet core.

(Continue reading)

Moq - Setup Mock method specifying parameters of type

· Reading time: ~2 minute(s) (255 words) csharp programming testing moq

When working on my GameBrowser project this evening, I wanted to verify that a method setup on a mock object had been called when a property of the parameter object was a particular value.

My scenario was that I was writing a unit test for the Quake3 protocol client and within that protocol client, I build the payload to include the 4-byte prefix data, so I needed to test that it was doing that payload building part correctly. I may extract this logic out in the future if I need to, but currently it’s only used within the Quake3 protocol so it can remain here for now.

(Continue reading)

Creating a Terraria server in Docker on a Raspberry Pi 4B

· Reading time: ~7 minute(s) (1367 words) gaming docker infrastructure

Terraria is a sandbox style game, similar in many ways to Minecraft, but yet different enough for many to argue otherwise!

When the Steam sale started, and Terraria was only £3.49, it made sense to give it a go. I’d tried it on a console in the past but found the controls a little cumbersome compared to a mouse and keyboard. My son also got it on his Steam account, as did a few of his friends, so we needed to find a way to get a server running where they could all play together or individually on a single world.

(Continue reading)

HP DM1-4027 Netbook locks up in Linux due to Thermal Event

· Reading time: ~1 minute(s) (168 words) techsupport dm1 notes

Sometimes in Linux I’ve noticed that the laptop will lock up, often in high CPU situations. This appears to be caused by some sort of thermal support (or lack of) and after some research, you can disable the thermal support within the OS and allow the BIOS to take over instead.

This is done by editing the grub entry to add thermal.off=1 at the end of the linux boot line which would result in the following (replacing {uuid} with your own UUID):

(Continue reading)

PrimeFilm 1800u Film Scanner

· Reading time: ~2 minute(s) (282 words) techsupport scanners notes

The drivers on the enclosed CD don’t work in Windows 10.

I had a nosey around online and found this post on the Microsoft Forum where Jack Moorhouse gave some excellent advice (copied below for safety):

  • Google “How to install unsigned drivers on Windows 10 - By TotallydubbedHD” and follow instructions
  • Download & run the installer for the slide viewer (SF_ENG_1.3.exe) which is for windows up to 7. I ran it in vista sp2 compatibility mode.AT THIS POINT IT STILL DOESN’T WORK
  • Go to control panel -> device manager ->imaging devices and update the driver for the slide viewer from the folder c:\windows\Twain_32\cyberviewX_SF

I’ll tweak the above to what worked for me:

(Continue reading)

Some reference bits for Git source control

· Reading time: ~2 minute(s) (328 words) techsupport git notes

Retaining chmod permissions for scripts in git repositories

git update-index --chmod=+x your_bash_script.sh

The git documentation provides more information on the update-index command here: https://www.git-scm.com/docs/git-update-index


Clone repository including all submodules

Get the latest commit in the parent repository:

git clone {repository_url}
cd {repository_dir}
# -- OR --
git pull

And then update the submodule:

git submodule update --init --recursive

This should pull the relevant commit for the submodule, but it will be in detached HEAD mode based on the commit of the submodule reference in the parent repository.

(Continue reading)

Convert JavaScript Number to Number Array

· Reading time: ~1 minute(s) (87 words) programming javascript

I had a number which I wanted converting into an array where each digit of the number was an item in the array. I tried a few different ways of doing this but always ended up with a string array which wasn’t what I wanted.

To get around this, you can use some of the new features introduced in ES6 as follows:

const theNumber = 432375;
const output = Array.from(theNumber.toString()).map(Number);

This results in output containing an array with the contents of [4, 3, 2, 3, 7, 5].

(Continue reading)

The imported project ".../Microsoft.WebApplication.targets" was not found

· Reading time: ~2 minute(s) (253 words) programming visualstudio

We have an existing web application project at work which was failing to open in Visual Studio 2019 with the following error:

The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VisualStudio\vCurrent\WebApplications\Microsoft.WebApplication.targets" was not found.

After some research, I came across this a VS Community post where Microsoft have deemed it to be under consideration, but after a few months, it’s still outstanding.

Figuring out that the issue could surround the vCurrent part of the path, I did a bit more research, coming across another VS Community post which discusses this point, and it turns out that Microsoft have changed the MSBuildToolsVersion variable to output Current rather than the version (as it did previously). Luckily, Jim Waite has posted a useful workaround which appears to have fixed the problem I was having (which I quote):

(Continue reading)