NotesToSelf.Dev (@NotesToSelfDev) header
NotesToSelf.Dev (@NotesToSelfDev) profile picture

Developer notes for myself

Joined March 2021
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…
1
1
16
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
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…
1
1
3
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…
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 &#34;${PROJECT_ID}&#34; ]]; then echo notestoself.dev/posts/a-bad-…