Skip to content

Instantly share code, notes, and snippets.

View shollingsworth's full-sized avatar

Steven Hollingsworth shollingsworth

View GitHub Profile
@shollingsworth
shollingsworth / ldap_search_example.sh
Last active April 5, 2022 23:26
LDAP search example
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# Filter cheatsheet
# https://gist.github.com/jonlabelle/0f8ec20c2474084325a89bc5362008a7
PASSWORD="password"
BN="dc=acme,dc=com"
DN="CN=Joe Smith,OU=Fabrication,OU=Los Angeles,OU=CA,OU=Users,${BN}"
@shollingsworth
shollingsworth / kde_app_notes
Created March 30, 2022 14:46
notes for kde apps and desktop apps
# Custom application *.desktop files are stored here
${HOME}/.local/share/applications
# Default home dir paths in kde
${HOME}/.local/bin:${HOME}/bin:${HOME}/.local/bin:${HOME}/bin
@shollingsworth
shollingsworth / change_inofity.sh
Created March 29, 2022 17:45
change inotify settings
#!/usr/bin/bash
if [[ $(whoami) != "root" ]]; then
echo "You must be root to run this script."
exit 1
fi
echo "----------------------"
echo "Existing settings"
echo "----------------------"
{
"venv" : "/path/to/venv",
"exclude": [
"**/node_modules",
"**/__pycache__",
"**/*.zip"
],
"include": [
"src"
]
@shollingsworth
shollingsworth / find_unsigned_modules.sh
Last active March 31, 2022 16:11
find unsigned modules for current kernel and sign them see https://askubuntu.com/a/988829
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
key="/root/custom_mok.priv"
der="/root/custom_mok.der"
if [[ $(whoami) != "root" ]]; then
echo "This script must be run as root"
exit 1
@shollingsworth
shollingsworth / hibernate_control.sh
Last active March 31, 2022 16:27
disable / enable linux hibernation / sleep settings via systemd
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
usage() {
echo "Usage: $0 <enable|disable>"
exit 1
}
action="${1:-}"
@shollingsworth
shollingsworth / iterjsonfiles.py
Created March 17, 2022 17:29
iterate over json files using a recursive function
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Globbing."""
from pathlib import Path
def _iterfiles(path:Path):
for i in path.iterdir():
if i.is_dir():
yield from _iterfiles(i)
else:
@shollingsworth
shollingsworth / rebootnow.sh
Last active March 16, 2022 01:52
force machine reboot now
# Do not pass go, reboot now
echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
awk -F\' '/menuentry / {print $2}' /boot/grub/grub.cfg
@shollingsworth
shollingsworth / slack_access_logs_parse.py
Created March 3, 2022 20:43
Print out slack access logs ordered by number of instances and first access / latest access from IP
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Print out slack access logs ordered by number of instances and first access / latest access from IP."""
import csv
import sys
from collections import defaultdict
from datetime import datetime
from pathlib import Path
FILE = Path("./access_logs.csv")