Skip to content

Instantly share code, notes, and snippets.

View nottrobin's full-sized avatar

Robin Winslow nottrobin

View GitHub Profile
nottrobin /
Created February 5, 2019 15:02
Find the user IDs of LXC containers, for either Snap or Deb installs

First we need to find the user ID of the container's user.

LXD might be installed in one of two ways. You can tell which, by running:

$ which lxc
/usr/bin/lxc  # This means it's installed as a deb
# OR
/snap/bin/lxc  # This means it's installed as a snap
nottrobin /
Created September 6, 2016 14:30
With Github API v3, create branch, commit a change to a file and open a pull request
#! /usr/bin/env python
from base64 import b64decode
from github import Github
with open('access-token.txt') as token_file:
token =
api = Github(token)
site = api.get_repo('nottrobin/gh-cms-example-site')
nottrobin / letter to MP about Gaza and
Last active February 6, 2024 23:43
letter to MP about Gaza and UNRWA

Dear Victoria Prentis,

This is the only the third time I have written to you. I write now concerning what is by far the most important current issue to me, which will definitely be deciding my vote in the next election.

On January 26th, the International Court of Justice ruled that South Africa has a good case for charging Israel with genocide of the Palestinian people.

As I'm sure you're aware, under the genocide convention, all signatories (Britain included) are required to intervene to prevent any genocide they observe from happening. More directly, in the ICJ's ruling of provisional measures on January 26th, they specifically called on said signatories, along with Israel, to ensure that humanitarian assistance is provided to Gazans.

The United Nation's Relief and Works Agency (UNRWA) is by far the single most important organisation providing such humanitarian aid to Gazans effected by the horrifying crisis in Gaza, and it was able to do this in large part due to Britain's support.

nottrobin /
Created January 26, 2016 01:42
Change directory / working directory context processor for python
import os
from contextlib import contextmanager
def working_directory(path):
A context manager which changes the working directory to the given
path, and then changes it back to its previous value on exit.
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0
nottrobin / nginx-sigquit.Dockerfile
Created November 15, 2019 11:48
nginx should use STOPSIGNAL SIGQUIT
FROM nginx
RUN echo 'server {\n\
listen 80 default_server;\n\
location / {\n\
}' > /etc/nginx/conf.d/default.conf
nottrobin / settings.json
Created March 24, 2020 14:49
VSCode editor settings for black, flake8, html
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"editor.formatOnSave": true,
nottrobin /
Created November 8, 2016 09:57
git force-clone: clone a repository; if it already exists locally, reset it to a clone of the remote.
#! /usr/bin/env bash
set -euo pipefail
_usage() {
echo "
git-force-clone -b branch remote_url destination_path
nottrobin /
Created August 2, 2022 10:38
Add "web-and-design" topic to all our team's repos
import requests
import json
from github import Github
token = "REPLACE_ME"
g = Github(token)
org = g.get_organization("canonical")
teams = org.get_teams()
nottrobin /
Created June 9, 2022 21:13
Find latest commit, check for modified articles in it, check if it was added in this commit
#! /usr/bin/env bash
commit_id=$(git log --format="%H" -n 1)
articles=( $(git diff --name-only HEAD HEAD^ | egrep '^_articles') )
for article in "${articles[@]}"
article_added_in=$(git log --pretty=format:"%H" --diff-filter=A -- $article)