Skip to content

Instantly share code, notes, and snippets.

View GuyPaddock's full-sized avatar

Guy Elsmore-Paddock GuyPaddock

View GitHub Profile
@GuyPaddock
GuyPaddock / list_sites.sh
Last active September 11, 2023 16:56
List the installation profile version of all Drupal sites on Pantheon that are tied to the Drupal 7 upstream. (Script authored by ChatGPT 3.5).
#!/bin/bash
# Define the Pantheon upstream ID
UPSTREAM_ID="21e1fada-199c-492b-97bd-0b36b53a9da0"
# Authenticate with Terminus (replace with your authentication method)
# terminus auth:login
# Initialize the CSV output with headers
echo "Site Name,Install Profile Version"
@GuyPaddock
GuyPaddock / azure_ad_stats.sh
Last active May 18, 2023 00:52
Benchmark Azure AD App Proxy using a session cookie acquired from Browser Developer Tools
#!/bin/bash
##
# @file
# A script to benchmark how Azure AD App Proxy performs across multiple
# requests.
#
# If you are using pre-authentication (as you usually will be), before using
# this script, you will need to sign in using your browser and then use
# developer tools to grab your session cookie so you can paste it below.
@GuyPaddock
GuyPaddock / CheckAzureAdAppSecretExpiry.ps1
Last active May 10, 2023 19:53
Use the "Az" PowerShell module to export Azure AD secret expiration dates to CSV.
##
# @file
# Check the expiration dates for all Azure AD App Registration Secrets.
#
# All applications that have secrets that have expired or that will expire in
# the next 60 days are exported to CSV.
#
# Adapted from:
# https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/scripts/powershell-export-apps-with-expriring-secrets
#
@GuyPaddock
GuyPaddock / mount_encrypted_shares.sh
Created May 2, 2023 03:27
Mount encrypted Synology volumes using key files over SSH
#!/usr/bin/env bash
##
# @file
# Mount encrypted Synology shared folders on their NAS over SSH.
#
# As long as key files are being stored securely on the system from which this
# command is being run, this approach offers more security than the
# "Key Manager" functionality native to Synology NASes since it does not store
# the encryption keys for volumes on the NAS device itself. This is because
# Synology uses the same cypher/passphrase on all NASes to decrypt keys stored
@GuyPaddock
GuyPaddock / kube_delete_pv_by_substring.sh
Last active April 21, 2023 03:45
Delete Kubernetes PVs that Match Specific Naming Pattern
#!/usr/bin/env bash
set -uo pipefail
PATTERN="${1}"
kubectl delete pvc $(kubectl get pvc | grep "${PATTERN}" | awk '{ print $1 }')
kubectl delete pv $(kubectl get pv | grep "${PATTERN}" | awk '{ print $1 }')
@GuyPaddock
GuyPaddock / list-issues.sh
Last active January 17, 2023 19:22
Extract Issue Tags from Commit History in a Branch Based Off develop
#!/usr/bin/env bash
##
# @file
# Extracts all of the issue tags in commit messages of a branch_ref and lists them.
#
# Usage:
# list-issues.sh [branch_ref ref] [base branch_ref ref]
#
# - If [branch_ref ref] is not specified, it defaults to "HEAD" (whatever is
@GuyPaddock
GuyPaddock / wistia_starwars.html
Created July 13, 2022 19:45
Wistia's "Star Wars" Terms of Service
<html>
<body>
<iframe src="https://fast.wistia.net/embed/iframe/7epq4bhukx?videoFoam=true" title="Star Wars Terms of Service - July 2022 v2 Video" allow="autoplay; fullscreen" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" msallowfullscreen="" width="633" height="356" data-dashlane-frameid="8008" style="width: 633px; height: 356px;"></iframe>
</body>
</html>
@GuyPaddock
GuyPaddock / cleanup_md.sh
Last active November 7, 2023 20:17
Clean-up Multidevs on Pantheon with Terminus
#!/usr/bin/env bash
set -euo pipefail
if [[ "$#" -eq 0 ]]; then
{
echo "Usage: ${0} <multi-dev 1> [multi-dev 2]... etc."
echo
echo "For example:"
echo " ${0} mr-819 mr-815 mr-814"
@GuyPaddock
GuyPaddock / watchdog.sh
Created April 12, 2022 14:28
Drupal Watchdog Queries via CLI
# BUGBUG: Putting "username" in the field list crashes Drush
terminus drush SITE_ID.ENVIRONMENT watchdog:show -- \
--format=csv \
--count=1000 \
--extended \
--type=taxonomy \
--fields=date,wid,message
@GuyPaddock
GuyPaddock / fpsync.sh
Created March 5, 2022 19:33
Using fpsync to sync two folders
#!/usr/bin/env bash
fpsync -E -vvvv -n 5 /path/to/src /path/to/dest