TypeScript object types with optional and minimally required properties
TL;DR
// Solution 1
type LabelEntry = { label: string };
type ImageEntry = { image: string };
type Entry = LabelEntry | ImageEntry;
// Solution 2
type Entry = Record<'label' & 'image', string>;
An object type that I find myself creating very frequently is one that has one or all of several properties. For example, I can create an entry with a text label, one with an image, or one with both:
Auto-increment field with Prisma

This post is a knowledgebase article on Prisma with PostgreSQL.
The typical model in a Prisma schema has an id field that auto-increments:
model User {
id Int @id @default(autoincrement())
name String
}
The following is working (most of the time) code that inserts a new entry:
prisma.user.create({
data: { name: 'Some User' },
});
However, the following error may occur:
Unique constraint failed on the fields: (id)
This is baffling - if the field auto-increments, how can the unique constraint be violated?
Docusaurus with Google Authentication
With a little bit of programming, your site made by Docusaurus can be modified to be accessible only to users signed in to Google.
The source material came from this article by Thomasdevshare. His article describes a similar authentication scheme for Docusaurus with Firebase as the identity provider whereas this article describes the same approach using Google API directly.
About Domain Names

This piece is a quick, non-technical introduction to domain names.
3 Things to Watch Out For When Commissioning Your Website

I decided to write down all the advice on website building that I always give my friends and customers so that I don't ever miss anything out. This is the first of several articles.
Leaving My Company

Two months ago I left the company which I co-founded 13 years back. Here are some of my takeaways after 13 years as its CTO.
Effective Presentations - Part 2 of 2

In the [previous article][prev], I wrote about my attempt at improving my pitches. I left off from that piece with the promise of a formula that can improve the quality of your slide decks immediately.
The answer: storytelling.
Effective Presentations - Part 1 of 2

I’m always looking for ways to improve my presentations. Oftentimes, I only get one chance to get my point across and I want to make every such opportunity count.
A Lesson from Twitter

Several months back I was addicted to Twitter. Any time I can pull out my phone, I would be checking my Twitter feed.
It's a time waster. Prolific YouTuber Dr Derek Muller describes it as a part of the distraction economy.