Skip to content

Instantly share code, notes, and snippets.

View hjst's full-sized avatar

Henry Todd hjst

  • Hereford, England
  • 18:11 (UTC)
View GitHub Profile
@hjst
hjst / tmux-base-session.sh
Created August 22, 2022 10:22
Celery tmux session
#!/bin/sh
SESSIONNAME="ctl"
tmux has-session -t $SESSIONNAME &> /dev/null
if [ $? != 0 ]
then
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
#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
hjst / [Radio Streams].m3u
Created October 28, 2018 13:02
MPD playlist file for BBC radio streams at /var/lib/mpd/playlists/[Radio Streams].m3u
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/llnw/bbc_radio_hereford_worcester.m3u8#BBC Hereford & Worcester
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/llnw/bbc_radio_one.m3u8#BBC Radio 1
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/llnw/bbc_1xtra.m3u8#BBC Radio 1Xtra
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/llnw/bbc_radio_two.m3u8#BBC Radio 2
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/llnw/bbc_radio_three.m3u8#BBC Radio 3
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/nonuk/sbr_low/llnw/bbc_radio_fourfm.m3u8#BBC Radio 4
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/nonuk/sbr_low/llnw/bbc_radio_five_live.m3u8#BBC Radio 5 Live
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_low/llnw/bbc_radio_five_live_sports_extra.m3u8#BBC Radio 5 Live Sports Extra
http://a.files.bbci.
@hjst
hjst / create-tango-theme-profile-in-gnome-terminal.sh
Created April 9, 2018 13:40
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
hjst / send-to-pocket.el
Created August 28, 2017 14:27
ELisp function to send the URL under the cursor to Pocket for reading later (uses msmtp)
(require 'url-util)
(defun hjst/send-to-pocket ()
"Send the URL at point to Pocket for reading later"
(interactive)
(let
((url (url-get-url-at-point)))
(start-process-shell-command "msmtp" "*send-to-pocket*"
(concat "printf 'Add:\n%s\n'"
url
"| msmtp add@getpocket.com"))
@hjst
hjst / url-version-finder.sh
Created July 7, 2017 17:08
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" \
https://s3.amazonaws.com/bucket/foo/bar-2.[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
hjst / Makefile
Created June 6, 2017 18:58
Makefile for use with PlantUML diagrams
PLANTUML_JAR_URL = https://sourceforge.net/projects/plantuml/files/plantuml.jar/download
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
hjst / aws_set_mfa_env_vars.sh
Created June 2, 2017 13:30
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:
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html
#
# This is the ARN for your MFA device, it's found in the "Security
# Credentials" tab of your IAM user summary
mfa_arn="arn:aws:iam::01234567890:mfa/your.name.here"
# This function only takes one parameter: the current TOTP value
# shown on your MFA device (will be a 6 digit number)
@hjst
hjst / 1_query.graphql
Last active May 11, 2017 10:02
Sample cross-table query with postgraphql 3.2.0
{
allFilms(first: 5) {
edges {
cursor
node {
nodeId
filmId
title
releaseYear
actors: filmActorsByFilmId {
@hjst
hjst / vob-to-mp4.sh
Last active April 21, 2017 15:16
Reencode .VOB files from an old DVD to .mp4 files of reasonable size
# Based on the two-pass suggestions here: https://trac.ffmpeg.org/wiki/Encode/H.264
#
# 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