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 / split_music_compilation.sh
Created September 14, 2022 05:50
Splits an audio file based on timestamps in a cuesheet
#!/bin/bash
# Splits an audio file based on timestamps in a cuesheet
split_music_compilation() {
[[ -f $1 ]] || { echo 'Audio file not found:' "$1"; return 1; }
[[ -f $2 ]] || { echo 'Cuesheet file not found:' "$2"; return 1; }
local source=$1 cuesheet=$2 count=0 pstamp='0:00' stamp title album
while read -r line; do
[[ $line =~ ([0-9]+:[0-9]+:[0-9]+).-.(.*).\[(.*)\] ]] && {
stamp=${BASH_REMATCH[1]}
title=${BASH_REMATCH[2]}
@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 / Get-SMSManagementPoint.ps1
Last active March 31, 2024 18:24
Finds SCCM management point in AD based on site code
function Get-SMSManagementPoint {
<# .SYNOPSIS
Finds SCCM management point based on site code #>
Param(
# The site code to search
[Parameter(Mandatory)]
[string]$SiteCode
)
return [adsisearcher]::new(
@AfroThundr3007730
AfroThundr3007730 / wg-auto.sh
Created June 17, 2022 00:40
Wrapper and service to start and stop wireguard interfaces
#!/bin/bash
# Wrapper to start and stop wireguard interfaces
wg_start() {
echo "Setting up Wireguard interface $2..."
ipv4=$(awk '$1 ~ /Address/ && $3 ~ /\./ {print $3}' /etc/wireguard/"${2}".conf)
ipv6=$(awk '$1 ~ /Address/ && $3 ~ /:/ {print $3}' /etc/wireguard/"${2}".conf)
ip link add dev "$2" type wireguard
[[ -n $ipv4 ]] && ip addr add dev "$2" "$ipv4"
[[ -n $ipv6 ]] && ip addr add dev "$2" "$ipv6"
@AfroThundr3007730
AfroThundr3007730 / HelperFunctions.psm1
Last active April 7, 2024 22:16
Collection of helpful bash and powershell functions (most are in my other gists).
# Last updated 20240331 by AfroThundr
# SPDX-License-Identifier: GPL-3.0-or-later
Set-StrictMode -Version Latest
#region Internal Variables
$DefaultPSProfileContent = @'
# Note: This profile stub is automatically overwritten, make changes instead in profile_local.ps1
# Always use strict mode
Set-StrictMode -Version Latest
@AfroThundr3007730
AfroThundr3007730 / Get-StringPermutations.ps1
Last active March 31, 2024 19:45
Gets recursive unique combinations of characters in a string
function Get-StringPermutations {
<# .SYNOPSIS
Calculates the permutations of an input string #>
[Alias('permutate')]
Param(
# String to calculate permutations from
[Parameter(Mandatory)]
[String]$String,
# Return only unique permutations
[Parameter()]
@AfroThundr3007730
AfroThundr3007730 / Get-SSLServerCertificate.ps1
Last active March 31, 2024 18:25
Powershell function similar to openssl -s_client to retrieve a certificate
function Get-SSLServerCertificate {
<# .SYNOPSIS
Retrieves the X509 certificate by connecting to a SSL enabled server #>
[Alias('s_client')]
Param(
# Hostname or IP address to connect to
[Parameter(Mandatory)]
[String]$Hostname,
# Port to connect to
[Parameter()]
@AfroThundr3007730
AfroThundr3007730 / unicode_btoa_atob.js
Created July 4, 2021 02:28
Unicode string to base64 (wrapper for btoa and atob)
"use strict"
const u_btoa = str => btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (_match, pl) => String.fromCharCode('0x' + pl)))
const u_atob = str => decodeURIComponent(atob(str).split('').map(c => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)).join(''))
@AfroThundr3007730
AfroThundr3007730 / SignScript.ps1
Last active March 31, 2024 18:25
Wrapper to Set-AuthenticodeSignature
function Set-ScriptSignature {
<# .SYNOPSIS
Wrapper function to sign and timestamp a script file #>
[Alias('SignScript')]
Param(
# The script file to sign
[Parameter(Mandatory)]
[String]$ScriptFile
)
@AfroThundr3007730
AfroThundr3007730 / Get-RunningTasks.ps1
Created March 25, 2021 20:31
Get a running list of active VITasks
function Get-RunningTasks() {
while ((Get-Task | Where-Object { $_.state -eq 'running' }).count -gt 0) {
Get-Task | Where-Object { $_.state -eq 'running' } |
Sort-Object name, percentcomplete |
Format-Table Name, State, PercentComplete, StartTime,
@{ L = 'Target'; E = { $_.ExtensionData.Info.EntityName } },
@{ L = 'Initiator'; E = { $_.ExtensionData.Info.Reason.UserName } }
Start-Sleep 10
}
}