Skip to content

Instantly share code, notes, and snippets.

View cgoldberg's full-sized avatar
🐢
compiling!

Corey Goldberg cgoldberg

🐢
compiling!
View GitHub Profile
@cgoldberg
cgoldberg / simple_selenium_profiler.py
Last active January 12, 2026 04:15
Python - Simple Selenium Profiler
import sys
import time
from collections import defaultdict
import atexit
from pathlib import Path
import importlib
import pkgutil
import selenium
@cgoldberg
cgoldberg / selenium_js_benchmark.py
Last active January 12, 2026 01:19
Benchmark Selenium script execution: WebDriver Classic vs. BiDi
#!/usr/bin/env python3
"""Benchmark Selenium script execution: WebDriver Classic vs. BiDi"""
import timeit
from selenium import webdriver
NUM = 500
@cgoldberg
cgoldberg / selenium-repo-stats.sh
Created December 31, 2025 16:41
Bash - Selenium - yearly Git activity
#!/usr/bin/env bash
#
# Selenium - yearly Git activity
#
# author: Corey Goldberg (https://github.com/cgoldberg)
# requires:
# - git (https://git-scm.com)
# - git-who (https://github.com/sinclairtarget/git-who)
# - selenium repo (git clone https://github.com/SeleniumHQ/selenium.git)
@cgoldberg
cgoldberg / branches.sh
Last active December 16, 2025 22:37
Bash/Git - show local branches and how far ahead/behind they are from remote/origin
#!/usr/bin/env bash
# show local branches and how far ahead/behind they are from remote/origin
git fetch origin
for branch in $(git branch --format='%(refname:short)'); do
remote_branch="origin/$branch"
if git show-ref --verify --quiet refs/remotes/$remote_branch; then
ahead=$(git rev-list --count $remote_branch..$branch)
behind=$(git rev-list --count $branch..$remote_branch)
@cgoldberg
cgoldberg / README.md
Last active December 5, 2025 20:36
Python SHA512 Benchmark

super simple hash benchmark


  • 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:

@cgoldberg
cgoldberg / sftp.py
Created November 14, 2025 00:14
Python - transferring files with SFTP using paramiko
#!/usr/bin/env python3
#
# transferring files with SFTP
# https://www.paramiko.org
import paramiko
class SFTP:
def __init__(self, host, user, password, port=22):
@cgoldberg
cgoldberg / selenium_chrome_extension.py
Last active November 12, 2025 20:16
Python - load a Chrome extension using Selenium BiDi
# 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
@cgoldberg
cgoldberg / current_year_prs.sh
Created October 28, 2025 13:27
Show GitHub Pull Requests in owner/repo created in the current year
#!/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
@cgoldberg
cgoldberg / selenium-bidi-network-logging.py
Created October 13, 2025 14:26
Python - Selenium BiDi - Network Request Logging
# 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
@cgoldberg
cgoldberg / selenium-logging.py
Last active November 12, 2025 20:18
Python/Selenium - launch Chrome and load a web page with all possible logging enabled
# 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