Skip to content

Instantly share code, notes, and snippets.

View xenithorb's full-sized avatar

Michael Goodwin xenithorb

View GitHub Profile
@xenithorb
xenithorb / README.md
Last active January 18, 2021 03:16
KeePass 2.x favorite triggers for saving and syncing
  1. If the file %HOME%/Nextcloud/keepass/{DB_NAME}[^1][^2] does not exist, then it exports the db there to create a new file
  2. If the file %HOME%/Nextcloud/keepass/{DB_NAME}[^1][^2] does exist, then it synchronizes the current database with that file

This way you don't have to worry about saving or moving around copies into your synced storage, and the normal sync trigger won't error out on a file that does not exist

The first trigger, Save new if file doesn't exist turns off the following Sync if file exists trigger to avoid a loop, the third trigger turns the sync trigger back on so that on any subsequent saves, it sync to the file as well.

[1]: %HOME% in keepass expands to $HOME on linux - might expand to %HOME% on Windows, too.
[2]: {DB_NAME} in keepass expands to the database's name + extension.

@xenithorb
xenithorb / dtmf_getter.sh
Created April 19, 2017 14:51
Parse freeswitch log for DTMF codes and output a single string
#!/bin/bash
LOGFILE="/var/log/freeswitch/freeswitch.log*"
#LOGFILE="/usr/local/freeswitch/log/freeswitch.log*"
USER="centos"
REMOTE_ADDR="${1:?ERROR: No remote address provided}"
UUID="${2:?ERROR: No UUID provided}"
get_logs() {
"$SUDO" find "${LOGFILE%/*}" -type f -name "${LOGFILE##*/}" ! -empty
@xenithorb
xenithorb / ssh-auth-sock.service
Created April 5, 2017 21:32
systemd user unit: Custom SSH_AUTH_SOCK variable for X11/Wayland (Fedora/GNOME)
# Because setting environment variables is HARD!! (apparently)
# 1. Disable gnome-keyring-ssh, or just allow ExecStartPre to do it:
# $ NAME="gnome-keyring-ssh.desktop"; cat "/etc/xdg/autostart/${NAME}" \
# <(echo "Hidden=true") > "${HOME}/.config/autostart/${NAME}"
# 2. $ mkdir -p ~/.config/systemd/user
# 3. Place this file in ~/.config/systemd/user/ssh-auth-sock.service
# 4. $ systemctl --user enable --now ssh-auth-sock.service
# 5. Logout or reboot.
[Unit]
#!/bin/bash
FILESET_NAME="${1:?ERROR: First argument (fileset name) not provided}"
AND_VERS="7.0"
API_VERS="24"
patch_list=(
"sigspoof-hook-${AND_VERS}"
"sigspoof-core"
"sigspoof-ui-global-${AND_VERS}"
@xenithorb
xenithorb / rpi_enable_watchdog.sh
Last active February 23, 2017 04:23
One-liner to enable Rasbperry Pi 3 watchdog timer
if [[ -c /dev/watchdog ]]; then if [[ -d /etc/systemd ]]; then mkdir /etc/systemd/system.conf.d &>/dev/null; else { echo "ERROR: No systemd"; exit; }; fi; echo -e "[Manager]\nRuntimeWatchdogSec=10\nShutdownWatchdogSec=3min" > /etc/systemd/system.conf.d/watchdog.conf; else { echo "No watchdog device present"; exit; }; fi && systemctl daemon-reload && systemctl daemon-reexec && systemctl show | grep Watchdog
@xenithorb
xenithorb / colortail.sh
Created February 10, 2017 15:51
tail with highlight for matching lines with color
color_tail() { local file="$1"; shift; local awk_cmd="$(count=0; for i in "$@"; do ((count++)); printf '/%s/ {print "\\033[3%sm",$0,"\\033[39m"; next; }\n' "$i" "$count"; done; echo "{ print \$0 }")"; tail -n100 -f "$file" | eval awk \'"${awk_cmd}"\'; }
@xenithorb
xenithorb / fonts.conf
Created January 1, 2017 13:17
fontconfig from laptop ~/.config/fontconfig/fonts.conf
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<edit name="rgba" mode="assign">
<const>bgr</const>
</edit>
</match>
<match target="font">
<edit name="hinting" mode="assign">
@xenithorb
xenithorb / .bashrc
Created December 22, 2016 18:59
List listening ports for a cgroup - bashrc style function
# Find listening ports of a service cgroup
# https://www.redpill-linpro.com/sysadvent/2016/12/22/systemd-at-3am.html
lsof_listen() {
local pids=$( ps -e -o pid,cgroup | awk '$2 ~ /'"$1"'/ { print "-p", $1 }' )
sudo lsof -n -i -a -P ${pids:?ERROR: No PIDs found.}
}
@xenithorb
xenithorb / ssl.inc
Last active December 6, 2016 17:41
Favorite NGINX SSL settings
# Parts configured from recommmendations at:
# https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html and
# https://cipherli.st/
#ssl_trusted_certificate /etc/letsencrypt/live/[ ]/chain.pem;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
#ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_session_cache shared:SSL:10M;
@xenithorb
xenithorb / kmod-signer.sh
Last active November 16, 2021 07:49
Akmod kernel module auto-signer for kernel upgrades on Fedora
#!/bin/bash
#
# /etc/kernel/postinst.d script to sign akmods kmods after kernel upgrade
#
# Author: Michael Goodwin Date: 2016-09-21
# 1. Copy this script to /etc/kernel/postinst.d/ and `chmod +x` it
#
# 2. Create signing keys (store these somewhere useful and safe):
# $ mkdir -p /etc/pki/tls/private/mok