Scripting

Introducing Station Finder

A Cloudflare hosted single page application.

James Montgomery

4 minute read

After migrating my blog to Cloudflare Pages, I wanted to run an application exclusively using Cloudflare products. Inspiration struck on a journey where I was low on fuel in the car. Introducing Station Finder Station Finder is a single-page application. The goal was to provide a means to locate a fuel station. Initially, you select a postcode and choose from a dynamically populated list of station results. A station selection updates the objects on the page to reflect the station choice.

API Diversions

Experimenting with a new API via Cloudflare workers.

James Montgomery

5 minute read

TL; DR Recently reinvigorated with my new UI work, I set myself to task with simplifying the front end player code. No matter how I looked at it, I’d needed to rewrite the back end API to support a front end rewrite. But what if I didn’t precisely need to do that? Enter stage left, Cloudflare Workers. Below I explain how I arrived at this. If you would like to view the Worker code, you can do so here.

A Serverless text-to-speech player for jokes and quotes

Using AWS components, Cloudflare, and public APIs.

James Montgomery

2 minute read

TL; DR I decided to dust off my text-to-speech list, implementing a serverless solution delivering random jokes and quotes. You may visit it at this address: https://tts-ja.mesmontgomery.co.uk/ You can get a preview of the joke quality here: Your browser does not support the audio element. Note: I can’t affect the humour quality 🤣. Solution overview Upon visiting the page, an event triggers calls to the API routes for their relative jokes and quotes.

Backup of Cloudflare DNS to AWS DynamoDB

Using AWS Lambda to copy records into DynamoDB via the Libcloud library

James Montgomery

5 minute read

TL; DR After a short break, I decided to take an item off the project list. DNS is a rich source of inspiration for me - and so I elected for a quick win in the form of serverless DNS records backup. The goal of which is to backup my DNS zone contents, via functions as a service (FaaS) and storage as a service (object or database). You can find all the associated code for this on my GitHub page.

Detecting digit combinations in a number with PowerShell

How we can inspect a number like 143256789 and determine it contains the digits 1-9

James Montgomery

5 minute read

TL; DR How do you pass the time on a car journey? Most of us have memories of “I spy” or other game. Lately, I’ve been looking out for number combinations after a car I owned passed 123k miles - specifically 123456 miles. What’s more, the trip computer almost made it read 1234567890! As time passed, I was looking out for other odometer readings. 123465 miles was the next number of interest.

Detecting Digits with PowerShell

A person can look at a number and determine which digits are present. How would a script achieve this?

James Montgomery

13 minute read

Table of contents TL; DR How to think about the problem Working with a number in PowerShell [System.Math]::DivRem Using DivRem to detect a digit Using DivRem to detect a range of digits Contains Using .contains() to detect a digit Using .contains() to detect a range of digits Match Using -match to detect a specific digit Using -Match to detect a range of digits Split Using -split to detect a digit Using -split to detect a range of digits ASCII Method Using the ASCII value of a character to detect unique digits in a number Conclusion Acknowledgements TL; DR Have you ever wondered, how many unique digits are in a number?