Skip to content

Instantly share code, notes, and snippets.

@jrwarwick
jrwarwick / simple_backup_verification_procedure.sh
Last active July 30, 2023 00:45
Backup verification script
# lets say you are backing up to external media like a usb hardisk drive. once in a while, you should restore the backup to an alternate location and verify and validate the restorability and fidelity of the backup.
# Following a mass file restore from backup to alternate location, perform comparison with original to confirm the backup is good and restorable
#On test restore host:
# zpool create -f tank /dev/sdb
# zpool list
mount /dev/sdc1 /mnt/bup/ #where sdc1 is the device for the external usb hdd you just plugged in
ls /mnt/bup
ls /mnt/bup/originhostname/
ls -lFh /mnt/bup/originhostname/originhostname.garage.zfs
@jrwarwick
jrwarwick / one-liners.sh
Last active October 25, 2023 15:10
Potpourri of handy shell one-liners/gems/nuggets for really specific tasks
# just keep running count of seconds gone by, printing to console periodicially.
# Useful as rough "stopwatch" when you need to prove to your netadmin that your ssh sessions are getting disconnected regularly.
BEGIN=$(date "+%Y%m%d%H%M%S") ; while [ 1=1 ] ; do echo "$(( $(date '+%Y%m%d%H%M%S') - $BEGIN ))" ; sleep 300 ; done
# Quick and dirty terminal-based test of (HTTPS) SSL connectivity and get the cert expiry properties
echo | openssl s_client -showcerts -connect foohost.bardomain.tld:443 | openssl x509 -noout -dates
## Thought: what belongs in here versus .profile as an alias/function?
## Probably anything that you aren't going to call often enough to warrant spending neurons on memroizing even the alias/func name.
## in which case most of what follows should actually go elsewhere.
@jrwarwick
jrwarwick / docker_ports_autolist.py
Last active May 26, 2023 21:57
Docker Container automatic service listing
#Kind of an automatic listing of the services created by the running docker containers
#Like Apache Fancy AutoIndex, but for docker services that have mapped all the way out to host port.
#todo:
# - expand well known services handling / alternative urls
# - loop to automatically refresh
# - error handling
# - pseudo clever service probing to see if we can figure out more about what is actually served up.
# If actually http, then maybe even traverse HTML for title tags and meta decription tags?
# - automatic publishing copy to /var/www/html if it exists?
@jrwarwick
jrwarwick / $HOME
Last active October 26, 2023 19:37
jrwarwick standard home directory configuration file collection
# To deploy this to a newly created user account's home:
cd $HOME
GIST_ID="665715ff3fcdbf4f5b25b32feb8e8410ed37cf47"
curl -Lo github_gist_home.zip https://gist.github.com/jrwarwick/1bc3527e3db7b1a8cb7e5fcf6e916f39/archive/${GIST_ID}.zip
unzip github_gist_home.zip
ls -laFh *-${GIST_ID}/ && mv *-${GIST_ID} nix_home_kit
echo "ok, now something like: cp -i nix_home_kit/.[a-z]* \$HOME/"
@jrwarwick
jrwarwick / AzurePowerFabric-Platform-TaT.md
Last active June 21, 2023 15:48
Various Azure, Fabric, and PowerAutomate (particularly) Techniques - quick reference, snippits, gems, cheatsheet, templates useful for building flows

Though it is ever shifting sands, there seems to be a sort of semi-coalescing within the Azure/Power/Fabric space. It is useful for me to pretend so, at least. Here are a handful of Tips and Techniques that I have found indispensible. Sometimes I'm kind of surprised they aren't built-in. Mostly this was accumulated from a PowerAutomate-into-* point of view, but probably will expand over time.

@jrwarwick
jrwarwick / .screenrc
Last active December 8, 2022 19:48 — forked from ChrisWills/.screenrc-main-example
Yet-Another nice default screenrc
# GNU Screen - main configuration file
# All other .screenrc files should source this file to inherit settings.
# Author: Christian Wills - cwills.sys@gmail.com, minor mods justin.warwick@gmail.com
# Allow bold colors - necessary for some reason
attrcolor b ".I"
# Tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
@jrwarwick
jrwarwick / haversine_distance_oracle.sql
Created December 2, 2022 16:23
Simple Oracle SQL haversine distance calculation
-- Simple Oracle SQL haversine distance.
-- Most likely you will want to put this into a CTE.
-- Not suitable for high-accuracy. Answer will be in km.
-- Still requires sdo for at least the degrees to radians conversion.
SELECT descript, ( /* Approx. Earth radius in km:*/ 6371 * acos(
cos(SDO_UTIL.CONVERT_UNIT(Lat1, 'Degree', 'Radian')) *
cos(SDO_UTIL.CONVERT_UNIT(Lat2, 'Degree', 'Radian')) *
cos(SDO_UTIL.CONVERT_UNIT(Lon2, 'Degree', 'Radian') - SDO_UTIL.CONVERT_UNIT(Lon1, 'Degree', 'Radian') )
+ sin(SDO_UTIL.CONVERT_UNIT(Lat1, 'Degree', 'Radian')) * sin(SDO_UTIL.CONVERT_UNIT(Lat2, 'Degree', 'Radian'))
)) AS haversine_distance
@jrwarwick
jrwarwick / get_build_option_id.sql
Created October 10, 2022 22:06
Oracle APEX PL/SQL API Supplement - Get Build Option component ID by name
create or replace function get_build_option_id(
p_build_option_name IN varchar2,
p_PRIMARY_APPLICATION_ID IN number := 10000
) return number
IS
l_build_option_id number;
BEGIN
select build_option_id into l_build_option_id
from APEX_APPLICATION_BUILD_OPTIONS
@jrwarwick
jrwarwick / log_collector_status_alert.sh
Last active September 23, 2022 21:35
spd-say from crontab + MS log collector failure monitor/notifier
#!/usr/bin/bash
#https://askubuntu.com/a/686944/234023
if [ -z "$XDG_RUNTIME_DIR" ]; then
XDG_RUNTIME_DIR=/run/user/$(id -u)
if [ -d "$XDG_RUNTIME_DIR" ] && [ -w "$XDG_RUNTIME_DIR" ]; then
export XDG_RUNTIME_DIR
else
unset XDG_RUNTIME_DIR
fi
fi
@jrwarwick
jrwarwick / captive_portal_escape.py
Last active September 7, 2022 16:34
Wi-Fi Captive Portal (Automatable) Escape
#!/usr/bin/env ptython
import re
import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin
##optional
import textwrap
from datetime import datetime
"""captive_portal_escape.py: Schedulable automatic-ish escape from a wi-fi "captive portal".