Skip to content

Instantly share code, notes, and snippets.

@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)
@hjst
hjst / pinniped.xml
Created Dec 13, 2016
Example of XDXF-formatted OED data
View pinniped.xml
<k>pinniped</k><br>
<b>pinniped, <abr>a.</abr> <i>and</i> <abr>n.</abr></b>
<i><abr>Zool.</abr></i><br>
<blockquote>
<blockquote>(<c c="darkslategray">ˈpɪnɪpɛd</c>)</blockquote>
</blockquote><br>
<blockquote>
<blockquote>Also <b>pinnipede</b>, <b>pinnaped</b>.</blockquote>
</blockquote><br>
<blockquote>
@hjst
hjst / dell-monitor-vga1-config.sh
Created May 10, 2016
Configure my Dell monitor (EDID not auto-recognised) via VGA manually with xrandr
View dell-monitor-vga1-config.sh
#!/bin/sh
# This cvt command calculates the modeline for a 1920×1080 display @ 60Hz
modeline=`cvt 1920 1080 60 | tail -n 1 | cut -d ' ' -f 2-`
modeline_name=`echo ${modeline} | cut -d '"' -f 2`
if xrandr | grep ${modeline_name} > /dev/null; then
# Mode already exists (probably didn't reboot yet) so don't add it
echo "Monitor already configured, skipping..."
else
echo "Adding monitor config modeline from cvt output..."
@hjst
hjst / define.sh
Created Jun 23, 2015
Makes reading stardict dictionary searches in a terminal more bearable.
View define.sh
#!/bin/bash
# A wrapper script for sdcv which provides line spacing and wrapping to improve
# readability.
#
# Please note: sdcv(1) relies on dictionary files being in
# /usr/share/stardict/dic
# $(HOME)/.stardict/dic
usage() {
@hjst
hjst / fish_user_key_bindings.fish
Created Apr 18, 2015
This adds bash-history-esque !! and !$ bindings to fish shell (and the substitution is immediate, which is neat)
View fish_user_key_bindings.fish
# put these in ~/.config/fish/functions/fish_user_key_bindings.fish
function bind_bang
switch (commandline -t)
case "!"
commandline -t $history[1]
commandline -f repaint
case "*"
commandline -i !
end
@hjst
hjst / gpg.rc
Last active Mar 30, 2021
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
@hjst
hjst / ticker.pl
Last active Aug 29, 2015
Time ticker with variable line length for easy visual recognition of ssh session freezes
View ticker.pl
#!/usr/bin/env perl
use strict;
use warnings;
use Sys::Hostname;
require 'sys/ioctl.ph';
main(@ARGV);
sub main {
@hjst
hjst / mtr_graph.gp
Last active May 19, 2020
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"
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 / feed-fixer.php
Created Sep 25, 2013
Pulls in an overstuffed RSS feed and removes any content:encoded nodes (which are usually superfluous).
View feed-fixer.php
<?php
$ch = curl_init("FEED URL GOES HERE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
curl_setopt($ch, CURLOPT_USERAGENT, "Henry's very friendly feed fetcher v1.1");
$rss_string = curl_exec($ch);
$dom = new DOMDocument();