Skip to content

Instantly share code, notes, and snippets.

@wojas
wojas / README.md
Created November 13, 2025 13:46
macOS sound volume limiter for Hammerspoon

(The following description and code is generated by ChatGPT)

Here’s a drop-in volume limiter for Hammerspoon (open source macOS automation app using Lua) that enforces per-output-device max volume, and automatically follows the active output device.

Paste this into ~/.hammerspoon/init.lua (or a separate file and require it), then edit the config table at the top.

(see file below)

How to use

@wojas
wojas / Dockerfile
Created October 30, 2025 15:01
Create a container with godu to inspect what is included in your docker context
FROM golang:1.20-alpine
ENV GOBIN /usr/local/bin
RUN go install github.com/viktomas/godu@latest
COPY / /context
WORKDIR /context
CMD ["/usr/local/bin/godu", "-l", "1", "/context"]
@wojas
wojas / docker-ps-architectures.sh
Created September 2, 2022 06:52
Check which docker containers are running under qemu emulation on macOS
#!/bin/bash
# https://stackoverflow.com/questions/66834864/how-to-determine-when-docker-containers-on-an-m1-macbook-are-running-via-qemu
#for i in `docker ps --format "{{.Image}}"` ; do
# docker image inspect $i --format "$i -> {{.Architecture}} : {{.Os}}"
#done
OPT=$@
set -euo pipefail
docker container ls $OPT --format "{{.ID}}\t{{.Image}}\t{{.Command}}\t{{.Status}}\t{{.Names}}" |
@wojas
wojas / gitlab-runner-docker.sh
Created August 25, 2022 07:09
Run the Gitlab runner locally in Docker (tested on macOS)
#!/bin/sh
# Based on https://stackoverflow.com/a/65920577/297793
# Manually start this first:
## docker run -d \
## --name gitlab-runner \
## --restart always \
## -v "$HOME:$HOME" \
## -v /var/run/docker.sock:/var/run/docker.sock \
## gitlab/gitlab-runner:latest
@wojas
wojas / CMakeLists.txt
Last active May 19, 2020 14:54
Quick and dirty example of how to wrap a callback registration
cmake_minimum_required(VERSION 3.16)
project(luac C)
set(CMAKE_C_STANDARD 11)
find_package(PkgConfig REQUIRED)
pkg_search_module(LUA REQUIRED IMPORTED_TARGET luajit luajit2)
add_executable(retval retval.c)
target_link_libraries(retval PUBLIC PkgConfig::LUA)
@wojas
wojas / kubelog.py
Last active April 2, 2020 09:12
Tool to quickly select and view Kubernetes container logs using fzf (screenshot below in comments)
#!/usr/bin/env python3
"""
kubelog is a tool that lists all pods and their contains using fzf
and prints the logs for the selected one.
Options to get fzf:
- https://github.com/junegunn/fzf
- brew install fzf
"""
@wojas
wojas / git-switch-branch.sh
Created May 24, 2019 13:22
Script to visually select a recent git branch to switch to
#!/bin/bash
# Script to visually select a recent git branch to switch to
# Requires https://github.com/junegunn/fzf (brew install fzf)
branches () {
git for-each-ref --sort=-committerdate refs/heads/ | sed 's|.*refs/heads/||' | head -30
}
branch=$(branches | fzf --no-sort --layout=reverse)
@wojas
wojas / note.sh
Created November 22, 2018 07:05
I replaced nvALT for note taking with this short shell script and fzf
#!/usr/bin/env bash
# When called with a name, open a specific note.
# When called without a name, use fzf to interactively search notes.
# (fzf: https://github.com/junegunn/fzf)
set -e
cd ~/path/to/my/notes/
export EDITOR=nvim
@wojas
wojas / btrfs-subvolume-usage.py
Created April 27, 2017 17:00
Get btrfs subvolume disk usage sorted by incremental size
#!/usr/bin/env python3
# NOTE: btrfs quota must be enabled for this to work:
# btrfs quota enable /btrfs/
import os
import sys
usage = {}
for line in os.popen('btrfs qgroup show / --raw', 'r'):
# 0/10784 15678980096 557056
if not line.startswith('0/'):
@wojas
wojas / prefix.sh
Last active April 6, 2022 02:52
Prefix shell command output with a colored string (supports stderr)
#!/bin/bash
raw_prefix="$1"
prefix_width=${PREFIX_WIDTH:-20}
color=color_${PREFIX_COLOR:-green}
error_color=color_${PREFIX_ERROR_COLOR:-red}
shift 1
if [ "$raw_prefix" = "" ]; then
echo "USAGE: $0 <prefix> <command> [args..]"