Programming

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)

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)

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)

Hosting Umbraco 7 on AWS Elastic Beanstalk

· Reading time: ~7 minute(s) (1419 words) programming umbraco aws

Previously at work, our marketing websites were all designed up front, with copy provided by our colleagues in Marketing and then the pages were generated by the development teams. Because this was taking our developers away from the tasks where they can add real value to the customer journey by streamlining the end-to-end process, it was decided that the company would benefit from introducing a CMS solution with which the Marketing team and Content Writers would be able to manage content themselves.

(Continue reading)

No executable found matching command "dotnet-lambda"

· Reading time: ~1 minute(s) (93 words) programming dotnetcore aws lambda

When packaging up a dotnetcore lambda function for deployment to AWS, you would run the following command:

dotnet lambda package -o ../../build/{DestinationFileName}.zip

However, when I ran this command earlier today on a new Lambda function project, I got the following error:

No executable found matching command "dotnet-lambda"

This is because the Amazon.Lambda.Tools package isn’t being included in the dotnet build process, so to fix things, I had to edit the .csproj file for the Lambda function to include the following:

(Continue reading)

Umbraco 7: Create a custom Property Editor

· Reading time: ~4 minute(s) (805 words) programming umbraco umbraco7 csharp

Recently, I’ve been working on creating an implementation of Umbraco CMS for the Marketing team at work to use for quickly creating content for promotions etc. and the SEO Manager has asked what we could implement to benefit them in terms of SEO (Search Engine Optimisation for those who don’t know).

Requirements

Now, until working on this, I knew what SEO was, but had no idea what it entailed, so working with the SEO Manager, we outlined the following requirements for our initial (MVP) release. He needed to be able to edit the following:

(Continue reading)

React.js Unit Testing with Jest and Enzyme

· Reading time: ~3 minute(s) (495 words) programming javascript reactjs testing

I’ve written loads of unit tests in my lifetime for C# and JavaScript, but never gotten around to writing any for testing the actual React components because there’s always been something more pressing. Time to put that right and take the plunge.

So I’ve picked up the project which resulted from the React.js Continued… State! tutorial as a starter for ten as it already has a lot of the boilerplate stuff in place.

(Continue reading)

Map() support in JavaScript ES6/ES2015

· Reading time: ~2 minute(s) (329 words) programming javascript

ECMAScript 6/2015 has brought a lot of new things to the world of JavaScript, and Map() is one of them. However, not all browsers are too keen on particular ways of using it.

I’ve been working on a UI project at work this week and encountered a weird issue with some code written by a colleague. We have some scenarios in our React app where we need to translate/map some values from an integer to a string (for textual display in the rendered screen). We tend to use Map() to do this and for the most part it works fine, until today!

(Continue reading)