Skip to content

Instantly share code, notes, and snippets.

@mikej312
mikej312 / bandcamp.md
Last active May 21, 2025 23:34
"Fixing" Bandcamp names

The archives are named <artist> - <album>.zip. After extracting into a folder with the same name, less the extension, I want to remove the artist name. Also, if " - " appears in the album title I only want to remove the first instance after the artist name:

Rename the folders: ls -d */ | awk -F'#' '{orig = $0; sub(/ - /, "#"); system("mv \"" orig "\" \"" $2 "\"")}'

The sound files are named <artist> - <album> - <track number> <track name>. I like to the tracks to follow the format <track number> - <track name>:

Rename the files: ls | grep flac | awk '{idx = match($0, " - [0-9][0-9]"); title = substr($0, idx + 3); sub(/ /, " - ", title); system("mv \"" $0 "\" \"" title "\"")}'

@mikej312
mikej312 / checksums.md
Last active August 11, 2020 18:34
Create a file of checksums for the files in a directory

find ****** -type f -exec sha256sum {} ; > checksums.sha256

#!/bin/sh
#
# OpenBSD Memory Plugin for Nagios
#
# The original verion of ths cscript was found here:
# https://exchange.nagios.org/directory/Plugins/Operating-Systems/BSD/OpenBSD/OpenBSD-Memory/details
#
# Updated the way the memory values are collected since top now outputs values in gigabytes
#
# Copyright 2008 - [email protected]
@mikej312
mikej312 / openvpn.md
Created July 3, 2020 00:21
Associate usernames with IP addresses of OpenVPN clients

Tested on an OpenBSD system using OpenVPN LDAP authentication:

sed -n '/Virtual/,/GLOBAL/{//!p;}' /var/log/openvpn-status.log | awk -F'[,:]' '{print $3}' | while read -r r; do echo -n $r; fgrep $r /var/log/openvpn | fgrep -m 1 username | awk -F\' '{ print " - " $2}' ; done

@mikej312
mikej312 / vnc-password.md
Last active July 3, 2020 00:22
Ubuntu 18.04 schreen sharing (VNC) password retrieval

To retrieve the Ubuntu screen sharing (VNC) password:

  • gsettings get org.gnome.Vino vnc-password

Note: this returns a Base64 encoded value