Skip to content

Instantly share code, notes, and snippets.

View bbengfort's full-sized avatar
🎯
Focusing

Benjamin Bengfort bbengfort

🎯
Focusing
View GitHub Profile
@bbengfort
bbengfort / process.py
Created October 6, 2024 20:42
Processes original parlance data and outputs some analyses
#!/usr/bin/env python3
import os
import re
import csv
import json
from datetime import datetime, timedelta
@bbengfort
bbengfort / hexdraw.py
Created September 26, 2024 18:02
A utility to draw Rotational colored hexagonal tiles. Adapted from https://variable-scope.com/posts/hexagon-tilings-with-python
#!/usr/bin/env python
import math
import random
import argparse
from PIL import Image
from aggdraw import Draw, Brush
@bbengfort
bbengfort / Envoy Workflows.ipynb
Created August 16, 2024 14:46
Envoy data workflows for travel rule exchanges using pyenvoy
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bbengfort
bbengfort / perdiem.py
Created July 9, 2024 15:29
Compute per-diem for travel based on GSA M&IE (Meals and Incidental Expenses)
#!/usr/bin/env python3
import argparse
from tabulate import tabulate
from datetime import datetime, timedelta
DATE_FMT = "%Y-%m-%d"
ONE_DAY = timedelta(days=1)
@bbengfort
bbengfort / randommer.py
Created April 5, 2024 22:51
Access the randommer.io API to generate fake crypto addresses and names for test fixtures.
#!/usr/bin/env python3
import os
import requests
import argparse
API_KEY_VAR = "RANDOMMER_API_KEY"
CRYPTO_TYPES = "https://randommer.io/api/Finance/CryptoAddress/Types"
CRYPTO_ADDRESS = "https://randommer.io/api/Finance/CryptoAddress"
RANDOM_NAME = "https://randommer.io/api/Name"
@bbengfort
bbengfort / cryptpress.go
Created October 27, 2023 22:09
Data encryption and compression are heavyweight algorithms that must be used with care in performance intensive applications; but when applying both mechanics to the same data, which should come first? These benchmarks compare Go gzip compression with AES-GCM cryptography. For more see: https://rotational.io/blog/compression-vs-cryptography/.
package cryptpress
import (
"bytes"
"compress/gzip"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"io"
)
@bbengfort
bbengfort / .dockerignore
Created September 19, 2023 12:15
Dockerfile examples for the blog post "How to Dockerize Python Data Science Processes" on rotational.io
# Ignore docker specific files
.dockerignore
docker-compose.yml
Dockerfile
# Ignore git directory and files
.gitignore
.git
# Ignore text files at the root of the project (optional)
@bbengfort
bbengfort / hashtopic.py
Last active April 3, 2023 17:18
Murmur3 comparison and test fixtures
#!/usr/bin/env python3
import mmh3
import json
import base64
def topic_hash(name):
hash = mmh3.hash128(name.encode('utf-8'), signed=False).to_bytes(16, byteorder='big', signed=False)
hash = hash[8:] + hash[:8]
@bbengfort
bbengfort / cleangcr.py
Last active February 12, 2023 19:22
A helper script that uses gcloud commands to cleanup old GCR images and reduce storage costs. By default it keeps any images tagged with a semver label and automatically removes any images with no tags. Users can specify a minimum number of images to keep and a grace period to allow images to stay for a specific time period.
#!/usr/bin/env python3
# Uses gcloud commands to cleanup old GCR images and reduce storage costs.
import re
import json
import argparse
import subprocess
from datetime import datetime, timedelta, timezone
@bbengfort
bbengfort / publisher.go
Created October 4, 2022 16:45
A quick ensign publisher routine.
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"time"
api "github.com/rotationalio/ensign/pkg/api/v1beta1"