Skip to content

Instantly share code, notes, and snippets.

View dixonwhitmire's full-sized avatar

Dixon Whitmire dixonwhitmire

View GitHub Profile
@dixonwhitmire
dixonwhitmire / main.go
Last active September 12, 2025 21:29
A Go timer example which does a bit of database comparisons for a project at work. Names of things have been changed.
package main
import (
"context"
"errors"
"flag"
"fmt"
"log"
"os"
"os/exec"
@dixonwhitmire
dixonwhitmire / run-tests.sh
Created July 7, 2025 13:54
Data Base Revision Harness (PostgreSQL)
#!/usr/bin/env bash
set -euo pipefail
source .env
export PGHOST=localhost
export PGDATABASE=my_db
export PGUSER=dbuser
export PGPASSWORD=${POSTGRES_PASSWORD}
for sql in tests/*_test.sql; do
mock_message = MagicMock()
mock_message.data = generate_mock_data()
mock_receive_messages = MagicMock()
mock_receive_messages.return_value.__aiter__.return_value = [(mock_receiver_client, mock_message)]
mock_async_messaging_client.receive_messages = mock_receive_messages
@dixonwhitmire
dixonwhitmire / logconfig.go
Created October 11, 2024 14:27
Configures Go Structured Logging
// Package logconfig initializes a default application structured logger.
package logconfig
import (
"log/slog"
"os"
)
const (
ErrorKey = "err"
@dixonwhitmire
dixonwhitmire / assert_test.go
Created September 11, 2024 13:56
Go assertion helpers
package someapp
import (
"errors"
"github.com/google/go-cmp/cmp"
"reflect"
"testing"
)
// AssertEqual evaluates two equivalent types to see if a difference exists.
@dixonwhitmire
dixonwhitmire / retry.go
Created June 14, 2024 02:36
retry io functions in golang
// Package retry supports retrying operations supported within the [RetryOperation] type set.
package retry
import (
"fmt"
"log/slog"
"os"
"time"
)
@dixonwhitmire
dixonwhitmire / csvmain.py
Created August 31, 2023 12:34
Print CSV Stats/Info To stdout
import csv
import sys
def print_csv_stats(file_path: str):
"""Parses a CSV file and prints some info to stdout, including:
- row count
- column count
- duplicate column count
- populated column count
@dixonwhitmire
dixonwhitmire / logging.yaml
Created August 29, 2023 19:18
Python Logging Config
version: 1
disable_existing_loggers: false
handlers:
console:
class: logging.StreamHandler
formatter: json
stream: ext://sys.stdout
formatters:
json:
'()': pythonjsonlogger.jsonlogger.JsonFormatter
@dixonwhitmire
dixonwhitmire / __init__.py
Created May 27, 2023 02:48
Python __init__.py for tests/resources
import os
# base resource directory for "file fixtures" (sample transactions)
resources_directory = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"resources",
)
@dixonwhitmire
dixonwhitmire / Dockerfile
Last active August 16, 2023 14:30
Python and Poetry Dockerfile
FROM ubi/ubi8 AS builder
LABEL name="Awesome App" \
maintainer="Awesome Team" \
summary="The Awesome Application" \
vendor="Awesome Vendor" \
version=${buildnumber} \
description="A ubi8 base image with python39 installed and configured for managing the Awesome App."