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.
https://t.co/tGsjqPACIX
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…
https://t.co/qapsgXOG5i
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.
https://t.co/Z9xj2APxx9
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()…
https://t.co/iD9poj0jTS
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.
https://t.co/ucfrvvFGPJ
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.
https://t.co/5jAOuv9kkv
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.
https://t.co/mNiaUrvPar
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
https://t.co/A4AtwVXt7a
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.
https://t.co/ffrzAPqi21
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.
https://t.co/A5c4qaveKO
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…
https://t.co/shEqj0VvlJ
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.
https://t.co/gzxY65T0GG
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.
https://t.co/hY8VX0Uecx
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.
https://t.co/4NsyseMXEL
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.
https://t.co/T4dvbwj3oI
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
https://t.co/HGthhN0VBK
Combining TypeScript assertion signatures and function overloads
TypeScript has a useful feature called assertion signatures that allows you to write functions that can be used to narrow the type of a value.
https://t.co/dtwQKDfBGA
Problem maximisation
A common metaphor about the potential dangers of AI is called “paperclip maximisation”. The idea is that an AI tasked with producing paperclips could figure out that it can produce more paperclips by e.g.
https://t.co/VaVLDQwHq3
Beware of SQL averages over dates with empty days
It’s pretty common to use SQL to extract sales summaries from tables that represent sales orders as rows. These kinds of queries often use the AVG() aggregate function to summarise the sales volume.
https://t.co/LHJ5Wnwk8E
Catching stale dist files in an npm tarball before publishing
Most TypeScript packages publish only their build output from the dist/ directory. That looks like this in the package.json file: {
https://t.co/MTihoxeQUQ