LaTeX Notes

4 Jan, 2022 - 1 minutes
Insert a figure, caption and label in a multicols environment This doesn’t float so will appear exactly where you place it % preamble \usepackage[margin=10pt,font=small,labelfont=bf]{caption} % reqd for captionof in minipage figs \usepackage{calc} % reqd to calc minipage dims % image \begin{minipage}{\linewidth-10pt}% -10pt to avoid hbox overflow \includegraphics[width=\linewidth]{img/tas} \captionof{figure}{Total Alkali--Silica for Martian igneous rocks \autocite{Filiberto2017}} \label{fig:tas} \end{minipage}% Referencing WIP Macros These are some of the custom commands I use when producing documents.

Using GCR on a (non-GKE) Kubernetes Cluster

18 May, 2021 - 1 minutes
Firstly, if you don’t yet have an artifacts bucket for GCR then you will need to you need to push an image to the registry to create the storage account. This can be anything (e.g. busybox) and can ideally be done with a project owner or editor. $ gsutil ls 'gs://artifacts.*' < no output > $ gcloud auth configure-docker $ docker pull busybox:latest $ docker tag busybox:latest gcr.io/<PROJ_ID>/busybox $ docker push gcr.

AES encryption with Java

20 Mar, 2018 - 3 minutes

The following code is for encrypting short messages (it acts on byte arrays and not streams so the whole message needs to fit in memory). It creates a random Initialisation Vector (IV) for each message which is prepended to the start of the encrypted stream.

Minimal logging configuration with Java, SLF4J & Gradle

9 Mar, 2018 - 1 minutes

This is mainly here for my copying and pasting for a new Java project.

The gradle deps bring the SLF4J API in to the compile time classpath and the LOG4J implementation in to the runtime. If you wanted to compile the log4j implementation in to your code base (e.g. building an application and not a library), you would need to move it into the compile list.

GPG With Multiple Recipients

22 Mar, 2015 - 3 minutes

This is how to store sensitive information (e.g. SSL key passphrases) in a GPG encrypted file with multiple recipients. If you’re using git to store the file (which you probably should be), always do a git pull before doing any changes. These files are binary and therefore merges are very difficult otherwise.

Encode Base36 in Python

1 Feb, 2015 - 1 minutes

The cleanest way I’ve found so far to encode/decode between base36 and integers in Python. The primary purpose of this was to write a url shortener based on looking up a numbered url from a database.