Skip to content

Instantly share code, notes, and snippets.

View u8sand's full-sized avatar

Daniel J. B. Clarke u8sand

View GitHub Profile
@u8sand
u8sand / !pgstore.md
Last active May 8, 2026 20:55
OpenAI-like helpers for storing an querying embedding vectors utilizing a postgres database with pgvector extension

PGStore

OpenAI-like helpers for storing an querying embedding vectors utilizing a postgres database with pgvector extension.

Also included is the docker-compose which instantiates a postgres database with the necessary extension.

Usage

import pathlib
@u8sand
u8sand / !sshgrok.md
Last active May 6, 2026 20:56
A CLI for ngrok-like functionality through a publicly accessible traefik server with SSH access

sshgrok

SSH reverse proxy with Traefik route registration.

What it does

  • Starts a Traefik container on the server.
  • Uses SSH reverse tunneling to expose a local service through the remote server.
  • Writes Traefik dynamic config files remotely so requests to a domain route back through the tunnel.
  • Supports automatic remote port selection and optional TLS via a Traefik certificate resolver / Let’s Encrypt.
@u8sand
u8sand / async_helpers.py
Created April 17, 2026 15:18
A convenient way of running async code from sync code in python
import queue
import atexit
import asyncio
import threading
def get_event_loop():
''' Get an active event loop or start one in another thread, stop it when exiting the program
'''
try:
return asyncio.get_event_loop()
IDH1
TSC1
GNAS
PIK3CA
NRAS
PTPN3
ARID1A
CDK6
RADIL
BRCA2
@u8sand
u8sand / frictionless_prune.py
Last active April 11, 2025 20:04
Cascade remove all invalid records from a datapackage
import csv
import sys
import click
import pathlib
import logging
import shutil
import frictionless
logging.basicConfig(stream=sys.stderr, level=logging.INFO)
@u8sand
u8sand / datapackage-validate.py
Last active December 9, 2024 18:24
Validate frictionless datapackage using datapackage-py
#!/usr/bin/env python
# Usage: datapackage-validate [datapackage.json]
import sys, traceback, logging
import datapackage
logging.basicConfig(stream=sys.stderr)
try:
from tqdm.auto import tqdm

Keybase proof

I hereby claim:

  • I am u8sand on github.
  • I am u8sand (https://keybase.io/u8sand) on keybase.
  • I have a public key ASB8OoHuHb_vgVtPX1wB9VlcUnYfwARjxDmvi_-8zYhy0wo

To claim this, I am signing this object:

@u8sand
u8sand / pip-freeze-timemachine.py
Last active October 29, 2024 17:27
Install packages from requirements files at a point in time
#!/usr/bin/env python
'''
This script installs packages from requirements file(s) in a virtual environment
as they would have been installed at a certian date, then assembles the versions
for the requirements.txt file.
Usage:
pip-freeze-timemachine -d 2022-01-01 -r requirements.txt -o requirements.versioned.txt
requirements:
@u8sand
u8sand / docker-compose-flatcar-config.yaml
Last active August 2, 2025 03:16
A demonstrative flatcar-config for running a docker-compose.yaml
# This launches a docker-compose.yaml (defined inline at the bottom)
# NOTE: this file should be converted to ignition.json which can be used with a Flatcar OS
# docker run --rm -i quay.io/coreos/butane:latest < docker-compose-flatcar-config.yaml > ignition.json
variant: flatcar
version: 1.0.0
passwd:
users:
- name: core
ssh_authorized_keys:
- # TODO: insert your public key (the `.pub` file generated by `ssh-keygen`)
@u8sand
u8sand / !tensorflow-serving.md
Created October 10, 2023 19:48
A slightly easier to use tensorflow-serving -- auto-construct models.config

README

docker.io/tensorflow/serving requires that you build a config file when working with more than one model. I find this a bit silly, this image builds it for you assuming you just have all the models in their separate directories.

  • /models/model-a/1/
  • /models/model-b/1/
  • ...