I have been aware of GitHub Gists for a while, but haven’t used them until now. This post is mainly to see how they work in this WordPress blog. I created a public gist and embedded the URL below.
For a code sample, I picked a short Python script from when I was looking at the secrets module. This script generates a random password with some hard-coded attributes. It starts by getting a 15 character string from token_urlsafe (though the final result is not URL-safe). It then inserts two special characters, chosen at random from a sequence, at random positions in the string. If I want different attributes for the password (such as a different length, or different token) I just edit the script.
Looks like a secret gist can be embedded too, but that sure doesn’t keep it secret:
This code sample is from trying the pytest.raises method.