Skip to content

Instantly share code, notes, and snippets.

View vergenzt's full-sized avatar

Tim Vergenz vergenzt

  • Jacksonville, FL
  • 20:20 (UTC -04:00)
View GitHub Profile
#!/usr/bin/env -S uv run --no-project --script
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "dbt-core==1.11.6",
# "dbt-databricks==1.11.6",
# ]
# ///
@vergenzt
vergenzt / partial_parse_repro.py
Created March 2, 2026 19:05
Failure to load partial_parse.msgpack: `int is not allowed for map key when strict_map_key=True`
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "dbt-core==1.11.6",
# "dbt-postgres==1.10.0",
# ]
# ///
Script started on Mon Dec 29 13:38:19 2025
Command: bash -x -c git diff --no-index rules-$(git rev-parse HEAD) rules-$(git rev-parse main)
++ git rev-parse HEAD
++ git rev-parse main
+ git diff --no-index rules-8f8e5fde9d2e269e8769e7d7d2e9ba8fdb5f1e75 rules-ebf08ba869eb979d28812bfa4f20aa1844f0e07d
[?1h= [?1l>
Command exit status: 0
Script done on Mon Dec 29 13:38:19 2025
type JsonVal = bool | int | float | str | None | dict[str, JsonVal] | list[JsonVal]
def escape_jinja_in_leaf_strs(val: JsonVal) -> JsonVal:
"""
Escape Jinja template markers in leaf strings.
Assuming that any strings at leaf nodes of the given JSON object, sanitize them so that:
(a) Jinja processing doesn't fail, and
(b) the result after such processing is equivalent to the input `val`.
@vergenzt
vergenzt / dbt-exposure-sync
Created November 18, 2025 16:56
wip dbt exposure <-> databricks dashboard sync script
#!/usr/bin/env python
"""
Manage databricks dashboards with dbt exposure metadata; sync changes up or down.
"""
from functools import cached_property, lru_cache
import json
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from dataclasses import dataclass
from enum import Enum
@vergenzt
vergenzt / Abbreviate "Product Backlog Item" -> "PBI".user.js
Created September 29, 2025 14:46
Userscript: Abbreviate "Product Backlog Item" -> "PBI" in Azure DevOps
// ==UserScript==
// @name Abbreviate "Product Backlog Item" -> "PBI"
// @match https://dev.azure.com/*
// ==/UserScript==
window.addEventListener("load", () => {
document.title = document.title.replace("Product Backlog Item", "PBI");
});
@vergenzt
vergenzt / update_head_revision_file.py
Created March 24, 2025 15:10
Fast Python script to write Alembic heads to file (for git conflicts on multiple heads)
#!/usr/bin/env python3
import ast
import os
import sys
from argparse import ArgumentParser, FileType
from collections import defaultdict
from configparser import ConfigParser
from graphlib import TopologicalSorter
from subprocess import check_call, check_output
from typing import Any, Iterable, Iterator, Tuple
@vergenzt
vergenzt / update_head_revision_file.py
Last active November 13, 2024 19:46
Python script to write alembic migration head(s) to head_revision.txt file
#!/usr/bin/env python3
import ast
import os
import sys
from collections import defaultdict
from graphlib import TopologicalSorter
from pathlib import Path
from subprocess import check_call, check_output
from typing import Any, Iterable, Iterator, Tuple, Union
@vergenzt
vergenzt / py-requirements-to-json
Last active May 7, 2024 18:30
Parse Python requirements files into AST JSON representation via tree-sitter-requirements
#!/usr/bin/env pip-run
"""
Parse Python requirements files into AST JSON representation
"""
# /// script
# dependencies = ['tree-sitter-requirements']
# ///
import json

If you have a command line that can generate a result, and you want to test whether successive results are statistically indepenent of each other, you can use the following:

seq <N_TESTS> \
| parallel -n0 <COMMAND...> \
| uniq -c \
| awk '{ NR%2 ? n1+=$1 : n2+=$1 } END { print NR, n1, n2 }' \
| python -c 'from statistics import NormalDist as N; import math; n_runs, n1, n2 = map(int, input().split()); n = n1+n2; μ=1.0*(2*n1*n2)/n + 1; σ=math.sqrt(1.0*(μ-1)*(μ-2)/(n-1)); Z = (n_runs-μ)/σ; p = N().cdf(-abs(Z)); p_two_tailed = p*2; print(); print(*list(vars().items())[-9:], sep="\n")'