- run a loop a half million times:
- split a delimited string into 5 fields
- strip invalid characters from each field with a regex
- calculate a SHA3-512 hash and get the digest for each field (2.5 million hashes)
Environment:
| #!/usr/bin/env python3 | |
| # | |
| # transferring files with SFTP | |
| # https://www.paramiko.org | |
| import paramiko | |
| class SFTP: | |
| def __init__(self, host, user, password, port=22): |
| # load a Chrome extension using Selenium BiDi | |
| import os | |
| from selenium import webdriver | |
| # using unzipped extension in ./extensions/my-extension/ | |
| path = os.path.join(os.getcwd(), "extensions", "my-extension") | |
| options = webdriver.ChromeOptions() | |
| options.enable_bidi = True |
| #!/usr/bin/env bash | |
| # | |
| # Show GitHub Pull Requests in owner/repo created in the current year | |
| # | |
| # usage: current_year_prs.sh <owner> <repo> | |
| # | |
| # requires: jq | |
| set -o pipefail |
| # Selenium BiDi - Network Request Logging | |
| # - launch Chrome | |
| # - add a request handler that logs all HTTP headers from reqests made during page load | |
| # - navigate to a web page | |
| # - remove request handler | |
| # - quit Chrome | |
| import pprint | |
| from selenium import webdriver |
| # launch Chrome and navigate to a web page with all console logging enabled | |
| # - chrome/chromedriver logs go to STDOUT | |
| # - captured driver/performance logs go to STDOUT | |
| # - selenium debug logs go to STDERR | |
| import logging | |
| from subprocess import STDOUT | |
| from selenium import webdriver |
| #!/usr/bin/env bash | |
| # | |
| # Chrome for Testing - install Debian Linux system dependencies | |
| # - visit the CfT Dashboard: https://googlechromelabs.github.io/chrome-for-testing | |
| # - download 'chrome-linux64.zip' for the version you need | |
| # - unzip it and run this script | |
| deps_file="chrome-linux64/deb.deps" | |
| if [ "${EUID}" -ne 0 ]; then |
| #!/usr/bin/env python3 | |
| # | |
| # Copyright (c) 2025 Corey Goldberg (https://github.com/cgoldberg) | |
| # License: MIT | |
| # | |
| # Generate language specific SBOMs from a multi-language monorepo on GitHub | |
| # - fetches repo-wide SBOM from GitHub | |
| # - generates individual SBOMs for each language specified | |
| # | |
| # requires: |
| # Generate a SHA3-512 hash with optional salt | |
| import re | |
| # requires pycryptodome | |
| # - https://pycryptodome.readthedocs.io/en/latest/src/hash/sha3_512.html | |
| from Crypto.Hash import SHA3_512 | |
| def generate_hash(s, salt=None): |
| #!/usr/bin/env python | |
| # | |
| # monkeypatch a method on a class and call the original method from the new one | |
| from functools import partialmethod | |
| class MyClass: | |
| # this is the original method |