Articles
Type narrowing and discriminating unions in TypeScript
May 10, 2022
π3 min read
Type narrowing is the process of moving from a less precise set of types to a more precise type or set of types. The aim of type narrowing is to reduce the types down to only the ones where the following methods or properties can be correctly accessed or c...
Putting the `S` in SOLID JavaScript
Feb 16, 2021
π4 min read
S - Single-Responsibility Principle (SRP) is the first design principal covered by SOLID principals.
SOLID is an Object oriented design principal. It stands for:
The principals were originally created and promoted by Robert Martin (aka Uncle Bob).
S -...
Getting started with Blender
Feb 13, 2021
π4 min read
I recently picked up 3d modelling after quite a few years away. I have not used Blender before so learning the basics involved many seaches and skimming videos to fine what I needed. This post is a quick guide to getting started with blender that I have cr...
React and Material UI (MUI)
Jan 8, 2021
π7 min read
When I first used Material UI, I struggled with a few concepts. I've written this quick overview to help get my head around it, and hopefully guide others to a quicker start.
I'm going to make a new project and then create some (horrible) styles!
Create ...
Formatting percentage values with JavaScript Intl
Jan 5, 2021
π§ Tip
Javascript contains an Internationalisation API that you can use to format numbers to a user's locale. Setting the style to percent is all that is needed.
Note: A value of 1 will return 100% because 1x anything is 100%!
To specify the decimal places use ...
Formatting currency with JavaScript Intl
Dec 17, 2020
π1 min read
π§ Tip
JavaScript's Internationalization API allows you to format currency. It takes the locale and options to configure the currency we're using. The options require the style to be set to currency and a currency option to specify the unit type, as this is retur...
Strava API activity sync with Axios, React, Redux & Saga - part 2
Dec 16, 2020
π6 min read
With the auth and state setup from part 1 of "Strava API activity sync with Axios, React, Redux & Saga" we can now progress to getting the activities and displaying them in a table.
Overview
Now we have tokens we can start to get the data from Strava. Th...
Strava API activity sync with Axios, React, Redux & Saga - part 1
Dec 13, 2020
π10 min read
Why?
I've been using Strava for over 5 years to track my activities, and more recently analyse them too. Towards the end of 2019 I realised that I was getting close to running 1,000km in a year, so I started a basic spreadsheet to track the data so that I...
Getting user locale with JavaScript
Nov 24, 2020
π1 min read
π§ Tip
To get a user's prefered locale we can query the navigator.language.
To change your language in Chrome go to chrome://settings/languages and add/edit the list of languages.
To get the full list of user languages we can use navigator.languages. This retur...
Styling React apps - what are the options?
Nov 1, 2020
π9 min read
When building a React app there are a number of ways you can styles your components and layout. These range from plain CSS classes on elements through to fully integrated style libraries that handle building the styles and creating class names for you.
Th...
Getting to grips with CSS variables
Oct 21, 2020
π3 min read
If you have ever used JavaScript variables then the concept of CSS variables should feel pretty familiar.
You set a variable
You use the variable
CSS variables follows this same pattern, but the language is slightly different.
What is happening here? F...