Skip to content

Instantly share code, notes, and snippets.

View u8sand's full-sized avatar

Daniel Clarke u8sand

View GitHub Profile
@u8sand
u8sand / docker-compose-flatcar-config.yaml
Last active March 26, 2024 18:08
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 30, 2023 14:02
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.

@u8sand
u8sand / !case-sensitive-ingress-nginx.md
Last active January 30, 2023 19:32
This patches the ingress-nginx controller to use case sensitive path prefix matching

case-sensitive-ingress-nginx

This patches the ingress-nginx controller to use case sensitive path prefix matching.

My issue in the repo was ignored

@u8sand
u8sand / df2pg.py
Last active November 23, 2022 19:38
A micro-library for quick pandas dataframe => postgres upload
'''
This snippet can be used for quickly copying a pandas dataframe
into postgres via unix pipe. I expect this to be faster than other
approaches since the writing can happen entirely in native code:
- os.pipe is facilitated by the kernel
- psycopg2 copy_from uses libpg
- np.savetxt uses libnumpy
Usage:
@u8sand
u8sand / !neo4j-ex.md
Last active November 15, 2022 21:34
A more convenient neo4j container which allows you to import dumps inplace

NEO4J Extended Docker Container

This overrides public neo4j container on dockerhub to make it more convenient to override the operating database at runtime.

To that effect it:

  • uses supervisord configured with supervisorctl support to maintain the neo4j process
  • it defines a script: neo4j-load which can import dumps from network endpoints

Usage

#!/bin/python3
# python archs4-dl.py series-samples GSE53655 | python archs4-dl.py fetch > GSE53655.tsv
import re
import json
import click
import urllib.request, urllib.parse, urllib.error
from tqdm import tqdm