Programming

Simplify Strings for Comparison by Removing Special Characters and Diacritic Marks

Posted on

I was working on a search system that needed to simplify the strings for comparison. It needed to compare the text regardless of special characters (diacritic marks) or casing. The following function breaks the special characters into their component parts, before removing the “special” parts and lower-casing the whole thing. function normalise(term) { // Simplifies […]

Programming

Find All Images on a Page With JavaScript

Posted on

One of the most common issues I see in content-managed websites is the presence of a fully-qualified image address that isn’t secure when the website itself is. When this happens, you’ll need to find all images that aren’t secure and fix them. For example, if you are visiting https://www.example.com and there is an image http://www.example.com/image.png […]

Programming

Linq Style Mapping for Single Objects

Posted on

Linq is not just the go-to .NET library for handling IEnumerable data sources, it’s the inspiration for many successful and unsucessful attempts to reproduce the style in other languages. When you have a class full of Linq and you find yourself wanting to simply map a single object to something else, you’ll find yourself writing […]

Programming

The ESM Module Loader is Experimental

Posted on

If you fire up a new TypeScript app and whack it into Node, you might come across the following error about The ESM Module Loader is Experimental. (dev) root@dev:~$ node –experimental-modules run.ts (node:11333) ExperimentalWarning: The ESM module loader is experimental. (node:11333) Warning: To load an ES module, set “type”: “module” in the package.json or use […]