Specify city timezones, not timezone offsets
Dates and times are notoriously difficult to get right in software. Many of the difficulties come from timezones and how unintuitive they are to think about.
notestoself.dev/posts/specif…
Generating business name ideas with Bash and Linux
I’m setting up a small side-business selling wall art prints in the UK, and needed to think of a short, reasonably unique name.
notestoself.dev/posts/genera…
Simple example of a floating point precision error for monetary amounts
Most software engineers are aware that floating point numbers are not suitable for monetary amounts, or any amount requiring reliable decimal precision.
notestoself.dev/posts/simple…
Be careful with truthy promises in TypeScript
There’s a type of small “gotcha” bug that is easy to hit with promises for boolean values in JavaScript. The simplest example might be this: async function checkSomeCondition(): Promise<boolean> { return…
notestoself.dev/posts/be-car…
Choosing dates and times in tests
A little note to avoid bugs in tests, or missing bugs: don’t use the current date or time when writing unit tests. When making up data for tests, it’s common to just use today’s date as it’s easy to think up.
notestoself.dev/posts/choosi…
Be careful with Node file globbing vs bash globbing
There’s a common gotcha when using commandline tools that have their own file globbing, such as Prettier in Nodejs. This command is supposed to run prettier against all the .ts files in all folders…
notestoself.dev/posts/be-car…
Productivity with random numbers
One little productivity trick I use is to select tasks or work with a random number. The simplest form is numbering a list of things you could do, then selecting one randomly.
notestoself.dev/posts/produc…
Loop try catch
A simple cause of failure in software systems is a single problematic item in a set causing the entire set to fail. Trivially, it looks like this: for (const item of items) { processItem(item) } When something goes wrong in processItem()…
notestoself.dev/posts/loop-t…
1
2
Ask your interview candidates to ask you an algorithm question in return
Here’s a potential idea to improve the technical interviews that you run: if you use algorithm questions in interviews, ask candidates to ask you an algorithm question as well.
notestoself.dev/posts/interv…
1
2
Easy social media images and markup with Hugo
Twitter Cards and Facebook’s OpenGraph provide semi-standardised markup for describing web content to social media and other aggregators.
notestoself.dev/posts/easy-s…
Github Action job to post pytest coverage as PR comment
Here’s a Github Action job that runs pytest coverage and then posts a summary of the coverage report as a PR comment with Markdown formatting.
notestoself.dev/posts/github…
Capturing multiline output and exit status in a Github Action with bash
You can capture output from a Github Action by echoing a variable name to the file specified by the
notestoself.dev/posts/github…
Python script to automate static Hugo site post images
It’s good to have a general post image on content sites, as it gives more of an identity to each page, and works well for social media sharing images.
notestoself.dev/posts/python…
Easier interface segregation in TypeScript (even better than Go!)
Preamble: Introduction to interface segregation (Skip this if you’re aware of what the Interface Segration Principle is.) The Interface Segration Principle is the I in the SOLID mnemonic.
notestoself.dev/posts/easier…
Python iterator chunk generator function
Here’s a versatile Python function that splits any iterator into chunks of size n as a generator. It can take simple iterators such as lists, but also take a generator and chunk it without unwinding the whole…
notestoself.dev/posts/python…
eslint changed TypeScript files only
It’s best if a linter is applied from the beginning of a project, and with default linting rules, as that way the project benefits from the linting with the minimum possible effort.
notestoself.dev/posts/eslint…
1
1
Keeping the ElasticSearch service running on an Ubuntu server
A local ElasticSearch instance powers the Chinese example sentence search feature on Chinese Boost. This works fine, but the ElasticSearch instance has a habit of crashing about once a day.
notestoself.dev/posts/keep-e…
Simulating an S3 static website on localhost with Yulin
If you’re using S3 to host a static website and want to test and develop it locally, you can use the @kensio/yulin package.
notestoself.dev/posts/yulin-…
Simulating AWS IAM authorization of S3 calls locally with Yulin
If you want to check locally that your IAM policies allow and deny what you think they do, you can use the simulated IAM service in Yulin.
notestoself.dev/posts/yulin-…
A bad mix of bash and sh with [[
If you accidentally run a bash script with sh, you’re probably going to have a bad time. One little gotcha is the use of [[ (double square brackets) in bash. E.g.: if [[ -z "${PROJECT_ID}" ]]; then echo
notestoself.dev/posts/a-bad-…
