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)

iPad appears in Windows 10, but not showing in iTunes

· Reading time: ~1 minute(s) (183 words) techsupport hardware

I have an aging iPad2 which is getting on a bit but still works fine, but often won’t appear in iTunes, but is showing in Windows 10 as a device in ‘This PC’.

I find it usually happens after an iTunes update when the iPad was plugged in already, and it seems Windows throws in a generic driver when the Apple drivers are removed as part of the upgrade process. To solve the problem, I do the following:

(Continue reading)

Rendering an array of data as a clickable list using React.js

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

React.js is great for quickly rendering arrays of data in a tabular format, and there’s loads of grid-like packages out there in npm, but sometimes you just need to hand-crank something yourself. Which is fine, until you want the row to be clickable…

So how would you usually render a page from an array of data? Well, I’d probably start with some form of iterating the array and building up the content that way. I’ll explain how I’d go about doing this now.

(Continue reading)

React.js Tutorials

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

I’ve created a few pages on here which are now growing into a bit of a tutorial, so thought I’d collate the links into one post (and append links to any new related posts in the future) so it’s easier to follow.

So to start off, I’ll rewind back to November 2015, when I created my Getting Started with React.js post. This was using JSX and ES5, along with Browserify to “compile” the code to “Vanilla JS” which the web browsers support. Fast forward now back to this year (2017), and I’ve created an update post to that, along with a few subsequent posts that take the journey a few steps further.

(Continue reading)