Skip to content

Instantly share code, notes, and snippets.

View andrew-stclair's full-sized avatar

Andrew St Clair andrew-stclair

View GitHub Profile
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGWXbFMBEADAcCiOGQDOlVFUkoyNX4P7jJHZ4AMaHXKKfuG5gv92KbLBvGfU
sG1R+i32h6rmtyMpIjp4vLLxOAPfYIuGdaY30ChVTvRH9m+hP2Ky5sB+LJSrwX9j
Jgeh3H4TRm2EqslnY/84HyxxGJRIySebOLi15/O2vROdneTzVItNeaS3J2XQvDaW
HJkGLd99IK/bYQnyzCaiTDcvmwQ7bkJUr7ezrOaZmA15X6jyJEs6UAxsBNsv3780
pljDxnZ52u0yItMW//ejw5k/vsKuqBGEv4IiXsbQfLZwnjA1x2VDGZ2a9s4MZRjM
JkI1TcYC64psPB01A2RcRXZTDdma7LV5VNHAtMFxdeFt12HKb2096734jYqP6Stg
erJF/RcBNir/GK92mzu4fdxO4rDPGy5bliDofsmuA3x3LV4sfK/eoO3hv9Q5Cd+F
5vFxA3RN3KjD79QhjSyD5us9nSuEg5MBDHsWTGm6jXXNONPSA+/pKwqwgyVvzP8K
#!/bin/sh
gpg --dearmor -o /etc/apt/trusted.gpg.d/andrew-stclair-keyring.gpg << EndOfMessage
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGWXbFMBEADAcCiOGQDOlVFUkoyNX4P7jJHZ4AMaHXKKfuG5gv92KbLBvGfU
sG1R+i32h6rmtyMpIjp4vLLxOAPfYIuGdaY30ChVTvRH9m+hP2Ky5sB+LJSrwX9j
Jgeh3H4TRm2EqslnY/84HyxxGJRIySebOLi15/O2vROdneTzVItNeaS3J2XQvDaW
HJkGLd99IK/bYQnyzCaiTDcvmwQ7bkJUr7ezrOaZmA15X6jyJEs6UAxsBNsv3780
pljDxnZ52u0yItMW//ejw5k/vsKuqBGEv4IiXsbQfLZwnjA1x2VDGZ2a9s4MZRjM
@andrew-stclair
andrew-stclair / export-manual.sh
Last active July 5, 2024 02:20
Export the Linux Manual to /opt/man in pdf format
#!/bin/bash
echo "Installing required software"
apt-get update
apt-get install groff man manpages manpages-dev -y
echo "Creating output directory if it does not exist"
SEARCH_DIR="/usr/share/man/"
OUT_DIR="/opt/man"
mkdir -p $OUT_DIR

RTTTL Ringtones

Sea Shanty 2

Sea Shanty 2: d=16,o=5,b=100: 16a, 16p, 16e, 16d, 8c#, 16p, 16c#, 16d, 16e, 16f#, 16g#, 8e, 8p, 16f#, 16p, 16e, 16d, 16c#, 16p, 16c#, 16p, 16b4, 16p, 16c#, 16p, 8d, p

@andrew-stclair
andrew-stclair / test_random.py
Last active August 10, 2023 06:46
WIP Python Script to check the random devices
"""Randomness Validator"""
# How many bytes to read
BYTES_READ = 50000000
# Devices to check
DEVICES = [
"/dev/random",
"/dev/urandom"
]

Automating Ubuntu Pro

I dont garantee these will always work, nor are they a good way of achieving some level of automation for ubuntu pro, but they worked at time of writing.

Run commands when ubuntu pro is activated

Checks if the output of the pro status command contains the string "Valid until"

# If Ubuntu Pro is Activated
@andrew-stclair
andrew-stclair / README.md
Last active March 31, 2023 05:09
LUKS Encrypted Disks scripts

LUKS Encrypted disks scripts

The following are scripts that can help with the use of LUKS encrypted disks, though they are very rudementry and require sudo.

The onlt script you will need is the crypt-format script, it's what creates the encrypted partition or file, the others just mount and unmount, which gnome can do on it's own (Other might be able to as well, but i have tested gnome)

Usage

Optional: Create mountable image

@andrew-stclair
andrew-stclair / gpg-ssh-auth.md
Last active February 28, 2023 23:34
Use a GPG key for SSH authentication

Use a GPG key for SSH authentication

These steps have been tested on MacOS. Linux should be similar if not the same. Good luck on Windows

Why would i do this?

  • If you are already using a GPG key to sign git commits or packages, it's one less key to securely backup.
  • GPG keys can be stored on OpenPGP Smart Cards like the YubiKey

Create a GPG key

@andrew-stclair
andrew-stclair / prompt.py
Last active October 31, 2022 04:17
Python Prompt - An example of a prompt like program in python, this does not use the match function from Python 3.10
# Variables
storage = {
'prompt': "❯",
'username': "root",
'hostname': "ubuntu"
}
# Default 'command not found' command
def h_noop(_):
@andrew-stclair
andrew-stclair / ShellShort.md
Last active January 10, 2023 00:20
Shell short hand

Bash short hand

systemctl start service-{a,b}.service would be equivalent to systemctl start service-a.service service-b.service

systemctl start srv-{1..4}.service would be equivalent to systemctl start srv-1.service srv-2.service srv-3.service srv-4.service

If for example you had multiple wireguard services and wanted to enable both the service and path for each

systemctl enable wg{0..3}.{service,path} would be equivalent to systemctl enable wg0.service wg0.path wg1.service etc...