Skip to content

Instantly share code, notes, and snippets.

View codeinthehole's full-sized avatar
🌏
The main difference between dinosaurs and us is we're building our own meteor.

David Winterbottom codeinthehole

🌏
The main difference between dinosaurs and us is we're building our own meteor.
View GitHub Profile
@codeinthehole
codeinthehole / python-testing.md
Last active January 23, 2026 10:54
Python testing reference

Python testing reference

This document is a reference for common testing patterns in a Django/Python project using Pytest.

Contents:

@codeinthehole
codeinthehole / git-run-precommit-on-branch-commits.sh
Last active November 3, 2025 10:41
Bash script to run pre-commit on every commit in a PR branch
#!/usr/bin/env bash
# Run pre-commit on every commit in your PR branch.
#
# The rebase will stop is pre-commit fails on any commit, allowing you to fix
# the issues. Once you've made changes, verify that pre-commit now passes on
# that commit with:
#
# pre-commit run --from HEAD^ --to HEAD
#
@codeinthehole
codeinthehole / list_1pw_user_items.sh
Created October 7, 2025 08:53
List 1Password items that a given user has access to
#!/usr/bin/env bash
#
# Print a TSV of items that are accessible by a given user.
set -e
export OP_FORMAT=json
function main() {
@codeinthehole
codeinthehole / list_1pw_item_users.sh
Created July 22, 2025 13:43
List users with access to a given 1Password item.
#!/usr/bin/env bash
#
# List a TSV of users who have access to an item.
set -e
export OP_FORMAT=json
function main() {
local item_id="$1"
@codeinthehole
codeinthehole / osx_bootstrap.sh
Last active July 16, 2025 10:19
Script to install stuff I want on a new OSX machine
#!/usr/bin/env bash
#
# Bootstrap script for setting up a new OSX machine
#
# This should be idempotent so it can be run multiple times.
#
# Some apps don't have a cask and so still need to be installed by hand. These
# include:
#
# - Twitter (app store)
@codeinthehole
codeinthehole / check_repos_for_unpushed_changes.sh
Created May 1, 2025 12:06
Bash script for checking local repositories for unpushed changes
#!/usr/bin/env bash
#
# Check the status of a folder of repos to see if there are any unpushed commits.
#
# This is intended to help migrate to a new laptop, where you want to check
# that there are no unpushed local commits before switching to the new machine.
#
# Needs `rg` and `fd` installed.
set -e
@codeinthehole
codeinthehole / tdd.sh
Created October 13, 2024 14:58
A Bash script for running an iterative TDD loop using an LLM to make a set of tests pass
#!/usr/bin/env bash
#
# A Bash script to run a TDD loop for building a Python module to pass tests.
set -euo pipefail
# How many times to loop.
ATTEMPTS=4
# The system prompt to use when creating the initial version.
@codeinthehole
codeinthehole / user-data.sh
Created August 18, 2014 12:41
Get the value of an EC2 instance's tag
#!/usr/bin/env bash
#
# Get the value of a tag for a running EC2 instance.
#
# This can be useful within bootstrapping scripts ("user-data").
#
# Note the EC3 instance needs to have an IAM role that lets it read tags. The policy
# JSON for this looks like:
#
# {
@codeinthehole
codeinthehole / git-fixup-files
Created August 8, 2024 11:01
Custom version of `git absorb` which autosquashes unstaged changes
#!/usr/bin/env bash
#
# Try and squash unstaged changes into existing branch commits.
#
# This command examines each unstaged file and attempts to create a fix-up
# commit to squash it into its natural parent in the current branch.
#
# - If it's able to do this for all modified files, the fix-up files are
# automatically squashed in.
#
@codeinthehole
codeinthehole / .pythonstartup.py
Created December 30, 2020 11:41
Python start-up file
# Python start-up file
# --------------------
# Ensure a PYTHONSTARTUP environment variable points to the location of this file.
# See https://docs.python.org/3/using/cmdline.html#envvar-PYTHONSTARTUP
# Always have pp available
from pprint import pprint as pp
# Pre-emptively import datetime as I use it a lot.
import datetime