Skip to content

Instantly share code, notes, and snippets.

View bmatthewshea's full-sized avatar

Brady Shea bmatthewshea

View GitHub Profile
bmatthewshea / myip.bash
Last active June 16, 2024 19:50
Show public IP and other info from simple bash script or alias
printf "Gateway:\n"; route | grep "^default" | cut -d " " -f 10
# captures ipv4 loopback/lo and primary lan interface, normally - adjust as needed:
printf "Private:\n"; ip -4 -o ad | grep "brd "| cut -d " " -f 7
# You do not need dig/nslookup for this to work (no dnsutils packages needed):
printf "Public:\n"; host -4 -t a | grep " has"| cut -d " " -f 4
# Instructions:
# Put this file in your path. (It does not need the ".bash" file extension.)
# Set permissions (example): `chmod 755 ~/scripts/myip`
# Run it.
bmatthewshea /
Last active March 9, 2024 16:34
Commands needed to upgrade RPI Raspbian/Debian System

Upgrade "Raspbian" Bullseye to Bookworm

(should work for any upgrade if you update release names)


sudo apt-get update
sudo apt-get upgrade
sudo apt-get full-upgrade
# Update the 2 individual files yourself, or run this:

sudo sed -i -e 's/bullseye/bookworm/g' /etc/apt/sources.list /etc/apt/sources.list.d/raspi.list

bmatthewshea /
Last active March 15, 2024 19:21
Add gpg key for Debian/Ubuntu repo - New format

apt-key add (key) is deprecated

On Debian Bookworm when running apt-key add.

NOTE: RSPAMD is only used as an example. This method should work for any deprecated install instructions for apt-key.

While executing:
wget -O- | apt-key add -

The following is observed:

"Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details."

bmatthewshea /
Last active October 2, 2023 00:14
When Do I Go Back Online? (Capture a combined ping/grep reply in a variable)
# Brady M. Shea - 23SEP2023
# For a StackOverflow answer (
# Original link:
# Variables/command subs
sleepy=60 # PING every SLEEPY seconds. 1 minute recommended. # can be Should be a name based host. Not an IP.
bmatthewshea /
Last active August 7, 2023 14:28
pflogsumm cron.daily script
# Save this script as:
# `/etc/cron.daily/pflogsumm`
# It should be owned by root.
# Then set permissions: `sudo chmod 755 /etc/cron.daily/pflogsumm`
# the script will also run directly if you wish to test it.
# Brady Shea 31Jul2023
test -x /usr/sbin/pflogsumm || exit 0
bmatthewshea / get-product-key.ps1
Last active December 21, 2022 16:13
PowerShell script to calculate current "ProductKey"
### "get-product-key.ps1":
### (updated from
### To allow this script to run, execute one of these in admin PS:
### Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
### or
### Set-ExecutionPolicy RemoteSigned
### And then execute the following:
bmatthewshea / check-restart-windows-service.ps1
Last active September 20, 2022 15:45
Query and restart a Windows service as needed. (PowerShell)
Script: "check-restart-windows-service.ps1"
Query and restart service as needed.
Use task scheduler with this script.
Brady M. Shea - 16 Sep 2022
.Setting $ServiceName
.Find the service name to monitor by opening a PS command prompt and entering "GET-SERVICE"
bmatthewshea /
Last active June 25, 2024 13:22
Debian/Ubuntu - CERTBOT without SNAP/SNAPD

CERTBOT - Install using Python PIP

Install Certbot using Python PIP (Package Installer for Python) - without using SNAP, APT or SYSTEMD. (Debian/Ubuntu)

This guide will help you install LetsEncrypt / Certbot using venv PIP under Debian/Ubuntu.

  • This guide has been tested up to Debian 12 / Bookworm.
bmatthewshea /
Last active August 17, 2021 18:42
Collatz Conjecture (Python Example)
# Collatz Conjecture:
# x → x/2 (if x is even)
# x → 3x + 1 (if x is odd)
import sys, time
# Default seed if no arguments given
seed = 27
bmatthewshea /
Last active August 5, 2021 02:55
Python script that does checks on apex domains from a text file. Checks status for bare apex / "www." subdomains and ssl / non-ssl. (4 checks on each domain). Outputs in CSV format.
# -*- coding: utf-8 -*-
## Brady Shea - 04AUG2021 - (Python 3 script)
## This will read in a file list of plain APEX domains like:
## ""
## If you want it in a file just pipe the script to a file.
## python3 -u ./ | tee ./domain-check.csv
import requests