Programming Stuff

This is just some random stuff that I didn't want to put anywhere else. Because, well, I can't remember now, but I'm sure it doesn't matter.

These should all open in a new tab / window.

Assorted Code Snippets

A collection of assorted snippets I often use and can't be bothered to remember. I blame the fact that I work in so many languages - it's a handy excuse.


Capitalise word
const capitalise = (str) => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;

As Percentage Of
const asPercentageOf = (left, right) => Math.round((left / right) * 100)

Get Random Entry from Array
const getRandomEntry = (sourceArray) =>  sourceArray[Math.floor(Math.random() * sourceArray.length)];

Deduplicate an array
const deDuplicate = (sourceArray) => [ Set(sourceArray)];

Check Equality
const isEqual = (left, right) => JSON.stringify(left) === JSON.stringify(right);

This stuff is here for historical reasons, don't bother.