Skip to content

Instantly share code, notes, and snippets.

@wallyhall
wallyhall / gist:0f7f45348ea92ad95e8616741344c3d3
Created May 31, 2016 09:48
"The Matrix prank". Confusing your fellow colleagues with a bashrc addition.
#!/bin/bash
RAND=$[ ( $RANDOM % 10 ) + 1 ]
if [ $RAND -ne 1 ]; then
exit
fi
NAME="$(getent passwd $(whoami) | cut -d: -f5 | cut -d" " -f 1)"
MSG="Hello $NAME. The Matrix has you. Follow the white rabbit..."
clear
@wallyhall
wallyhall / gist:d2a36e1d59bc7e1acdce2874bd724e2f
Created July 30, 2018 12:20
/etc/courier/maildroprc for ClamAV and Spamassassin
xfilter "/usr/bin/clamassassin"
if (/^X-Virus-Status: Yes/:h)
{
# Create a Quarantine folder if they've not got one
`[ -d $DEFAULT/.Quarantine ] || (maildirmake -f Quarantine $DEFAULT)`
# Deliver to Quarantine folder
to $DEFAULT/.Quarantine/
}
xfilter "/usr/bin/spamc -f -u $USER -s 5000000"
@wallyhall
wallyhall / gist:95edfce51eb9960c44d367b63c965de7
Created June 16, 2020 14:45
Approximately real free memory on Linux
#!/bin/sh
cat /proc/meminfo | awk 'BEGIN { i=0; } { if ( /^(MemFree|Buffers|Cache): *(\d*)/ ) { i += $2 ; } } END { print i / 1024 / 1024 " GB" }'
@wallyhall
wallyhall / gist:0e1f0a478e1af9f47e51e43bb7748b3c
Created July 30, 2020 11:08
Parallel processing in bash, collecting all resulting STDOUT from children
#!/bin/bash
# trap handler to cleanly shutdown all children if aborted (i.e. ^C is invoked)
function abort {
cd - > /dev/null
# ignore the SIGTERM that is about to be issued
trap '' SIGTERM
echo "Signalling shutdown to all children..."
kill 0
@wallyhall
wallyhall / gist:51cf26b2c7175c9b2cb68bd4ec78310e
Created August 10, 2020 11:10
MySQL resignal and customised error message
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
DECLARE v_error_message VARCHAR(512);
DECLARE v_condition_number INT(1) UNSIGNED;
ROLLBACK;
GET DIAGNOSTICS v_condition_number = NUMBER;
GET DIAGNOSTICS CONDITION v_condition_number v_error_message = MESSAGE_TEXT;
SET v_error_message = CONCAT('Rolledback due to: "', v_error_message, '"');
RESIGNAL SET MESSAGE_TEXT = v_error_message;
@wallyhall
wallyhall / apache_airflow_sso_howto.md
Last active October 26, 2024 18:18
Apache Airflow Azure AAD SSO howto

The following instructions for enabling Azure SSO for Apache Airflow nearly take you all the way - but fall short a couple of details around the configuration of airflow itself:

https://objectpartners.com/2021/12/24/enterprise-auth-for-airflow-azure-ad

All the "Azure" instructions there can be safely followed - the resulting webserver_config.py (which can be injected into a dockerised Airflow in /opt/airflow/webserver_config.py) can be built from the following:

from __future__ import annotations

import os