Skip to content

Instantly share code, notes, and snippets.

View cmsj's full-sized avatar
Working from home

Chris Jones cmsj

Working from home
View GitHub Profile
cmsj / config.yaml
Created October 5, 2023 23:02
docker compose stack for octodns and bind to sync a zone from Route53 to a local Bind
View config.yaml
class: octodns.provider.yaml.YamlProvider
directory: /config/
default_ttl: 3600
enforce_order: True
class: octodns_route53.Route53Provider
access_key_id: env/AWS_ACCESS_KEY_ID
cmsj / hue_nicely.yaml
Created September 26, 2023 10:08
A Home Assistant custom script for turning on zigbee lightbulbs in a less awful way than default.
View hue_nicely.yaml
alias: A Hue Nicely
mode: queued
name: Bulbs
description: Turn zigbee-connected Hue bulbs on smoothly
required: true
cmsj /
Last active August 26, 2023 03:29
Ansible to add dropbear (ie an SSH server) to your initramfs, for unlocking encrypted root partitions

This is some Ansible (for Ubuntu 22.04) to install and configure your initramfs to run dropbear (ie an SSH server).

Super handy if you have an encrypted root partition and don't have physical access to the machine to enter the encryption passphrase on the console.


  • You'll need to put your actual public SSH keys, instead of the blahblah placeholder I have here
  • I set dropbear to run on port 31337 so the hostkey doesn't clash with the main OS' key in your ~/.ssh/known_hosts
  • This expects to be able to trigger two Ansible handlers when it makes changes, they are listed separately at the bottom
  • You'll need to change the GRUB_CMDLINE_LINUX_DEFAULT line below to have the actual IP/gateway/NIC/hostname you want the kernel to configure
  • After you ssh in when the machine is booting, the command to actually unlock the root filesystem is: cryptroot-unlock
cmsj /
Created August 25, 2023 09:30
Google Script thread muter
// Enforce thread muting
// When you mute a thread in Gmail, it adds a "Muted" label
// Unfortunately, it doesn't really completely mute the thread - e.g. emails added to the thread will still be marked as unread and show up against folder counts
// This script will ensure that all emails appearing on muted threads, will be marked read, and archived.
// By default it will only look for emails that are less than 3 days old, to limit the size of the query results. You can adjust that if you want to
var age_max="3d"
function enforceMutes() {
cmsj /
Created August 24, 2023 23:37
Setting Samba passwords with Ansible

Scenario: You want to create a user in Linux, and set a Samba password for it, all from Ansible:


  • This will not update the Samba password if you change the variable.

To create the encrypted vault string, run: ansible-vault encrypt_string --ask-vault-password 'some_password'

- name: Create OS group
cmsj / automatic-zfs-volume-keys.yaml
Created August 24, 2023 23:55
Loading zfs encryption keys at boot
View automatic-zfs-volume-keys.yaml
- name: Install ZFS tools/utilities
name: "{{ item }}"
state: present
- zfsutils-linux
- name: Install tank encryption key
dest: /etc/zfs/tank.key
cmsj / bpytop-console.yml
Last active August 24, 2023 23:17
Replace getty on tty1 with bpytop, using Ansible, on Ubuntu 22.04
View bpytop-console.yml
- name: Install bpytop
name: bpytop
state: present
- name: Create bpytop configuration directory
path: /opt/bpytop
state: directory
owner: nobody
cmsj /
Created August 24, 2023 10:13
# A simple tool for managing docker containers
# Drop this in your path somewhere and chmod +x it, then create symlinks to it with the names:
# clog - show the logs for a container
# cblip - restart a container and then show its logs
# cgo - run a command inside a container (defaults to /bin/sh)
# Usage for each is: <command> CONTAINER_NAME
CMD="$(basename $0)"
cmsj /
Created April 19, 2023 17:04
Quick hack to run SLM locally
# pip install the following, and make sure you have a pytorch that supports CUDA.
# accelerate
# bitsandbytes
# transformers
# IPython
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from IPython.display import Markdown, display
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from IPython.display import Markdown, display
def hr(): display(Markdown('---'))
def cprint(msg: str, color: str = "blue", **kwargs) -> str:
if color == "blue": print("\033[34m" + msg + "\033[0m", **kwargs)
elif color == "red": print("\033[31m" + msg + "\033[0m", **kwargs)
elif color == "green": print("\033[32m" + msg + "\033[0m", **kwargs)
elif color == "yellow": print("\033[33m" + msg + "\033[0m", **kwargs)