Skip to content

Instantly share code, notes, and snippets.

View hughdbrown's full-sized avatar

Hugh Brown hughdbrown

View GitHub Profile
@hughdbrown
hughdbrown / slides.md
Created August 10, 2025 19:18
Slide stack in MarkDown for JSON in python
theme title class highlighter drawings transition mdc
default
JSON Mastery for Python Developers
text-center
shiki
enabled
true
slide-left
true
@hughdbrown
hughdbrown / browser-hist.md
Last active July 29, 2025 19:13
PRD for a browser history app for MacOS + Chrome

Rust CLI Tool: Chrome History Searcher for Mac

TL;DR

Mac users often need to search their Chrome browsing history quickly and flexibly from the command line. This Rust CLI tool enables users to search their Chrome history database by date range, page title, or URL domain, with results displayed in the terminal. The tool is designed for privacy-conscious power users, developers, and researchers who want fast, local, and scriptable access to their browsing data.


Goals

@hughdbrown
hughdbrown / truncation.md
Last active March 13, 2025 19:33
Truncating numbers

The problem

So you are interested in rounding a number to its lowest multiple. Let's say you want numbers to be rounded to 10:

>>> for number in range(30):
...     print(f"{number}: {10 * (number // 10)}")
...
0: 0
1: 0
2: 0
@hughdbrown
hughdbrown / setup-aie5.sh
Created February 27, 2025 21:34
Setup AIE5 with upstream/main and origin/main
#!/bin/sh
set -eux -o pipefail
export GIT_USER=hughdbrown
export GIT_REPO_NAME_USER=AIE5 # What the user is going to call the repo
export GIT_REPO_NAME_AI_MAKER=AIE5 # What the repo is already called by AI_MAKER
mkdir -p ~/workspace/${GIT_USER}/maven.com/${GIT_REPO_NAME_USER}
cd ~/workspace/${GIT_USER}/maven.com/${GIT_REPO_NAME_USER}
@hughdbrown
hughdbrown / rust-trust.py
Created February 25, 2025 06:35
Check how many of the job entries on Who Is Hiring? pages are actually 'trust', not 'rust'.
>>> import requests
>>> IDS = {
42919502: "2025-02-01",
42575537: "2025-01-01",
42297424: "2024-12-01",
42017580: "2024-11-01",
41709301: "2024-10-01",
41425910: "2024-09-01",
41129813: "2024-08-01",
40846428: "2024-07-01",
@hughdbrown
hughdbrown / asyncio-local.py
Created February 14, 2025 19:21
Show that asyncio can be run on local files
#!/usr/bin/env python3
import asyncio
from pathlib import Path
async def line_count(filename):
try:
count = filename.read_text(encoding='utf-8').count('\n')
except:
count = -1
@hughdbrown
hughdbrown / w_function.py
Created February 5, 2025 15:27
Lambert's W function
#!/usr/bin/env python3
import math
# from sys import stderr
def w_function_dx(x):
return (x + 1) * math.exp(x)
def w_function(x, x0):
return x * math.exp(x) - x0
@hughdbrown
hughdbrown / random_numbers.py
Last active October 10, 2024 17:25
Test various strategies for creating arrays of random numbers, some with serial dependencies
import os
os.environ["NUMBA_LOOP_VECTORIZE"] = "0"
os.environ["NUMBA_SLP_VECTORIZE"] = "0"
from datetime import datetime
from numba import jit, uint32, uint64
import numpy as np
@hughdbrown
hughdbrown / top_sort.py
Last active August 12, 2024 21:04
Try graphlib.TopologicalSort
>>> from graphlib import TopologicalSorter
>>> data = {"A": ["B", "D"], "B": [], "D": [], "C": ["A"]}
>>> ts = TopologicalSorter(data)
>>> for a in ts.static_order():
... print(a)
...
B
D
A
@hughdbrown
hughdbrown / common-logging.py
Created August 5, 2024 16:03
Common python logging preamble
import logging
FORMAT = '%(asctime)s %(message)s'
logging.basicConfig(
format=FORMAT,
datefmt="%Y-%m-%dT%H:%M:%S",
# logger levels are: DEBUG, INFO, WARNING, ERROR, CRITICAL
level=os.environ.get('LOGLEVEL', 'INFO').upper(),
)
logger = logging.getLogger()