Skip to content

Instantly share code, notes, and snippets.

View dixonwhitmire's full-sized avatar

Dixon Whitmire dixonwhitmire

View GitHub Profile
@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."
@dixonwhitmire
dixonwhitmire / logging_retry.py
Created May 12, 2023 16:06
Logging and Retry Decorator
import time
import logging
logger = logging.getLogger(__name__)
def logging_retry(retry=False, max_retries=10, retry_interval=10):
"""
smoketest decorator provides task logging with timing information and optional retries.
Retries, if enabled are limited to `max_retries`. The duration between each retry is calculated as
retry_interval = retry_attempt * retry_interval
@dixonwhitmire
dixonwhitmire / MakeFile
Created August 31, 2022 14:32
Go MakeFile
fmt:
go fmt ./...
.PHONY:fmt
lint: fmt
revive ./...
.PHONY:lint
vet: fmt
go vet ./...
@dixonwhitmire
dixonwhitmire / jsonpath.py
Created April 15, 2022 00:36
JSON Path Snippets
import json
from fhir.resources.patient import Patient
from fhir.resources import construct_fhir_element
from jsonpath_ng import jsonpath, parse
from jsonpath_ng.ext import parser
with open('Patient.json', 'r') as f:
pat_dict = json.load(f)
patient: Patient = construct_fhir_element("Patient", pat_dict)
@dixonwhitmire
dixonwhitmire / chunk.py
Created November 20, 2021 11:54
Chunk A List
def chunk(sequence: List, step: int):
for i in range(0, len(sequence), step):
yield sequence[i:i + step]
@dixonwhitmire
dixonwhitmire / docker-compose.yml
Created September 27, 2021 17:18
LFH FHIR Integration
version: "3.9"
networks:
main:
name: fabric_test
services:
connect:
build:
context: .
dockerfile: Dockerfile
args: