Skip to content

Instantly share code, notes, and snippets.

@hjst
hjst / mtr_graph.gp
Last active July 27, 2023 14:46
Generating SVG graphs from mtr reports
View mtr_graph.gp
# Use a stacked column histogram
set style data histograms
set style histogram rowstacked
# Columns are 60% of max width (i.e. not touching, set 1.0 for touching)
set boxwidth 0.6
# Define colours - 1:yellow 2:orange 3:red
unset style line
set style line 1 linetype 1 linecolor rgb "#ffff99"
@hjst
hjst / Makefile
Created June 6, 2017 18:58
Makefile for use with PlantUML diagrams
View Makefile
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)
View Reading list.md

These are books I've been recommended, books I own but haven't started yet, books I've been given but am avoiding reading etc. etc.

General

  • Flash Boys by Michael Lewis
  • The British Way in Counter-Insurgency, 1945-1967 by David French
  • The Library: A World History by James W. P. Campbell
  • Into That Darkness: An Examination of Conscience by Gitta Sereny
  • The Character of Physical Law by Richard Feynman
  • The Design and Implementation of the FreeBSD Operating System by Marshall Kirk McKusick, George Neville-Neil & Robert N. M. Watson
  • The Illustrated Star Wars Universe by Ralph McQuarrie & Kevin Anderson
@hjst
hjst / tmux-base-session.sh
Created August 22, 2022 10:22
Celery tmux session
View tmux-base-session.sh
#!/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
@hjst
hjst / gpg.rc
Last active March 30, 2021 07:54
Simple Mutt config for using GnuPG via GPGME
View gpg.rc
# Old-school GPG config was taken from the following docs. I'm preserving these
# links here just in case I need to configure an old version of mutt & gnupg in
# the future without gpgme.
# * /usr/share/docs/mutt/gpg.rc
# * http://codesorcery.net/old/mutt/mutt-gnupg-howto
# * http://dev.mutt.org/trac/wiki/MuttGuide/UseGPG
#
# Mutt now has solid support for GPGME, which not only makes config much
# simpler and eliminates the need to fork gpg processes & parse their output -
# it also makes working with gpg-agent, kwallet, gnome-keyring etc. a doddle
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
hjst / create-tango-theme-profile-in-gnome-terminal.sh
Created April 9, 2018 13:40
Modified Tango palette for GNOME Terminal (off-black background)
View create-tango-theme-profile-in-gnome-terminal.sh
#!/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 / [Radio Streams].m3u
Created October 28, 2018 13:02
MPD playlist file for BBC radio streams at /var/lib/mpd/playlists/[Radio Streams].m3u
View [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 / gist:1326755
Last active November 21, 2018 05:22
Format a javascript Date object as a 12h am/pm time string.
View gist:1326755
function format_time(date_obj) {
// formats a javascript Date object into a 12h AM/PM time string
var hour = date_obj.getHours();
var minute = date_obj.getMinutes();
var amPM = (hour > 11) ? "pm" : "am";
if(hour > 12) {
hour -= 12;
} else if(hour == 0) {
hour = "12";
}
@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)
View send-to-pocket.el
(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"))