Skip to content

Instantly share code, notes, and snippets.

View bukzor's full-sized avatar
🌥️
learning google cloud

Buck Evan bukzor

🌥️
learning google cloud
  • google.com
  • Appleton, WI
  • 21:22 (UTC -05:00)
View GitHub Profile
@bukzor
bukzor / concurrent_gather.py
Created July 10, 2025 16:52
a half-baked `gather` for `concurrent.futures`
import threading
from concurrent.futures import Future
from typing import TypeVar
T = TypeVar("T")
def gather(*futures: Future[T], return_exceptions=False) -> Future[list[T]]:
if return_exceptions:
raise NotImplementedError("concurrent.futures.gather: can't yet return_exceptions")
@bukzor
bukzor / pytest.log
Created July 1, 2025 19:20
Fixture to catch leaked threads (DI-1008)
$ pytest tests/snuba/api/endpoints/test_organization_trace_meta.py::OrganizationEventsTraceMetaEndpointTest::test_bad_ids -vvvv
=============================== test session starts ================================
platform darwin -- Python 3.13.1, pytest-8.1.2, pluggy-1.5.0 -- /Users/buck/repo/getsentry/sentry/.venv/bin/python3
cachedir: .pytest_cache
metadata: {'Python': '3.13.1', 'Platform': 'macOS-15.5-arm64-arm-64bit-Mach-O', 'Packages': {'pytest': '8.1.2', 'pluggy': '1.5.0'}, 'Plugins': {'fail-slow': '0.3.0', 'time-machine': '2.16.0', 'json-report': '1.5.0', 'metadata': '3.1.1', 'xdist': '3.0.2', 'django': '4.9.0', 'pytest_sentry': '0.3.0', 'anyio': '3.7.1', 'rerunfailures': '15.0', 'cov': '4.0.0'}}
django: version: 5.2.1
rootdir: /Users/buck/repo/getsentry/sentry
configfile: pyproject.toml
plugins: fail-slow-0.3.0, time-machine-2.16.0, json-report-1.5.0, metadata-3.1.1, xdist-3.0.2, django-4.9.0, pytest_sentry-0.3.0, anyio-3.7.1, rerunfailures-15.0, cov-4.0.0
collected 1 item
@bukzor
bukzor / add_decorator.py
Created June 20, 2025 18:02
libcst: prepend a decorator
#!/usr/bin/env python3
"""
usage: add-decorator-cst DECORATOR_NAME FUNCTION_NAME FILE_PATH
Automatically adds a decorator to a Python function's source code,
preserving all comments and formatting.
Requires: pip install libcst
Examples:
@bukzor
bukzor / bq_struct_demo.py
Last active June 11, 2025 18:55
passing an array of struct to bigquery
import json
from dataclasses import dataclass
from datetime import datetime
from typing import Any
from typing import Iterator
from typing import TypeAlias
from google.cloud import bigquery # type:ignore[missingTypeStubs]
Rows: TypeAlias = Iterator[bigquery.Row]
@bukzor
bukzor / skribblio.txt
Last active February 14, 2025 20:46
word list for https://skribbl.io/
3D cube,Abraham Lincoln,Adidas,Africa,Aladdin,Alaska,Albert Einstein,Alice in Wonderland,Amazon Box,Amazon River,America,Android,Angkor Wat,Angry Birds,Antarctica,Apple Logo,Arctic,Audi,Australia,BMW,Baby Yoda,Baltic Sea,Barack Obama,Barney,Batman,Batman Logo,Beethoven,Benjamin Franklin,Big Ben,Bitcoin,Black Sea,Brandenburg Gate,Brazil,Buckingham Palace,Bugs Bunny,Burger King,Canada,Capitol Building,Captain America,Caribbean,Caspian Sea,Charlie Chaplin,China,Christ the Redeemer,Chuck Norris,Cleopatra,Coca Cola,Coffee Mug,Colosseum,Columbus,Cookie Monster,DNA,Da Vinci,Dance Move,Darth Vader,Dead Sea,Discord Logo,Disney Castle,Doge,Dollar Sign,Dominos Pizza,Donald Duck,Dracula,Easter Bunny,Egypt,Eiffel Tower,Elmo,Elvis Presley,Emoji,Empire State Building,English Channel,Facebook,FedEx Truck,Ferrari,Ford,France,Frankenstein,Gandhi,Garfield,George Washington,Germany,Ghostbusters,Godzilla,Golden Gate Bridge,Google,Great Britain,Great Lakes,Great Sphinx,Great Wall of China,Greece,Greenland,Grinch,Grumpy Cat,Harry P
@bukzor
bukzor / workflow-run-times.csv
Last active December 11, 2024 15:52
GitHub GraphQL to retrieve run times for a particular GHA job
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 7.
"name","startedAt","completedAt","conclusion","detailsUrl","duration"
"self-hosted-end-to-end","2024-11-26T15:46:09Z","2024-11-26T16:07:08Z","SUCCESS","https://github.com/getsentry/snuba/actions/runs/12034154894/job/33550021806",1259
"self-hosted-end-to-end","2024-11-26T16:47:29Z","2024-11-26T17:14:01Z","SUCCESS","https://github.com/getsentry/snuba/actions/runs/12035220718/job/33553661370",1592
"self-hosted-end-to-end","2024-11-26T16:48:18Z","2024-11-26T17:12:22Z","SUCCESS","https://github.com/getsentry/snuba/actions/runs/12035235305/job/33553709892",1444
"self-hosted-end-to-end","2024-11-26T16:53:44Z","2024-11-26T17:14:11Z","SUCCESS","https://github.com/getsentry/snuba/actions/runs/12035327143/job/33554017768",1227
"self-hosted-end-to-end","2024-11-26T16:56:25Z","2024-11-26T17:15:59Z","SUCCESS","https://github.com/getsentry/snuba/actions/runs/12035373227/job/33554176510",1174
"self-hosted-end-to-end","2024-11-27T15:27:57Z","2024-11-27T15:56:07Z","SUCCESS","https://github.com/getsentry/snuba/actions/runs/1205
@bukzor
bukzor / README.md
Last active October 25, 2024 19:17
about github merge via rebase

merged via rebase:

https://github.com/getsentry/gha-sandbox.private/pull/5

main            87fa9c42e0a098d7783465d977ec0438bead0f8e
d3'             bbc490e3983dfba36d58a86ced39cee6a4e9ca75    PullRequest.mergeCommit merge_commit_sha
c3'             c7898f8f1b15e7b5f02d14f653b640252dd85936
b3'             30989ccb9095a639544119edeaaa00a0fa889ef1
a3' ed80389ae9d10911b81761e7fa0ab3e9ca194546
@bukzor
bukzor / view_test.py
Created October 4, 2024 17:51
Unit testing for bigquery SQL
#!/usr/bin/env py.test
from __future__ import annotations
import subprocess
from pathlib import Path
from typing import IO
from typing import Iterable
import pandas
from _pytest.python import Metafunc

Why are these wildly different?

WITH
  gocd_events as (
    SELECT * FROM `di-dev-mtr--buck-5.devinfra_metrics.gocd_events`
  )

SELECT *
FROM 
#!/usr/bin/env python3
"""
I attempt to showcase and fix a problem in `urllib.parse.urlunsplit` by fixing it and comparing it to the original.
See `DEMO`, below for results.
TL;DR: It's currently impossible to obtain relative URIs (like `file:selfie.png`) from urlunsplit, but we could fix it.
"""
from urllib.parse import urlsplit, urlunsplit