Skip to content

Instantly share code, notes, and snippets.

View AfroThundr3007730's full-sized avatar
🔧
Hacking all the things...

Eddie Carswell AfroThundr3007730

🔧
Hacking all the things...
View GitHub Profile
@AfroThundr3007730
AfroThundr3007730 / Get-GHRepoList.ps1
Last active March 31, 2024 18:24
Gets a list of repositories of a GitHub user
Set-StrictMode -Version Latest
function Get-GHRepoList {
<# .SYNOPSIS
Gets a list of repositories of a GitHub user. #>
Param(
# User to enumerate
[string]$User,
# Page size to request
[int]$Size = 100
@AfroThundr3007730
AfroThundr3007730 / Update-LocalNugetRepository.ps1
Created June 27, 2023 20:23
Update a local Nuget repo from a remote repo
Set-StrictMode -Version Latest
# Inspired by: https://weblogs.asp.net/jongalloway/downloading-a-local-nuget-repository-with-powershell
function Update-LocalNugetRepository {
<# .SYNOPSIS
Update a local Nuget repo from a remote repo #>
Param(
# Remote repository feed URL
[Uri]$FeedURLBase = 'https://aka.ms/sme-extension-feed',
# Local repository directory
@AfroThundr3007730
AfroThundr3007730 / say.sh
Last active March 31, 2024 14:10
Bash function to log message and print to stdout
#!/bin/bash
# Log message and print to stdout
# shellcheck disable=SC2059
say() {
export TERM=${TERM:=xterm}
if [[ $1 == -h ]]; then
shift; local s=$1; shift
tput setaf 2; printf "$s\\n" "$@"
else
@AfroThundr3007730
AfroThundr3007730 / timer.sh
Last active March 31, 2024 14:10
Bash function to record duration, with concurrent timer support
#!/bin/bash
# Record time duration, concurrent timers
timer() {
[[ $1 =~ ^[0-9]+$ ]] && {
[[ $n -gt $1 ]] || n=$1; local i=$1; shift; }
[[ $1 == -n ]] && { n=$(( n + 1 )); shift; }
[[ $1 == -p ]] && { n=$(( n - 1 )); shift; }
[[ $1 == -c ]] && { local i=$n; shift; }
[[ -n $1 ]] || say -n err 'No timer action specified.'
@AfroThundr3007730
AfroThundr3007730 / note_on_licensing.md
Last active March 30, 2024 23:37
A note on licensing

A note on licensing

Unless otherwise specified, any public code, document, snippet, or file posted on my GitHub profile or Gists page, is released under the GNU GPL, Version 3.0 or later.

I'm not going to necessarily remember to tag all of my files with a license. So in the absense of one, the above statement holds true.

@AfroThundr3007730
AfroThundr3007730 / mc_generate_map.sh
Last active March 30, 2024 23:26
Generates a coordinate grid to move a player to generate a Minecraft map
#!/bin/bash
# Generates a coordinate grid to move a player to generate a Minecraft map
# SPDX-License-Identifier: GPL-3.0-or-later
# Quick n dirty original version:
#for x in $(seq -2500 100 2500); do
# for z in $(seq -2500 100 2500); do
# echo "Cords: $x $z"
# screen -S mc -X stuff "/tp $player $x 128 $z\n"
# sleep 5
@AfroThundr3007730
AfroThundr3007730 / 00-getcert.md
Last active March 30, 2024 23:25
Renews my LetsEncrypt certificates if they expire in less than 3 days.

This gist includes a certificate renewal script, which I use to renew both of my LetsEncrypt certificates, as well as the systemd unit files necessary to automate it. It's currently set to run every 12 hours, and renews the certificates if they expire in less than 3 days. The certbot tool is required in order to use this script. Note that I generated my keys and CSR manually because I needed to add specific extensions to my certificates. That process is not covered here.

Filename Description
01-getcert.sh The certificate renewal script.
02-cli.ini Example Certbot configuration.
03-getcert.timer The systemd timer unit file.
04-getcert.service The systemd service unit file.
05-openssl.conf Example openssl.conf for the CSR
06-getcert-ddns.sh DDNS version of the renewal script.
@AfroThundr3007730
AfroThundr3007730 / xdg_dirs.sh
Last active March 30, 2024 23:20
Profile snippet to redirect $HOME clutter to the proper XDG directory
#!/bin/sh
#/etc/profile.d/xdg_dirs.sh
# SPDX-License-Identifier: GPL-3.0-or-later
###############################################################################
# XDG variables
###############################################################################
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-${HOME}/.cache}"
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}"
export XDG_DATA_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}"
@AfroThundr3007730
AfroThundr3007730 / ddclient.service
Last active March 30, 2024 23:19
Dynamic DNS update wrapper for nsupdate
# /etc/systemd/system/ddclient.service
[Unit]
Description=Dynamic DNS update wrapper for nsupdate
[Service]
Type=simple
Restart=no
ExecStart=/usr/local/sbin/my-ddclient
@AfroThundr3007730
AfroThundr3007730 / dce-dload.sh
Last active March 30, 2024 23:18
Wrapper around DiscordChatExporter for automatic channel media archiving
#!/bin/bash
# Wrapper around DiscordChatExporter for automatic channel media archiving
# SPDX-License-Identifier: GPL-3.0-or-later
dce.set_globals() {
AUTHOR='AfroThundr'
BASENAME="${0##*/}"
MODIFIED='20240304'
VERSION='0.3.1'