Skip to content

Instantly share code, notes, and snippets.

View gingerbeardman's full-sized avatar

Matt Sephton gingerbeardman

View GitHub Profile
@gingerbeardman
gingerbeardman / csv2md.sh
Created June 3, 2025 22:59
TSV/CSV to Markdown table
pbpaste | tr "," ";" | tr "\t" ',' | csvtomd -p 0 | sed 's/&/\&/g' | sed 's/|/ | /g' | sed 's/ */ /g; s/^ *//; s/ *$//' | sed 's/^/| /; s/$/ |/' | tr ';' ','
@gingerbeardman
gingerbeardman / dismiss_notifications.sh
Created June 1, 2025 19:20
Dismiss all notifications
osascript -e '
tell application "System Events"
tell process "NotificationCenter"
if not (window "Notification Center" exists) then return
set alertGroups to groups of first UI element of first scroll area of first group of window "Notification Center"
repeat with aGroup in alertGroups
try
perform (first action of aGroup whose name contains "Close" or name contains "Clear")
on error errMsg
log errMsg
@gingerbeardman
gingerbeardman / deark-pict.sh
Last active April 16, 2025 22:54
decompress .tar and .tar.gz then run a 2-pass deark on all resulting files to extract all PICT and keep only the resulting PNG
#!/usr/bin/env zsh
# Check if source folder is provided
if [ -z "$1" ]; then
echo "Usage: $0 <source_folder>"
exit 1
fi
SOURCE_DIR="$1"
DEST_DIR="${SOURCE_DIR}_extracted"
@gingerbeardman
gingerbeardman / vector-auto-download.js
Created April 1, 2025 12:43
Automatically redirects to download page and clicks the download button, for temporary use
// Redirect to file download at Vector.co.jp
if (window.location.host === 'www.vector.co.jp' && window.location.pathname.startsWith('/soft/')) {
// Extract file ID by removing non-numeric characters
const fileId = window.location.href.replace(/\D/g, '');
// Construct new URL with file ID
window.location.href = `https://www.vector.co.jp/download/file/mac/game/fh${fileId}.html`;
}
// Auto-click the first link in #summary section on Vector.co.jp download pages
@gingerbeardman
gingerbeardman / image_compare.sh
Last active April 16, 2025 23:25
Compares all images in a directory, doesn't check the same pair twice, duplicates are opened in Preview
#!/usr/bin/env zsh
# Threshold for similarity
THRESHOLD=0.05
# Get a sorted list of PNG files, using null-terminated strings to handle special characters
files=()
while IFS= read -r -d '' file; do
files+=("$file")
done < <(find . -maxdepth 1 -type f -name "*.png" -print0 | sort -z)
@gingerbeardman
gingerbeardman / image_tag.sh
Last active April 1, 2025 13:38
Applies different macOS Finder colours to images of specific sizes
#!/usr/bin/env zsh
# Function to tag files with specified dimensions and color
tag_dimension_files() {
local width="$1"
local height="$2"
local color="$3"
# Color label mapping
local label_index
@gingerbeardman
gingerbeardman / volumes.60s.sh
Last active February 25, 2025 13:51
xbar/bitbar shell script to list and clean and eject (unmount using option) volumes as a replacement for CleanMyDrive
#!/bin/zsh
# <bitbar.title>Volume Manager</bitbar.title>
# <bitbar.version>250225</bitbar.version>
# <bitbar.author>Matt Sephton</bitbar.author>
# <bitbar.author.github>gingerbeardman</bitbar.author.github>
# <bitbar.desc>Lists and manages mounted user volumes</bitbar.desc>
# <bitbar.dependencies>zsh</bitbar.dependencies>
# <bitbar.abouturl>https://gist.github.com/gingerbeardman/610f22180117ad20465d7c529cc5faa0</bitbar.abouturl>
setopt EXTENDED_GLOB
@gingerbeardman
gingerbeardman / jp2pdf.sh
Created February 3, 2025 21:26
Convert folder full of jp2 images into PDF, parallel across 8 CPU cores
find . -name "*.jp2" | parallel -j 8 sips -s format pdf -s formatOptions 75 --resampleHeight 1536 {} --out ../pdf/{.}.pdf
@gingerbeardman
gingerbeardman / cone.scad
Last active January 12, 2025 07:40
Traffic cone with shadow in OpenSCAD
// Animation settings
$vpr = [45,0,-90];
$vpt = [0,0,05];
$vpd = 250;
// Colors
shade = [0.5,0.5,0.45,1];
orange = [1.0,0.5,0.0,1];
black = [0.2,0.2,0.2,1];
white = [0.9,0.9,0.9,1];
@gingerbeardman
gingerbeardman / access_control.sh
Created January 7, 2025 20:21
Access control and permissions
#!/bin/bash
# Create the directory if it doesn't exist
sudo mkdir -p /var/log/caddy
# Set ownership to caddy user and group
sudo chown caddy:caddy /var/log/caddy
# Set appropriate permissions (755 for directory)
sudo chmod 755 /var/log/caddy