Skip to content

Instantly share code, notes, and snippets.

View DrizzlyOwl's full-sized avatar

Ash Davies DrizzlyOwl

View GitHub Profile
#! /bin/bash
set -e
TZ=Europe/London
TODAY=$(date -Idate)
DATE_90=$(date --date="90 days ago" +"%Y-%m-%d")
SILENT=0
################################################################################
# Author:
@DrizzlyOwl
DrizzlyOwl / afd-domain-scan.sh
Last active February 8, 2024 09:40
Refresh domain validation tokens for AFD Custom Domains
#! /bin/bash
set -e
TODAY=$(date -Idate)
TZ=Europe/London
################################################################################
# Author:
# Ash Davies <@DrizzlyOwl>
# Version:
@DrizzlyOwl
DrizzlyOwl / query-audit-log.sh
Last active July 26, 2023 16:10
Can be used to query SQL Server Audit Logs that exist on a Storage Account to determine which users logged in and how many times in a given time period
#!/bin/bash
set -euo pipefail
# Default values for CLI flags
SERVER=""
DATABASE=""
# Use a Service Principal or an Azure AD user with admin rights for your SQL Server
USERNAME=""
PASSWORD="" # Or use "your_service_principal_client_secret" for Service Principal
@DrizzlyOwl
DrizzlyOwl / az-cmk-enable
Created January 16, 2023 16:43
Create and enable a Customer Managed Key for Azure Storage Account encryption
#! /bin/bash
# Echo usage if something isn't right.
usage() {
echo "Usage: $0"
echo " [-r <resource-group>] Name of the Azure Resource Group"
echo " [-v <keyvault>] Name of the Key Vault that will hold the Customer Managed Key"
echo " [-s <storage-account>] Name of the target Storage Account that needs to have CMK Encryption enabled"
echo " [-k <key-name>] Name of the new CMK"
echo " [-e <email>] Email address of the user-managed identity that can access the Key Vault" 1>&2; exit 1;
@DrizzlyOwl
DrizzlyOwl / .zshrc
Last active October 26, 2022 10:52
# Path to oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="af-magic"
# jbergantine is like toothpaste = good
# eastwood is nice and clean
# flazz is good
# nicoulaj is also good
# steeef is good
# half-life is good
@DrizzlyOwl
DrizzlyOwl / mounty.sh
Created October 26, 2022 10:36
Test whether a Cloudfuse mount is writable. If it isn't then re-mount it.
#! /bin/bash
#
# Author: Ash Davies
# Description: Checks a Cloudfuse mountpoint and reinitialises it if the mount goes missing
#
VOLUME="/path/to/content/uploads"
PROBE="$VOLUME/mounty.probe"
FOLDER="/path/to/cloudfuse/mount/"
@DrizzlyOwl
DrizzlyOwl / rackspace-bill-into-gsheets.gs
Created September 5, 2022 10:43
Import Rackspace Bill into Google sheets using Google App Script
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Rackspace API')
.addItem('Fetch latest billing data','fetchBilling')
.addToUi();
}
function fetchBilling() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
console.log('Task started');
@DrizzlyOwl
DrizzlyOwl / db-migrator.sh
Created April 7, 2022 15:46
Migrate a database from one MySQL host to another
#! /bin/bash
# @author Ash Davies <a.davies@mixd.co.uk>
FROM=$1
TO=$2
FILENAME=wp-config.php
BACKUP_FIRST=yes
TMP=$(mktemp)
# Terminate on any errors
@DrizzlyOwl
DrizzlyOwl / composer.py
Last active January 19, 2022 15:25
Parse composer outdated into a markdown table
import json,sys;
a = json.load(sys.stdin);
packages = a['installed'];
num_packages = len(packages);
are_available_updates = bool(num_packages);
if are_available_updates:
print("There are "+str(num_packages)+" package updates available");
print("\n");
#! /bin/bash
#
# A quick bash script to make it easier for non tech-savvy folks
# to create a vhost conf file and enable it for apache2.
#
# @author Ash Davies <a.davies@mixd.co.uk>
# @version 1.1.0
#
asksure() {