This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
[[ $1 == start && ! -b /dev/mapper/$2 ]] && { | |
[[ -d /sys/module/kvdo ]] || modprobe kvdo | |
target=$(readlink -f $(awk -v dev=$2 '$1~dev && $4~"vdo" {print $6}' /etc/dmsetup.table)) | |
[[ $target =~ /dev/dm- ]] && target=$(find /dev/mapper -type l -lname "*${target##*/}") | |
table=$(awk -v dev=$2 -v target=$target '$1~dev && $4~"vdo" {sub($1FS,""); sub($5,target); print $0}' /etc/dmsetup.table) | |
echo dmsetup create $2 --table "$table" | |
[[ -b /dev/mapper/$2 ]] || exit 1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Parses chatterino logs to get stream income from bits and subscriptions | |
get_stream_stats() { | |
local f=${1##*/}; f=${f%.*} | |
printf 'Channel: %s Date: %s\n' "${f%%-*}" "${f#*-}" | |
awk '/[Cc]heer/ { | |
for (i = 1; i <= NF; i++) { | |
if ($i ~ /^[Cc]heer$/) { | |
j = i + 1 | |
token = $i $j |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Resolve-DnsRecordAllDCs { | |
<# .SYNOPSIS | |
Resolves a DNS record on all active DCs in a domain #> | |
[Alias('nslookup_all')] | |
Param( | |
# Name to resolve | |
[Parameter(Mandatory, ValueFromPipeline)] | |
[string]$Name, | |
# Type of record | |
[Parameter(ValueFromPipelineByPropertyName)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Generates a coordinate grid to move a player and generate a Minecraft map | |
# Can run commands live via screen or RCON, or generate a command list | |
# 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/a3a01297705d65ed8c327539b5a55c46 | |
# Dependencies: screen python3(rcon) journalctl tail pkill |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Last updated 20240913 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()] |