Skip to content

Instantly share code, notes, and snippets.

View mshafer1's full-sized avatar

MakerByNight mshafer1

View GitHub Profile
@mshafer1
mshafer1 / _setup_crypt_enroll.sh
Last active June 16, 2025 01:23
Setup Ubuntu Server to auto-decrypt disk on boot using tpm 2
#!/bin/bash
# based on https://askubuntu.com/a/1543666
set -euo pipefail
apt-get update
apt-get install -y tpm2-initramfs-tool
if [ -z "$FDE_PASS" ]; then
echo "Error: Muss hand down current crypt password using FDE_PASS env var" 2>&1;
exit 1;
@mshafer1
mshafer1 / clean_contacts_lists.py
Last active August 10, 2025 12:16
Cleanup a vcf file with extraneous phone numbers that are invalid
import argparse
import contextlib
import sys
import pathlib
import re
import tempfile
def _exception(msg: str):
print(msg)
input("Press enter to close...")
import os
import pathlib
import sys
import pdf2image
# based on https://www.geeksforgeeks.org/convert-pdf-to-image-using-python/
if len(sys.argv) < 2:
print(f"Usage: {sys.argv[0]} file_to_convert.pdf")
input("Press enter to continue...")
@mshafer1
mshafer1 / install-windows-updates.ps1
Created March 21, 2025 11:24
New Windows bootstrap tools
param (
[switch]$setup = $false
)
function installRequirements {
# Install the PSWindowsUpdate module
Install-Module -Name PSWindowsUpdate -Force -AllowClobber
}
@mshafer1
mshafer1 / run_updates.sh
Created February 4, 2025 02:46
Apt Run updates and reboot if needed
set -e
echo Running updates
date
apt-get update
apt-get upgrade -y
if test -f /var/run/reboot-required; then
echo Requires reboot
reboot
fi
echo finished
@mshafer1
mshafer1 / README.md
Last active January 30, 2025 02:47
mshafer1 Desktop Root CA certificate

!!READ BEFORE CONTINUING!!

What does installing a root certificate mean?

It means that you trust the author/holder of the cert to:

  • only publish code/tools signed with it that they have written or verified.
  • protect the private-key portion to prevent others from using it

Installing a root certificate means that you trust the author/owner completely because any code they publish that is signed with that cert, will be allowed to run on your computer

@mshafer1
mshafer1 / launch.json
Created November 23, 2024 15:37
Basic vscode config files
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
@mshafer1
mshafer1 / fail2ban-all-status
Created December 9, 2023 14:44
fail2ban list all jail status'
#!/bin/bash
fail2ban-client status | grep "list" | cut -d":" -f2 | sed -e 's;\s\s*; ;g' | cut -d',' --output-delimiter=$'\n' -f1- | xargs -n 1 fail2ban-client status
@mshafer1
mshafer1 / setup_mshafer1.sh
Last active January 4, 2025 16:10
Bash script to setup user mshafer1 with ssh key
set -e
new_user=mshafer1
useradd -m --shell /bin/bash $new_user
usermod -aG sudo $new_user
mkdir -p /home/${new_user}/.ssh
echo ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtFQ2u7P/f3/tKt8dRAkiQr9+P1kVvpLzCPTuaMonMCc4UQvinIc8/DbQRN1xrOqPsa3QVJ4CQirPLsHoOwDskM/ff2iXAq/rsjPdTK7OYaECNO89nk2mcv/C2xuEu8V/Ib8zMhoaZ5aWN4fTaxhZffuU2XqXadwKT7UZjuD+vEQxXpMxzFDruZdebYdAJTNStzXQFZtOfJqZtMEi2tcXdUjIyDPao63aJmfasxM45j0vEv4JnH0dyxJON3muhX/TnDwdKNPHGkOO3NGEKYOTDPU9tzwMfL3vqfS3skQ+HUEPHz1p0E/jJ4rZzugymj/K54CRijp4URyRmGTzl/EkZ mshafer1_do >> /home/${new_user}/.ssh/authorized_keys
@mshafer1
mshafer1 / password.py
Last active May 22, 2025 02:26
Python script to gen passwords
import argparse
import secrets
import string
import sys
import pathlib
_SCRIPT_DIR = pathlib.Path(__file__).parent
_WORDS_FILE = _SCRIPT_DIR / "words.txt"
def _password_length_type(x):