Skip to content

Instantly share code, notes, and snippets.

View vergenzt's full-sized avatar

Tim Vergenz vergenzt

  • Jacksonville, FL
  • 17:01 (UTC -04:00)
View GitHub Profile

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 November 3, 2023 21:00
GNU parallel - easy JSON processing placeholder via jq expression
--rpl '{[(.*?)]} uq(); $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") or die "Could not open pipe to jq!"; print $jq_in $_; close $jq_in; $_ = do { local $/; <$jq_out> }; chomp; 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
#!/usr/bin/env bash
set -euf -o pipefail # https://sipb.mit.edu/doc/safe-shell/
# https://medium.com/@LihauTan/2f87c770ea9c
find . -name .gitignore \
-exec awk '
FNR==1 { print "\n## " FILENAME } \
FNR==1 { cmd = "dirname " FILENAME; cmd | getline DIRNAME; close(cmd) } \
/^ *#/ { print $0; next } \
/^[^!]/ { print DIRNAME "/" $0 } \
#!/usr/bin/env python3
'''
Parses current directory's git configuration + optional environment vars into a
list of strings suitable for tagging Docker images.
Outputs the computed image name(s) to stdout, separated by newlines.
'''
import os
import re
@vergenzt
vergenzt / aws_op_auto_reauth.sh
Last active May 31, 2022 19:22
aws_op_auto_reauth.sh
#!/usr/bin/env python3
: "${AWS_ADFS_HOST:?}"
: "${AWS_ADFS_REGION:?}"
: "${AWS_ADFS_OP_ITEM_UUID:?}"
# op session expires after 30 minutes of inactivity, so reauth every 25 minutes by default
: "${AUTH_INTERVAL:=+25 minutes}"
@vergenzt
vergenzt / parse_database_url.py
Created April 14, 2022 13:56
parse_database_url.py
#!/usr/bin/env python3
import argparse, os, shlex, subprocess, sys
from typing import Dict, List
from urllib.parse import ParseResult, urlparse, unquote, parse_qs
def _envvar_vals(url: ParseResult) -> Dict[str, str]:
path: List[str] = url.path.strip('/').split('/')
vals_from_url = {
@vergenzt
vergenzt / csvsplit.sh
Last active February 12, 2020 21:39
Split a large CSV file into chunks of rows when fields may contain newlines (i.e. can't do naive line-based split)
# uses Mac OSX `osascript` for convenience
# depends on `coreutils` and `csvkit`
ROWS_PER_FILE=20000
FILE="$(osascript -e 'POSIX path of (choose file with prompt "Choose combined CSV file")')"
if [ -z "$FILE" ]; then exit; fi
BASE="$(basename "$FILE" | cut -d. -f1)"
cd "$(dirname "$FILE")"
@vergenzt
vergenzt / fetch_outreach_emails_and_calls.rb
Last active March 5, 2020 16:45
Fetch Outreach call and email data
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "json_api_client"
gem "oauth2"
gem "faraday_middleware-oauth2_refresh"
end
require "yaml"