Skip to content

Instantly share code, notes, and snippets.

@andrewlkho
andrewlkho / gist:e9a8c996c4bc1df23cd2
Last active April 25, 2023 08:37
How to secure debian with two factor authentication (TOTP/HOTP)

First, install the necesssary packages:

% apt-get install libpam-oath oathtool

Generate a key and write it to /etc/users.oath (NB the key will be in hexadecimal; if you are using Authy you will want to convert it to BASE32):

% KEY=$( head -c 1024 /dev/urandom | openssl sha1 | awk '{ print $2 }' )
% echo "HOTP/T30/6 andrewlkho - ${KEY}" >> /etc/security/users.oath
% chmod 600 /etc/users.oath
@andrewlkho
andrewlkho / gist:76f10a79066f7e2730b2
Created April 23, 2015 18:11
List solarized colours in Terminal
print -P "%F{234}base03\n%F{235}\n%F{240}base01\n%F{241}base00\n%F{244}base0\n%F{245}base1\n%F{254}base2\n%F{230}base3\n%F{136}yellow\n%F{166}orange\n%F{124}red\n%F{125}magenta\n%F{61}violet\n%F{33}blue\n%F{37}cyan\n%F{64}green"
@andrewlkho
andrewlkho / gist:fe6c48671fdb15148fb1
Last active August 29, 2015 14:13
LaTeX footer for notes
\usepackage[iso,british]{isodate}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}
\cfoot{\footnotesize\thepage}
\rfoot{\footnotesize{}ALKH/\today}
### Keybase proof
I hereby claim:
* I am andrewlkho on github.
* I am andrewlkho (https://keybase.io/andrewlkho) on keybase.
* I have a public key whose fingerprint is DAEA BF95 8F39 728B 31F0 4E9A 21E5 508E AF72 A573
To claim this, I am signing this object:
@andrewlkho
andrewlkho / gist:23b5b5bcf853b3473421
Last active June 23, 2018 00:24
How to install debian to a USB drive for use on a MacBook Air

This guide shows how to install debian so that it can be booted and run from a USB drive on a MacBook Air. I use this to store a copy of my PGP master keypair. Networking is deliberately not configured and all operations requiring the master keypair (such as signing other people's keys) are done only on this system. See the debian wiki for information on how to separate your key. Note that this is slightly different to using a live CD. It is not possible to tailor the base configuration of a live CD to one's own requirements, and they frequently automatically connect to the nearest local network. Nevertheless, if you wish to use a live CD instead, I recommend Tails. Arturo Filastò has written a similar guide for Tails.

The method I use requires [VirtualBox][4], which should also contain a working debian installation itself. An alternative method would be to use [debootstrap][5] b

@andrewlkho
andrewlkho / gist:10739728
Created April 15, 2014 15:02
Deploying jekyll on TextDrive

This was originally posted on 2012-12-13 to http://andrewho.co.uk/weblog/deploying-jekyll-on-textdrive

This post is an update to "[Deploying jekyll (on a Joyent Shared Accelerator)][old-article]".

This website is based on [jekyll][], a static site generator. I host the files for this in a bare git repository on a [TextDrive][] shared server. Here is the procedure I use to automatically deploy the site whenever I push to master. The paths used below will obviously be specific to where I have placed things. I use a bare git repository in ~/git/andrewho.co.uk.git and deploy to

@andrewlkho
andrewlkho / gist:10739476
Created April 15, 2014 14:59
Patching GNU screen on Mac OS X for vertical split

This was originally posted on 2011-12-18 to http://andrewho.co.uk/weblog/patching-gnu-screen-on-mac-os-x-for-vertical-split

The ability in GNU screen to vertically split a display so that two windows are visible side-by-side (which is what GNU screen means by "vertical split") is not available in the latest stable release (4.0.3). It is, however, available in the latest HEAD slated for screen 4.1. Various distributions such as debian have merged the upstream changes into their stable versions; Mac OS X (10.7) is not one of them. Here's how to compile it in.

First, clone the latest HEAD (450e8f38 at the moment):

@andrewlkho
andrewlkho / gist:10739376
Last active December 24, 2018 16:57
Clean URLs on jekyll/Apache

This was originally posted on 2011-07-11 to http://andrewho.co.uk/weblog/clean-urls-on-jekyll-apache

I use a static site generator, specifically [jekyll][], to transform some templates into a set of static *.html files. However, I like to keep the URLs looking clean, and not display the .html extension both because I think it looks better and also so that the URLs purely reflect the content and not the underlying files or CMS used to serve that content. In short, whilst the file being served might be $DOCUMENT_ROOT/weblog/title.html, the canonical URL for that resource should be /weblog/title. Here's how I do that in .htaccess.

@andrewlkho
andrewlkho / gist:10739278
Created April 15, 2014 14:57
vim-pathogen with mutt and git

This was originally posted on 2011-04-05 to http://andrewho.co.uk/weblog/vim-pathogen-with-mutt-and-git

For a long time I've used vim as my editor for both composing messages in mutt and commit messages for git. I do this with the following line in my ~/.muttrc (and a similar one in my ~/.gitconfig:

set editor = "vim -c 'set wrap tw=76 fo=toqwal12 nonumber spell' +1"

Recently I refactored my vim configuration files using Tim Pope's excellent [pathogen][1] script. Doing so required me to place the following lines in my

@andrewlkho
andrewlkho / post-receive
Last active November 11, 2015 01:41
Deploying jekyll (on a Joyent Shared Accelerator)

This was originally posted on 2010-12-29 to http://andrewho.co.uk/weblog/deploying-jekyll-on-a-joyent-shared-accelerator

This website is based on [jekyll][] (a static site generator). I store the text files for jekyll in a git repository. Here is how I setup automatic deployment of this website. Whilst a lot of this post is generally applicable, some of it (specifically the installation section) is only of relevance if, like me, you are hosted on a [Joyent][] Shared Accelerator.

Before we get started, just note that the git repository storing my website is a bare one in ~/git/design/andrewho.co.uk.git. I'll assume you're happy creating such