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 / 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 April 6, 2025 09:23
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/
  • ...
@u8sand
u8sand / parse_datetime.patch
Last active September 24, 2023 13:33
Changes to get datetime v0.5 working in https://github.com/uutils/coreutils
diff --git a/Cargo.lock b/Cargo.lock
index 3723c52da..06049f73b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1499,9 +1499,9 @@ dependencies = [
[[package]]
name = "parse_datetime"
-version = "0.4.0"
+version = "0.5.0"
@u8sand
u8sand / Windows10-OpenSSH.ps1
Last active June 27, 2023 19:44
Powershell script for hassle-free Windows 10 OpenSSH Setup
# To get around "scripts not allowed on this system," you can run this with:
# powershell -ExecutionPolicy Bypass -File Windows10-OpenSSH.ps1
if (-Not (New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host "Must run as administrator!"
Sleep 5
Exit
}
Write-Host "Current service status..."

matomo + nginx

Based off of the information here: https://github.com/matomo-org/docker/tree/master/.examples/nginx

But instead of running two separate containers (nginx+matomo), a single container is created to serve matomo with nginx, this is more convenient in certain environments.

This is achieved simply by adding nginx and supervisord on top of the matomo image and serving nginx & php-fpm with supervsiord.

@u8sand
u8sand / !next-js-runtime-entrypoint-reconfig.md
Last active March 4, 2025 02:03
This trick allows you to build nextjs projects but change the basePath at runtime

NextJS Runtime Entrypoint Reconfig

NextJS seems to have no way to reconfigure the base path (vercel/next.js#16059).

Some propose a reverse proxy, but because static pages embed the basePrefix into them this also doesn't work well.

The alternative is quite undesirable -- building at runtime.

Here, we use a hopefully unique string /__ENTRYPOINT__ as the entrypoint, this allows us to just replace this string in all the next-built files at startup when we know the actual entrypoint.