Skip to content

Instantly share code, notes, and snippets.

@green-leader
green-leader / backupwatch.sh
Last active July 5, 2023 18:33
Watch a set of directories to notify if they have not changed
#!/bin/bash
# Check if array is started
ls /mnt/disk[1-9]* 1>/dev/null 2>/dev/null
if ! ls /mnt/disk[1-9]*
then
echo "ERROR: Array must be started before using this script"
exit
fi
@green-leader
green-leader / tailproxy.sh
Created May 23, 2023 14:56
acts as a proxy command for ssh. A DNS server could return an incorrect subnet when a domain name is used. This will look up the the tailscale IP which the servers with ssh are listening on
#!/bin/bash
set -e
set -u
set -o pipefail
readonly INCOMING_HOST=$1
readonly INCOMING_PORT=$2
readonly SEARCH_DOMAIN=$3
# HOST=$(echo "$INCOMING_HOST" | sed -e "s/$SEARCH_DOMAIN//")
HOST="${INCOMING_HOST//$SEARCH_DOMAIN/''}"
@green-leader
green-leader / Borg_Exclude
Created October 22, 2022 20:40
Backup Exclusion list
sh:**/node_modules/**
sh:**/.android/avd/**
sh:**/.android/build-cache/**
sh:**/.eve/**
sh:**/.gradle/caches/**
sh:**/.config/discord/Cache/**
sh:**/.config/google-chrome/**
sh:**/.local/share/Steam/**
sh:**/.steam/**
#!/usr/bin/env bash
# oneliner to copy and paste for installation
# pre-commit hook to check code
# cp python-pre-commit.sh .git/hooks/
# If any command fails, exit immediately with that command's exit status
set -eo pipefail
# Run flake8 against all code in the `source_code` directory
# flake8 . --exclude="./venv/*"
@green-leader
green-leader / config.json
Last active October 12, 2023 09:56
Config For spotify Playlist Generator
{
"song_origin": [
"Goblincore Mix",
"Arabic Trap",
"Nasty Bits"
]
,"filter_show": [
"spotify:show:4xQ4HKZjIg04Phtj2gaTbi",
"spotify:show:5GcTIDkgnB9wP6CmUyOSqa",
"spotify:show:6z4NLXyHPga1UmSJsPK7G1",
@green-leader
green-leader / code.sh
Last active May 15, 2023 18:00 — forked from lucidhacker/code.sh
Obsidian Sync Code
# update and upgrade installed packages
apt update && apt upgrade
# install cronie and termux-services
pkg install cronie termux-services
# enable the crond service
sv-enable crond
# install and enable vim
@green-leader
green-leader / TownNames.py
Last active December 24, 2022 17:54
Generate reasonable town names
#!/usr/bin/env python3
import random
defPrefixes = ["Ahn\'", "Ains", "Al", "Alb", "Ald", "Alla", "Alt", "Alta", "Amar", "Amber", "Amyr", "Ander", "Anti", "Apple", "Ar", "Arbor", "Ard", "Arrow", "Ash", "Ashen", "Asta", "Auburn", "Aura", "Aus", "Autumn", "Ava", "Avon", "Back", "Bad", "Bain", "Bal", "Bal\'", "Bald", "Baldr", "Baldur", "Bane", "Baron", "Barron", "Barrow", "Basalt", "Beach", "Bear", "Bedd", "Beech", "Bell", "Beetle", "Bele", "Beryl", "Big", "Birch", "Bitter", "Black", "Blade", "Blue", "Bog", "Bone", "Border", "Boulder", "Brav", "Break", "Breeze", "Briar", "Bridge", "Brier", "Bright", "Brim", "Bronze", "Buck", "Bug", "Burn", "By", "Cael", "Caer", "Carn", "Cassel", "Caster", "Castle", "Cedar", "Chamber", "Cherry", "Cheyd", "Chill", "Cinder", "Clam", "Clay", "Cloud", "Cobble", "Cold", "Con", "Condor", "Corner", "Crab", "Crag", "Craw", "Crow", "Crown", "Crystal", "Cumber", "Dag", "Dagger", "Dark", "Dart", "Dawn", "Daven", "Day", "Dead", "Deep", "Demon", "Destin", "Devil", "Dire", "Do\'", "Dorn", "Do
@green-leader
green-leader / reboot-into-windows
Created March 28, 2021 14:31
Allows setting the target of a reboot to Window making dual booting more convenient
#!/bin/bash
# reference: https://rastating.github.io/creating-a-reboot-into-windows-button-in-ubuntu/
set -e
# ensure running as root
if [ "$(id -u)" != "0" ]; then
exec sudo "$0" "$@"
fi
target=$(grep -i windows /boot/grub/grub.cfg | cut -d "'" -f 2)
echo $target
@green-leader
green-leader / volume_mgmt.sh
Last active April 18, 2021 14:27
doctl scripting to add a volume onto a droplet then remove it minimal error checking
#!/bin/bash
set -o errexit
set -o xtrace
set -o nounset
set -o pipefail
VOLUMENAME="tempvolume"
DROPLET_ID=$(curl -s http://169.254.169.254/metadata/v1/id)
REGION=$(curl -s http://169.254.169.254/metadata/v1/region)
@green-leader
green-leader / twitchmirror.sh
Last active February 21, 2020 20:53
TwitchtoYoutube
#!/bin/bash
set -x
date +%R
function cmdCheck () {
command -v $1 >/dev/null 2>&1 || { echo >&2 "I require $1 but it's not installed. Aborting."; exit 1; }
}
#cmdCheck youtube-dl
cmdCheck ffmpeg
#cmdCheck youtube-upload