Skip to content

Instantly share code, notes, and snippets.

@mmguero
mmguero / pem_passwd.sh
Last active October 20, 2022 21:24
change/set the password of a PEM file
#!/usr/bin/env bash
# change/set the password of a PEM file
# https://gist.github.com/mmguero/6f576e45266ff370732dd7b1e2bf9777
set -e
WORKDIR="$(mktemp -d)"
@mmguero
mmguero / window_dimensions.sh
Last active October 20, 2022 21:19
Get the coordinates of the active window's top-left corner, and the window's size
#!/usr/bin/env bash
# https://gist.github.com/mmguero/4afe9db7d9da60c89b5145a60ba669e8
# Get the coordinates of the active window's
# top-left corner, and the window's size.
# This excludes the window decoration.
unset x y w h
eval $(xwininfo -id $(xdotool getactivewindow) |
sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \
@mmguero
mmguero / screenshot.sh
Created October 20, 2022 21:23
take a screenshot using
#!/usr/bin/env bash
# takes a screenshot of the currently active window
# https://gist.github.com/mmguero/95f62f32b44083913708e0d7929ad134
import -window "$(xdotool getwindowfocus getactivewindow)" ./screenshot-"$(date +%Y%m%d_%H%M%S)".png
@mmguero
mmguero / starship.toml
Last active November 2, 2022 19:48
starship.toml
# see https://starship.rs/config/
# https://gist.github.com/mmguero/730775739384895e84874320c1f9af66
palette = "tlacuache"
format = """
[\ue0b6](fg:machine_info_bg)\
$username\
$hostname\
$localip\
@mmguero
mmguero / playground.md
Created November 4, 2022 13:33
GitHub markdown with reference-style links

markdown-playground

First Header Second Header Third Header
oneone 12 [13]
[21] [twotwo][22] [23]
[31] [32] [three trees][33]
@mmguero
mmguero / settings.json
Created December 22, 2022 20:08
Microsoft Windows Terminal settings for MSYS2's MING64 installed via scoop
{
"commandline": "cmd.exe /c set MSYSTEM=MINGW64 && %USERPROFILE%/scoop/apps/msys2/current/usr/bin/bash --login -i",
"font":
{
"face": "Hack NFM",
"size": 11
},
"guid": "{75529e5d-bde6-4848-85f4-d73c3838a5f5}",
"hidden": false,
"icon": "%USERPROFILE%/scoop/apps/msys2/current/mingw64.ico",
@mmguero
mmguero / picard.txt
Created March 3, 2023 05:25
Picard "Name files like this" the way I like it
$lower($firstalphachar($swapprefix($if2(%albumartist%,%artist%))))/
$swapprefix($if2(%albumartist%,%artist%))/
$if(%albumartist%,%album%/,)
$if2(%albumartist%,%artist%) - $if(%albumartist%,%album%) - $if($gt(%totaldiscs%,1),%discnumber% - )$if($and(%albumartist%,%tracknumber%),$num(%tracknumber%,2) - )$if(%_multiartist%,%artist% - ,)%title%
@mmguero
mmguero / imagedupes.py
Last active April 6, 2023 13:45
run imagededup (https://github.com/idealo/imagededup) on a directory/directories of images
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# run imagededup (https://github.com/idealo/imagededup) on a directory/directories of images
# and write the results as JSON to STDOUT
#
# https://gist.github.com/mmguero/75ddc56f2961e5301bc14e46fbf75119
import argparse
import glob
@mmguero
mmguero / init_storage.sh
Last active May 10, 2023 19:24
init_storage.sh for NFS for Malcolm
#!/bin/bash
if [ -z "$BASH_VERSION" ]; then
echo "Wrong interpreter, please run \"$0\" with bash"
exit 1
fi
ENCODING="utf-8"
RUN_PATH="$(pwd)"
@mmguero
mmguero / srvstat.sh
Last active August 15, 2023 16:43
get first and last lines from systemctl status for all systemd user services
for FILE in ~/.config/systemd/user/*.service; do \
echo "-------- $(basename "$FILE")"; \
( systemctl --user status --no-pager "$(basename "$FILE")" 2>&1 | tee /dev/fd/3 | head -n 3 ) 3> >( tail -n 3 ) ; \
done