Skip to content

Instantly share code, notes, and snippets.

View vergenzt's full-sized avatar

Tim Vergenz vergenzt

  • Jacksonville, FL
  • 07:38 (UTC -05:00)
View GitHub Profile
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")'
@vergenzt
vergenzt / jwt-future-iat-should-not-be-rejected.md
Last active December 14, 2023 01:18
Discussion: JWT tokens containing `iat` values in the future should not be rejected

Previous discussion elsewhere on Github

Comments by me

Y'all this was litigated previously at #190. The JWT spec does NOT say to reject tokens with iat ("issued at") in the future, so this behavior goes beyond the spec and is inconsistent with many other JWT libraries.

4.1.6. "iat" (Issued At) Claim The "iat" (issued at) claim identifies the time at which the JWT was

@vergenzt
vergenzt / .parallelrc
Last active October 10, 2024 15:42
GNU parallel - easy JSON processing placeholder via jq expression
--rpl '{[(.*?)]} $Global::use{"IPC::Open2"} ||= eval "use IPC::Open2; 1;"; my $jq = open2(my $jq_out, my $jq_in, "jq", "-Rrc", "[ try(fromjson) // . | $$1 | tostring | \@sh] | join(\" \")") or die "Could not open pipe to jq!"; print $jq_in $_; close $jq_in; $_ = <$jq_out>; chomp $_; uq(); waitpid $jq, 0; $? && die'
!include _header.puml
group #lightblue "Parse phase"
dbt -> project ++: //read all yaml and SQL files//
return
rnote right of dbt #white: Evalute config
rnote right of dbt #white
Evalute ""generate_schema_name""
on all nodes to determine