Skip to content

Instantly share code, notes, and snippets.

@asokolsky
asokolsky / cleanup-worktrees.sh
Created September 8, 2026 08:45
cleanup-worktrees.sh — remove clean, merged Git worktrees. Dry run by default; --apply removes only worktrees whose exact HEAD is provably preserved by a normal or squash merge (GitHub/GitLab). Zsh.
#!/usr/bin/env zsh
# Remove clean, merged Git worktrees beneath ~/PersonalProjects/.worktrees.
# The default mode is a read-only dry run.
# Pass --apply to
# - remove worktrees and
# - their local branches and
# - exact sibling .review.md files, then
# - remove unregistered candidate trees that contain only directories, and
# - remove any top-level repository directory left completely empty.
@asokolsky
asokolsky / find_process_using_secure_input.py
Created August 4, 2026 00:41
find_process_using_secure_input.py
#!/usr/bin/env python
"""
If macOS detects that you're typing sensitive data (e.g. a password), it prevents
other apps from reading keystrokes. This is normally a good thing, but it's mildly
annoying if you use an app like TextExpander, and macOS doesn't notice that it's
no longer using Secure Input. Then your keyboard shortcuts stop working!
This script will print a list of processes that have Secure Input enabled, e.g.:
The following processes are using Secure Input:
@asokolsky
asokolsky / gist:024bf272f89e4700afc1da6f1336dcdc
Created April 17, 2026 23:37
List all the persistent resources in an AWS account
#!/usr/bin/env bash
#
# List all the persistent resources in an AWS account
# $1 - AWS profile name to use
#
# Exit on error. Append "|| true" if you expect an error.
set -o errexit
# Exit on error inside any functions or subshells.
set -o errtrace
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
"""
Launch a process alongside with the caller.
Supply input to that process and read outputs,
rinse and repeat.
Sample usage:
with ProcessSession(['.venv/bin/python3', '-m', 'simultons']) as session:
cmd = 'set debug true'
while not session.wait(0.1):
stdout, stderr = session.consume_outputs(cmd)
What are the main categories into which Kubernetes monitoring is divided?
- infra
- orchestration & control
- application
Which of the following are potential trouble indicators for pod conditions that the K8s Analyzer examines?
- pod status failed
- pod status pending
- pod status unknown
@asokolsky
asokolsky / urldecode
Created June 5, 2024 21:30
one-liner to do url-decoding
echo -n "%21%20" | python3 -c "import sys; from urllib.parse import unquote; print(unquote(sys.stdin.read()));"