Skip to content

Instantly share code, notes, and snippets.

View obscurerichard's full-sized avatar
🎩
🧐💾🚴‍♂️🌱

Richard Bullington-McGuire obscurerichard

🎩
🧐💾🚴‍♂️🌱
View GitHub Profile
@obscurerichard
obscurerichard / get-sri.sh
Last active November 23, 2024 18:53
Subresource integrity bash scriptlet
#!/usr/bin/env bash
# Adapted from https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
# example code within which appears to be CC0 public domain. Likewise for this work:
# CC0: This work has been marked as dedicated to the public domain.
url=${1:-https://code.jquery.com/jquery-3.6.0.slim.min.js}
algo=${2:-sha384}
hash=$(curl -s "$url" | openssl dgst -"$algo" -binary | openssl base64 -A)
if grep -q css <<<"$url" >/dev/null 2>&1; then
out='<link rel="stylesheet" href="%s" integrity="%s-%s" crossorigin="anonymous">\n'
else
@obscurerichard
obscurerichard / protect-conda-base.sh
Last active December 14, 2024 01:43
Protect the anaconda base environment from accidental installs
# protect-conda-base.sh
#
# If you use Anaconda, it is really easy to accidentally install packages
# into the base environment. Head that off at the pass.
# However, allow installs in a pip virtual environment.
#
# Allow for an override if you run these commands with a CONDA_PROMPT_OVERRIDE variable set,
# as in:
#
# CONDA_PROMPT_OVERRIDE pip install powerline-shell