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 / 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 August 29, 2025 18:18
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.

@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 June 29, 2026 19:51
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
@u8sand
u8sand / ssh-crypt.sh
Created September 1, 2022 21:29
Use ssh keys & github for quick and easy crypto.
#!/bin/bash
#
# A helper for using ssh keys & github for encrypting/decrypting messages intended for specific recipients.
# Installation (assumes ~/.local/sbin/ is in your PATH, put it wherever you want):
# 1. Download script
# 2. mv ssh-crypt.sh ~/.local/sbin/ssh-crypt
# 3. chmod +x ~/.local/sbin/ssh-crypt
#
# See `ssh-crypt help` for command information.
@u8sand
u8sand / rclone-serve-combined
Last active August 6, 2022 15:52
A simple script for serving one store with all rclone remotes as directories. I use this as a daemon which can be accessed with dolphin :)
#!/bin/bash
# `rclone serve -h` for other remotes / arguments
PROTOCOL="webdav"
ARGS="--vfs-cache-mode writes"
# we construct an inline combined upstream with all remotes using the remote name as the directory
rclone listremotes \
| awk -F':' -v ARGS="${ARGS}" -v PROTOCOL="${PROTOCOL}" "
BEGIN {