Skip to content

Instantly share code, notes, and snippets.

hjst /
Created Aug 22, 2022
Celery tmux session
tmux has-session -t $SESSIONNAME &> /dev/null
if [ $? != 0 ]
tmux new-session -s $SESSIONNAME -n dashboard -d sudo watch -n 5 podman ps -a
tmux split-window -v -l 70% top
tmux new-window -n flood-logs journalctl -u flood.service -f
View code-s7.rkt
#lang racket
(require games/cards racket/gui racket/class racket/unit)
;; Layout width and height:
(define WIDTH 5)
(define HEIGHT 4)
(define MAX-MATCHES (/ (* WIDTH HEIGHT) 2))
;; Randomize
(random-seed (modulo (current-milliseconds) 10000))
hjst / [Radio Streams].m3u
Created Oct 28, 2018
MPD playlist file for BBC radio streams at /var/lib/mpd/playlists/[Radio Streams].m3u
View [Radio Streams].m3u Hereford & Worcester Radio 1 Radio 1Xtra Radio 2 Radio 3 Radio 4 Radio 5 Live Radio 5 Live Sports Extra
hjst /
Created Apr 9, 2018
Modified Tango palette for GNOME Terminal (off-black background)
#!/usr/bin/env bash
# Base16 - Gnome Terminal color scheme install script
[[ -z "$PROFILE_NAME" ]] && PROFILE_NAME="Tango Modified"
[[ -z "$PROFILE_SLUG" ]] && PROFILE_SLUG="tango-modified"
[[ -z "$DCONF" ]] && DCONF=dconf
[[ -z "$UUIDGEN" ]] && UUIDGEN=uuidgen
dset() {
local key="$1"; shift
hjst / send-to-pocket.el
Created Aug 28, 2017
ELisp function to send the URL under the cursor to Pocket for reading later (uses msmtp)
View send-to-pocket.el
(require 'url-util)
(defun hjst/send-to-pocket ()
"Send the URL at point to Pocket for reading later"
((url (url-get-url-at-point)))
(start-process-shell-command "msmtp" "*send-to-pocket*"
(concat "printf 'Add:\n%s\n'"
"| msmtp"))
hjst /
Created Jul 7, 2017
Try to find valid downloads for files with a version number in their URL
curl --head --silent --output /dev/null \
--write-out "%{http_code}: %{url_effective}\n" \[6-82].[0-9]-[1-9].baz.[0-9].tgz \
| grep -v ^403
# --head # do a HEAD, not a GET; understand the tradeoffs
# --silent # hush the usual output progress bars etc.
# --output /dev/null # hush the remaining output (header echoes)
# --write-out "%{http_code}: %{url_effective}\n" # output these specific fields on a line, suitable for grep
# .../bucket/foo/bar-2.[6-82].[0-9]-[1-9].baz.[0-9].tgz # URL pattern, usual bash syntax
hjst / Makefile
Created Jun 6, 2017
Makefile for use with PlantUML diagrams
View Makefile
DIAGRAMS_SRC := $(wildcard diagrams/*.plantuml)
DIAGRAMS_PNG := $(addsuffix .png, $(basename $(DIAGRAMS_SRC)))
DIAGRAMS_SVG := $(addsuffix .svg, $(basename $(DIAGRAMS_SRC)))
# Default target first; build PNGs, probably what we want most of the time
png: plantuml.jar $(DIAGRAMS_PNG)
# SVG are nice-to-have but don't need to build by default
svg: plantuml.jar $(DIAGRAMS_SVG)
hjst /
Created Jun 2, 2017
Shell function to set temporary MFA session env vars for AWS CLI access
aws_set_mfa_env_vars () {
# This assumes you have the aws-cli tool already set up and working:
# This is the ARN for your MFA device, it's found in the "Security
# Credentials" tab of your IAM user summary
# This function only takes one parameter: the current TOTP value
# shown on your MFA device (will be a 6 digit number)
hjst / 1_query.graphql
Last active May 11, 2017
Sample cross-table query with postgraphql 3.2.0
View 1_query.graphql
allFilms(first: 5) {
edges {
node {
actors: filmActorsByFilmId {
hjst /
Last active Apr 21, 2017
Reencode .VOB files from an old DVD to .mp4 files of reasonable size
# Based on the two-pass suggestions here:
# Optional: for multiple VOB files you wish to concatenate, do so *before* reencoding:
ffmpeg -i "concat:VTS_01_1.VOB|VTS_01_2.VOB|VTS_01_3.VOB" -c copy CONCAT.VOB
# The target average bitrate (for -b:v switch) is calculated like so:
# For a video that's 600 seconds long and a target filesize of 200MB
# (200 MiB * 8192 [converts MiB to kBit]) / 600 seconds = ~2730 kBit/s total bitrate
# 2730 - 128 kBit/s (desired audio bitrate) = 2602 kBit/s video bitrate