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 / 1-vscode-cleanup.sh
Last active November 6, 2024 17:15
vscode profile cleanup tasks
#!/bin/bash
# Purge extensions cache
rm -fr /vscode/vscode-server/extensionsCache/* ~/.vscode-server/extensionsCache/*
# Remove older extension versions
find ~/.vscode*/extensions -maxdepth 1 -type d |
awk '{t=gensub(/(.+)-[0-9\.-]+.+/, "\\1", 1); if (t in m) {print $0} else {m[t]++}}' |
xargs -rtl rm -fr
@AfroThundr3007730
AfroThundr3007730 / PS_AutomationNull.md
Last active June 29, 2024 21:59
Using PowerShell's AutomationNull to avoid automatic type conversion

PowerShell Type Conversion and AutomationNull

This all started because I wanted to use [System.IO.FileNotFoundException][1] in a function. Specifically, [this constructor][2], which allows you to set the error message and the file that caused the exception:

public FileNotFoundException (string? message, string? fileName);
@AfroThundr3007730
AfroThundr3007730 / Invoke-AutoCurl.ps1
Last active October 4, 2024 21:38
cURL wrapper to auto resume downloads
function Invoke-AutoCurl {
<# .SYNOPSIS
cURL wrapper to auto resume downloads #>
[Alias('autocurl')]
Param(
[Parameter(Mandatory)]
[Uri]$URL
)
do {
@AfroThundr3007730
AfroThundr3007730 / gpg-agent.ps1
Created April 24, 2024 21:16
powershell start background gpg-agent
[Diagnostics.Process]::Start(
[Diagnostics.ProcessStartInfo]@{
CreateNoWindow = $true
WindowStyle = 'Hidden'
FileName = 'gpg-agent.exe'
Arguments = '--daemon'
}
)
@AfroThundr3007730
AfroThundr3007730 / Rocky_8_STIG_notes.md
Last active November 11, 2024 21:20
Notes on getting Rocky 9 and Ubuntu 24.04 compliant with DISA STIGs

Rocky 8 STIG notes

Red Hat Enterprise Linux 8 Security Technical Implementation Guide :: Version 1, Release: 14 Benchmark Date: 24 Apr 2024

Updated on 2024-07-02

Utilities

All fix and check commands must be run as root.

@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 / utils.common.sh
Last active September 17, 2024 01:45
Collection of utility functions for bash scripts
#!/bin/bash
# Collection of utility functions for bash scripts
# Version 0.6.5 modified 2024-09-09 by AfroThundr
# SPDX-License-Identifier: GPL-3.0-or-later
#
# For issues or updated versions of this script, browse to the following URL:
# https://gist.github.com/AfroThundr3007730/b761bd1a6b2f32a2e97727c7e049e354
# Take caution sourcing this file in your shell, as it uses strict mode.
#----------------------------------------------------------------------#
@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'
@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 / Hide-ConsoleWindow.ps1
Last active October 4, 2024 21:38
Hides a console window (even the new WindowsTerminal.exe)
# Adapted from https://stackoverflow.com/a/74976541/4087397
function Hide-ConsoleWindow() {
# Import 'ShowWindowAsync' method to properly hide windows
Add-Type -Name User32 -Namespace Win32 -MemberDefinition `
'[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
# Mangle the window title to ensure it's unique and allow us to find it
$Host.UI.RawUI.WindowTitle = [Guid]::NewGuid()
# Find our process by the mangled window title and hide it
[Win32.User32]::ShowWindowAsync(
(Get-Process).where{ $_.MainWindowTitle -eq $Host.UI.RawUI.WindowTitle }.MainWindowHandle, 0)