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 […]

Programming

Where to Put Your TypeScript Type Annotations

Posted on

I have long held fast to a basic principle of letting type inference do your work for you. That means not adding type annotations unless you have a good reason to. I thought I would supply a bit more information on where to put your TypeScript type annotations and when they add value rather than […]

Programming

Real Life Performance Cost of compilation debug=”true”

Posted on

There is a little setting in your ASP.NET Web.config file that sets compilation debug to true. If you debug your application locally, this gets set for you if it hasn’t been set already… <system.web> <compilation debug=”true” targetFramework=”4.5.2″ /> <!– … –> This is necessary for debugging, but also costly. That’s why your default Web.Release.config transform […]