Skip to content

Instantly share code, notes, and snippets.

View jsleeio's full-sized avatar

John Slee jsleeio

View GitHub Profile
@jsleeio
jsleeio / openbsd-release-downloader.sh
Created December 24, 2023 04:15
OpenBSD release, syspatch and snapshot downloader script
#!/bin/ksh
## downloads OpenBSD releases, snapshots and syspatches, and verifies them
## with signify(1). Files are downloaded to /var/www/htdocs/OpenBSD/... per
## the standard mirror layout, so that you can use them as an installurl.
##
## I use this to retrieve sets for building VMs.
##
## upstream mirror is selected from /etc/installurl.
##
@jsleeio
jsleeio / WHISPERER.md
Last active April 14, 2023 07:12
macOS whisperer

what is this?

Applescript gadget that politely saves volume/mute settings, unmutes, sets volume very low, whispers some text provided on the commandline (the first CLI argument only) then politely restores the volume/mute settings. Polite!

Don't install this to unattended MacBooks. Definitely don't make it run as a cron job...

howto

@jsleeio
jsleeio / diff-last-two-reads.sh
Last active December 26, 2022 19:57
macOS scripted configuration with 'defaults'
#!/bin/bash
### @jsleeio, 2022
###
### diff the last two sets of defaults data dumped with read-all-domains.sh
function _die() {
echo "FATAL: $*" >&2
exit 1
}
@jsleeio
jsleeio / docker-login-ecr.bash
Created November 28, 2021 02:38
automatic Docker login to ECR via AWS configuration data
docker-login-ecr() {
local ecr_account_profile=${ECR_ACCOUNT_PROFILE:-utility}
local ecr_region
local ecr_account_id
ecr_account_id="$(aws configure get "$ecr_account_profile.role_arn" | awk -F: '{ print $5 }')"
if [[ -z "$ecr_account_id" ]] ; then
return 1
fi
ecr_region=$(aws configure get "$ecr_account_profile.region")
if [[ -z "$ecr_region" ]] ; then
@jsleeio
jsleeio / quantized-sleep.go
Created January 23, 2020 13:32
sleep until a quantized time, implemented in both Bourne shell and Go
package main
import (
"flag"
"fmt"
"time"
)
func main() {
multiple := flag.Duration("multiple", 5*time.Minute, "sleep until the next integer multiple of this time")
@jsleeio
jsleeio / eagle-run-cam-job.sh
Last active July 13, 2019 02:59
Run Autodesk EAGLE 9.x CAM jobs from commandline
#!/bin/bash
set -e
set -o pipefail
_die() {
echo "eagle-run-cam-job.sh: FATAL: $*" >&2
exit 1
}
@jsleeio
jsleeio / certsplit.sh
Created October 20, 2018 08:29
shell script to rip apart CA certificate bundles for inspection/mangling
#!/usr/bin/env ksh
# intended for ripping apart CA certificate bundles
set -e -u
_usage() {
echo "usage: $0 [-a MODE] inputfile.pem"
echo ""
echo "Available modes are:"
@jsleeio
jsleeio / select-random-reels.sh
Last active June 8, 2019 21:05
Prepare random sets of Make Noise Morphagene reels for copying to SD card
#!/bin/bash
### given a folder full of Morphagene-suitable audio files, select 32
### at random and make a directory full of hardlinks(!!) to them, ready
### for copying to an SD card. Also generates an index file so you can
### trace back to the original filenames.
# macOS and GNU both seem to have sort -R for randomizing. You may need to
# adjust if using some other implementation
@jsleeio
jsleeio / wallpaper.sh
Created February 4, 2016 23:29
set OSX wallpaper (Mavericks+ only)
## found on stackoverflow somewhere
function wallpaper() {
sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '$1'" && killall Dock
}
@jsleeio
jsleeio / akamai-curl.sh
Created January 8, 2016 03:32
curl wrapper for Akamai debugging
#!/bin/sh
usage() {
echo "usage: $0 [-s] [-v] [-L] [-h HTTPHOST] [-X HTTPMETHOD] URL"
exit 1
}
args=`getopt svLX:h: $*`
if [ $? != 0 ] ; then
usage