Skip to content

Instantly share code, notes, and snippets.

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 / [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
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 Apr 9, 2018
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 / 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"
(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 Jul 7, 2017
Try to find valid downloads for files with a version number in their URL
View url-version-finder.sh
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 Jun 6, 2017
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)
@hjst
hjst / aws_set_mfa_env_vars.sh
Created Jun 2, 2017
Shell function to set temporary MFA session env vars for AWS CLI access
View aws_set_mfa_env_vars.sh
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
Sample cross-table query with postgraphql 3.2.0
View 1_query.graphql
{
allFilms(first: 5) {
edges {
cursor
node {
nodeId
filmId
title
releaseYear
actors: filmActorsByFilmId {
@hjst
hjst / vob-to-mp4.sh
Last active Apr 21, 2017
Reencode .VOB files from an old DVD to .mp4 files of reasonable size
View vob-to-mp4.sh
# 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
@hjst
hjst / abbreviations.tsv
Created Dec 14, 2016
Tab-delimited file of abbreviations used in the OED.
View abbreviations.tsv
abbr title
a. adjective
a. adoption of, adopted from
a (in dates) ante
abbrev. abbreviation (of)
Aberd. Aberdeen
abl. ablative
absol. absolute(ly)
abstr. abstract
Acad. academia, academy, academic(al)