Skip to content

Instantly share code, notes, and snippets.

View hall757's full-sized avatar
🌎
Consuming oxygen... unless this is a simulation!

Randy Hall hall757

🌎
Consuming oxygen... unless this is a simulation!
View GitHub Profile
@hall757
hall757 / parse_yaml.sh
Created September 13, 2023 19:24
parse yaml file into bash env vars
#!/bin/bash
function parse_yaml {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\):|\1|" \
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
@hall757
hall757 / s3_clean_path.sh
Created September 12, 2023 20:50
Remove folder objects from S3 bucket so that when files are removed, the containing folders disappear when empty.
#!/bin/bash
# $1 - BUCKET - The S3 bucket to scan
# $2 - PATH_TO_CLEAN - The base path to clean. This will
# select only subfolders of this path. No leading
# or trailing slash.
# $3 - DEPTH_TO_KEEP - The number of levels of folders
# to exclude from PATH_TO_CLEAN. All folder objects
# below this level will be removed. If files still
# exist in the folder, the folder will remain visable.
@hall757
hall757 / gist:19e5a0006198362db81d52cf24eb84e2
Created February 4, 2018 20:28
Enable Apple Superdrive on Google PIxelbook dev mode
# From my .bashrc
# Thanks to https://github.com/onmomo/superdrive-enabler
SDE=/usr/local/sbin/superdriveEnabler
if [ ! -f $SDE ]; then
curl -s -o $SDE https://raw.githubusercontent.com/onmomo/superdrive-enabler/master/dist/x86_64/superdriveEnabler_x86_64
chmod a+x $SDE
fi
SDERULES=/etc/udev/rules.d/99-superdrive.rules
if [ -f $SDE ]&&[ ! -f $SDERULES ]; then