Skip to content

Instantly share code, notes, and snippets.

View matsest's full-sized avatar

Mats Estensen matsest

View GitHub Profile
@matsest
matsest / .bashrc
Last active May 31, 2023 14:14
VimEscapeEverything
## Add this to your .bash_rc / .zshrc
# Alias for vim-style exit in Bash/Zsh
alias :q=exit
@matsest
matsest / networkranges.ps1
Last active June 27, 2023 14:54
Sorting IP address spaces with PowerShell
# Define ranges
$NetworkRanges = @(
'10.11.0.0/24'
'10.11.1.0/24'
'10.11.12.0/24'
'10.11.24.0/24'
'10.11.2.0/24'
)
# Bad - does not sort according to address spaces, only alphanumerical :(
@matsest
matsest / clean-snaps.sh
Created January 31, 2024 08:36
Clean old Snap revisions
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
@matsest
matsest / go-update.sh
Last active May 31, 2024 12:50
Update golang
#!/bin/bash
# Check privileges
if [[ "$(id -u)" -ne 0 ]]
then echo Please run this script as root or using sudo!
exit
fi
# Print current version
export PATH="${PATH}:/usr/local/go/bin"