Skip to content

Instantly share code, notes, and snippets.

View tbnorth's full-sized avatar

Terry Brown tbnorth

View GitHub Profile
@tbnorth
tbnorth / fast_git_ps1.sh
Last active February 26, 2026 13:41
Fast Git Bash (Windows) git status prompt
# Paste this at end of .bashrc
# Replacing "On branch" with " " makes sure the branch-name sorts first in `sort -u`
# sort -u removes duplicate x!? chars. for multiple deleted / modified / unknown files
# final sed strips leading space and linebreaks and adds []
function fast_git_ps1 {
git status 2>&1 | sed -En '
/On branch/ {s/On branch / /; s/$/ /; H}
/deleted:/ {s/.*/x/; H}

docker run -d --restart unless-stopped -it -p 30767:8767 -v $PWD/devsub:/src/devsub --mount src=shared_htdocs,dst=/out,volume-subpath=devlogs python python /src/devsub

HOST=maindev ; CONT=someapp ; on -n $HOST "docker logs -t --tail 1000 $(docker ps -fname=$CONT --format='{{println .ID}}')" | devpub $HOST $CONT

@tbnorth
tbnorth / disable_all_workflows.sh
Last active October 13, 2025 16:53
disable all GitHub workflows on all repos. with gh CLI
# Get a current list of repos.
gh search repos --limit 1000 @tbnorth | sed 's/\s.*//' | tee repos.list.202510
# Get a list of workflows including repo. names.
< repos.list.202510 xargs -IF bash -c 'echo REPO F ; gh workflow list --repo F' \
| tee workflows.list.202510
# Disable all active workflows.
@tbnorth
tbnorth / README.md
Last active October 2, 2025 19:46
Multi-host execution util.

The script assumes:

a) you have something like defined:

export maindev=maindev
export bkupdev=bkupdev
export mainstg=mainstg
export bkupstg=bkupstg
export mainprod=mainprod
@tbnorth
tbnorth / debranch.py
Last active September 9, 2025 19:32
Clean up merged branches in a repo.
#!/usr/bin/env python3
"""Local repo cleanup"""
import re
import sys
from subprocess import run
specified_permanent = []
for arg in sys.argv:
if arg.startswith("--permanent="):
specified_permanent = arg.split("=", 1)[1].split(",")
@tbnorth
tbnorth / table.hef
Last active May 5, 2025 03:04
Hyperwood table
Hyperwood Exchange Format
Version 1
hyperwood.org
SimpleTable
{"width":14,"depth":23,"height":11}
{"x":0.035,"y":0.016,"z":0.035}
{"width":0.489,"depth":0.3651,"height":0.3842}
4
Leg
Top
@tbnorth
tbnorth / bkup.sh
Last active March 27, 2025 13:51
Backup / log "rotation" keeping more more recent files
TARGET=trilium-data
BKUP_DIR=/home/tbrown02/data/trilium-backup
mkdir -p $BKUP_DIR/cull
OUTFILE=$(date '+%Y-%m-%d-%H-%M-trilium_bkup.tar.xz')
cd ~
nice tar caf $BKUP_DIR/$OUTFILE $TARGET
# After https://unix.stackexchange.com/a/669081/319850
# but using sort to handle multiple bkups per day.
@tbnorth
tbnorth / mkchart.py
Last active December 19, 2024 16:46
drawsvg experiment, draw a fish timeline chart
"""Draw a simple SVG timeline chart with Python."""
import sys
import drawsvg as draw
w = 1200
h = 800
ox = -100
oy = -400
@tbnorth
tbnorth / shell_tricks.md
Created June 17, 2024 21:32
Collection of git / sed / command line tricks

jira tickets referenced between two commits

PROJ=factotum ; git log ^staging dev | sed -E 's/'$PROJ'-[0-9]+/\n&\n/gI' | sed -En '/'$PROJ'-[0-9]+/I p' | tr a-z A-Z | sort -u | sed 's%.*%https://jira.example.com/browse/&%'

@tbnorth
tbnorth / getdeps.md
Last active June 14, 2024 12:21
Get list of actual dependencies for a Python project

If you're requirements.txt file is the output of pip freeze then it's really a lock file, not a list of project dependencies. To get just the actual dependencies:

find . -name \*.py -type f | xargs sed -En '/^(import|from)/ {s/\S+ //; s/ .*//; s/\..*//; p}' | sort -u >reqs

This extracts foo from all import foo.bar... and from foo.bar import... lines, dropping local imports (starting with '.').