Skip to content

Instantly share code, notes, and snippets.

@uhthomas
uhthomas / jxl.sh
Last active April 15, 2025 22:02
find lossless jxl images and reencode them as lossy
#!/usr/bin/env bash
set -euo pipefail
while IFS= read -r -d '' file; do
if jxlinfo "$file" | grep -iq lossless; then
echo "Image $file is lossless"
cjxl --container=1 "$file" "$file"
echo "Finished conversion"
fi
done < <(find . -type f -iname "*.jxl" -size +20M -print0)
@uhthomas
uhthomas / do.sh
Created April 15, 2025 17:49
convert raw arw nef to jxl
#!/usr/bin/env bash
set -euo pipefail
while IFS= read -r -d '' file; do
echo "Processing: $file"
magick mogrify -format jxl "$file"
out="${file%.*}.jxl"
if [[ "${file,,}" == *".nef" ]]; then
@uhthomas
uhthomas / deduplicate_slice.go
Last active November 8, 2024 14:43
deduplicate go slice
func DeduplicateSlice[T cmp.Ordered](in []T) []T {
slices.Sort(in)
out := in[:0]
for i := 0; i < len(in); i++ {
var n int
for j := i + 1; j < len(in); j++ {
if in[i] != in[j] {
break
@uhthomas
uhthomas / README.md
Last active January 8, 2025 13:52
Recover rook ceph after catastrophic monitor store loss

Recover rook ceph after catastrophic monitor store loss

The OS SSD died on my kubernetes/rook/ceph cluster which left the cluster with catastrophic monitor store loss. The process for recovering from just OSDs is not well documented, especially not when combined with rook and cephfs with multiple data pools. The last of which may never have been done before.

I am writing this document after the fact, so I may be missing some things, or they may be out of order. I will try my best though as I think it could be helpful.

@uhthomas
uhthomas / main.go
Last active August 27, 2024 22:49
improved docker distrubtion invalid repository finder and deleter
package main
import (
"context"
"flag"
"fmt"
"log"
"path"
"github.com/aws/aws-sdk-go/aws"
{
"__inputs": [
{
"name": "DS_VICTORIAMETRICS",
"label": "VictoriaMetrics",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
// You can edit this code!
// Click here and start typing.
package main
import (
"crypto/sha256"
"encoding/base64"
"fmt"
"strings"
)
spec:
retentionPeriod: 2y
replicationFactor: 2
vmselect:
replicaCount: 3
securityContext:
runAsUser: 1000
runAsGroup: 3000
runAsNonRoot: true
fsGroup: 2000
Computer Information:
Manufacturer: Gigabyte Technology Co., Ltd.
Model: X570 AORUS ELITE
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: AuthenticAMD
CPU Brand: AMD Ryzen 9 3950X 16-Core Processor
CPU Family: 0x17
diff --git a/go/tools/builders/nogo_main.go b/go/tools/builders/nogo_main.go
index 631cf0e5..29722f35 100644
--- a/go/tools/builders/nogo_main.go
+++ b/go/tools/builders/nogo_main.go
@@ -26,18 +26,23 @@ import (
"flag"
"fmt"
"go/ast"
+ "go/format"
"go/parser"