RSSAmplifier

Blog

TIL Computer

Last 10 notes on TIL Computer

til.computerRSS feed ↗10 posts

Latest posts

Randomly Allocating Port Numbers

<p>A small Go function which will return an available port number. The technique is to setup a server bound to port 0, get the port number, then shutdown the server. Not a perfect technique as there’s a tiny race condition between shutting the server down and using the port, but good enough for what I need it for.</p> <figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="go"…

Using The Python Kubernetes Client

<h2 id="within-a-pod">Within A Pod<a role="anchor" aria-hidden tabindex="-1" data-no-popover href="#within-a-pod" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0…

Docker Techniques

<h2 id="setting-the-default-image-platform">Setting The Default Image Platform<a role="anchor" aria-hidden tabindex="-1" data-no-popover href="#setting-the-default-image-platform" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0…

Netlify CLI And Pipelines

<p>For anyone else having trouble installing Netlify CLI in a Github/Forgejo pipeline, seeing the error <code>directory not empty</code> when trying to install Netlify CLI globally, try <a href="https://docs.netlify.com/api-and-cli-guides/cli-guides/get-started-with-cli/#installation-in-a-ci-environment" class="external">these instructions<svg aria-hidden="true" class="external-icon"…

Statically Asserting Go Interface Implementations

<p>Today I learnt about the practice of statically asserting that a type in Go implements an interface. This is for cases where you want to guarantee a given type implements an interface, but you’re not in a position to assert this yourself within your own code.</p> <p>An example of this might be to demonstrate a given type implements <code>json.Marshaller</code>. You’re generally not going to…

Favour ANY Over IN When Using PostgreSQL With SQLC

<p>Whenever I’ve got a database, and an array of IDs, and I want to fetch the rows with those IDs, I tend to favour an <code>in</code> query:</p> <figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="sql" data-theme="github-light github-dark"><code data-language="sql" data-theme="github-light github-dark" style="display: grid;"><span data-line=""><span…

Feedback Of Conditional Updates In PostgreSQL

<p>Imagine, if you will, a service responsible for dispatching jobs to a pool of workers. The worker reports when a job has started, and will send updated while the job is in progress, and when it’s finished. The dispatcher tracks this in a PostgreSQL database and forwards the completion message upstream. This message should only be sent if the job exists in the database and should only be ever…

AWS CLI Techniques

<h2 id="getting-current-iam-role">Getting Current IAM Role<a role="anchor" aria-hidden tabindex="-1" data-no-popover href="#getting-current-iam-role" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path…

Bash Techniques

<h2 id="arrays">Arrays<a role="anchor" aria-hidden tabindex="-1" data-no-popover href="#arrays" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07…

PostgreSQL Slowdown Survival Guide

<p>A list of techniques for diagnosing and fixing a slowdown caused by PostgreSQL. Some hallmarks for when these techniques could be useful are as follows:</p> <ol> <li><strong>The database CPU is maxing out:</strong> this could be an indication that database is overloaded, either by lots of requests, or a few unoptimised queries. Finding any slow running queries may be a good first step.</li>…