Skip to content

Instantly share code, notes, and snippets.

@ergosteur
ergosteur / gaminit.sh
Last active May 19, 2024 15:39
bash script to create and switch between multiple domains to use with GAMADV-XTD3. Place in the same directory as your gam executable. (made with copilot assistance)
#!/bin/bash
# Script name: gaminit
#
# This script sets the GAMCFGDIR environment variable to the directory where the script is located,
# appended with a domain name provided as an argument. If the specified domain subdirectory does not exist,
# it prompts the user to confirm if they want the directory to be created.
#
# Does NOT WORK with standard gam, as only GAMADV-XTD3 supports the GAMCFGDIR environment variable!!
#
# If a 'gam' executable is found in the same directory as the script, it adds the directory to the PATH.
@ergosteur
ergosteur / export-volumes.sh
Created April 15, 2024 21:04
Quick and dirty Docker Volume backup/export and restore/import scripts
#!/bin/bash
# Check if backup directory is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <backup_directory>"
exit 1
fi
backup_dir=$1
@ergosteur
ergosteur / Get-VideoDimensions.ps1
Created March 13, 2024 19:15
PowerShell script to get the height and width of video files and add them to the Get-ChildItem object array.
<#
.SYNOPSIS
Script to get the height and width of video files and add them to the Get-ChildItem object array.
.DESCRIPTION
Run the script similar to how Get-ChildItem would be used. Parameters Path, Filter and Recurse are accepted.
Can also filter based on MaxHeight.
Depends on ffprobe being in path in oreder to get video dimensions.
Returns an array of type System.IO.FileSystemInfo.
Example usage:
#!/bin/bash
#
# dockerized-ffmpeg-drop-in
# version 0.3
# https://gist.github.com/ergosteur
# ** Partially AI-generated code via ChatGPT
#
#
# This is a shell script to use dockerized ffmpeg (linuxserver/ffmpeg) as a drop-in replacement for the 'ffmpeg' command
@ergosteur
ergosteur / Enable-OpenSSHServer.ps1
Created June 26, 2023 17:46
Script to enable OpenSSH server on Windows 10+
<#
.SYNOPSIS
This script installs and enables the OpenSSH server service on Windows 10 and 11 client machines.
.DESCRIPTION
This script installs the OpenSSH server service on Windows 10 and 11 client machines, allows it through Windows Firewall, and sets it to start automatically. It also includes an optional section to restrict incoming connections to only RFC1918 IPv4 addresses when a parameter is passed to the script.
.PARAMETER RestrictToRFC1918
When specified, restricts incoming connections to the OpenSSH server to only RFC1918 IPv4 addresses.

Keybase proof

I hereby claim:

  • I am ergosteur on github.
  • I am ergosteur (https://keybase.io/ergosteur) on keybase.
  • I have a public key ASAR_ZUzksDv7ylw4SoC_asfXSg4ANOZe0O4IN6McdwpxQo

To claim this, I am signing this object:

@ergosteur
ergosteur / mount-drive-wsl.bat
Last active June 12, 2023 19:10
Batch script to mount a drive in WSL. Useful for removable devices or other drives that may have been mounted after WSL was already running. Also a companion script to unmount drives from WSL.
@echo off
setlocal enabledelayedexpansion
:prompt_drive
set /P "drive=Please enter the drive letter to mount in WSL: "
:: Validate drive letter
if not "!drive:~1!"=="" (
echo Invalid input. Please enter a single letter.
goto prompt_drive
@ergosteur
ergosteur / pingbeep-enhanced.ps1
Last active June 7, 2023 17:25
Scripts for Windows and Linux/macOS/*nix that continuously pings a given IP or hostname, making a beep for every ping reply and displaying a colored character for every reply or timeout.
<#
.SYNOPSIS
Continuously pings a given IP or hostname, making a beep for every ping reply and displaying a character for every reply or timeout.
.DESCRIPTION
This script continuously pings a given IP or hostname. For every ping reply, it makes a beep sound
(unless the -NoBeep switch is used) and displays a character. For every request timed out, it also
displays a character. The characters used depend on the version of PowerShell being used and whether
the -NoUnicode switch is used: if using PowerShell 6 or newer and -NoUnicode is not used, a green
circle character is displayed for ping replies and a red circle character for timeouts; otherwise,
/**
* Processes emails in a given label in Gmail.
* Can mark emails as read and/or archive them based on the specified action.
* Only processes emails older than the specified number of days.
* Can log the subject of each email it processes if verbose mode is enabled.
*
* @param {string} labelName - The name of the label to process emails in.
* @param {number} days - The number of days old an email must be to be processed.
* @param {number} action - The action to perform on each email (0 = none, 1 = mark as read, 2 = archive, 3 = mark as read and archive).
* @param {boolean} verboseMode - Whether or not to log the subject of each email processed.
# Script to parse cisco IOS running-config.txt to csv file
# Work in progress
# Depends on cisco-config-parser (https://github.com/arezazadeh/cisco_config_parser)
# install with pip install --user cisco-config-parser
# only tested on Python 3.11 on Windows 10
# issues so far:
# - does not handle "add" lines for additional allowed vlans - ie two lines of allowed vlans. I believe this is an upstream issue in the cisco_config_parser library
#
# this script adds a column header "id" at the end of the line.
# the id field can be used to map the imported data to existing interfaces (for example created by device templates)