Skip to content

Instantly share code, notes, and snippets.

@patte
patte / index.html
Last active September 5, 2026 18:30
maplibre-gl #6584: getCameraAltitude() NaN on the globe, before/after side by side
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>maplibre-gl: getCameraAltitude() on the globe, before and after the fix for #6584</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/maplibre-gl@6.7.0/dist/maplibre-gl.css" rel="stylesheet">
<style>
html, body { margin: 0; height: 100%; background: #141418; color: #eee; font: 15px/1.45 system-ui, sans-serif; }
#panel { padding: 12px 16px; background: #1c1c22; border-bottom: 1px solid #2c2c34; }
@patte
patte / index.html
Last active August 26, 2026 23:30
maplibre-gl 6.6.0: stale terrain drape textures after a zoom animation — press ① then ②
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>maplibre-gl: stale terrain drape textures after a zoom animation</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://unpkg.com/maplibre-gl@6.6.0/dist/maplibre-gl.css" rel="stylesheet">
<style>
html, body { margin: 0; height: 100%; }
#map { position: absolute; inset: 0; }
@patte
patte / create_date_xmps.ugly.sh
Created November 1, 2025 16:46
write .xmp with DateTimeOriginal for files which miss creation date based on Library.apdb extraction and file creation date
#!/usr/bin/env bash
## move away CR2 and AAE files
cd /data/
SRC="./Fotos-Mediathek.photoslibrary/Masters/"
DEST="./additional-files/Masters/"
sudo mkdir -p "$DEST"
sudo rsync -av \
--remove-source-files \
@patte
patte / simulate_zfs_data_errors.md
Last active October 31, 2025 18:14
test zed notifications by manufacturing a bad zfs scrub
# create
dd if=/dev/zero of=/tmp/sparse_file bs=1 count=0 seek=512M
sudo losetup /dev/loop10 /tmp/sparse_file
sudo zpool create test /dev/loop10
sudo zpool status test

# write
sudo zfs create test/fs
sudo dd if=/dev/urandom of=/test/fs/bigfile bs=1M count=400 status=progress
@patte
patte / linux_mail.md
Last active October 31, 2025 17:40
setup email sending on linux
sudo apt install --no-install-recommends msmtp msmtp-mta bsd-mailx

sudo touch /var/log/msmtp
sudo chown root:users /var/log/msmtp
sudo chmod 664 /var/log/msmtp

echo 'set mta=/usr/bin/msmtp' | sudo tee -a /etc/mail.rc

sudo vi /etc/msmtprc
# fix for:
# perl: warning: Setting locale failed.
# perl: warning: Please check that your locale settings:
# LANGUAGE = (unset),
# LC_ALL = (unset),
# LC_CTYPE = "UTF-8",
# LANG = "C.UTF-8"
# are supported and installed on your system.
# perl: warning: Falling back to a fallback locale ("C.UTF-8").
@patte
patte / buffers.ts
Last active September 23, 2025 13:56
fix: Argument of type 'Uint8Array<ArrayBufferLike>' is not assignable to parameter of type 'Uint8Array<ArrayBuffer>'
/**
* Asserts that the provided Uint8Array is backed by an ArrayBuffer.
*
* Throws an error if the buffer is a SharedArrayBuffer or any other type.
* This is useful for ensuring (type) compatibility with APIs that require Uint8Array<ArrayBuffer>.
* Usage:
* // bytes: Uint8Array<ArrayBufferLike>
* assertArrayBuffer(bytes);
* // bytes: Uint8Array<ArrayBuffer>
*
@patte
patte / led.service
Created August 28, 2025 13:13
Turn off the LED of the powerbutton on framework notebooks.
# /etc/systemd/system/led.service
[Unit]
Description=Turn off boot button LED
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/bin/bash -c "echo 0 > /sys/class/leds/chromeos:white:power/brightness"
RemainAfterExit=true
User=root
@patte
patte / proxy_server.go
Created February 15, 2024 11:39
litefs proxy_server.go with simple websocket support
package main
import (
"io"
"log"
"net/http"
"net/http/httputil"
"net/url"
)
var topojsonClient = require("topojson-client")
ch = await fetch("https://swiss-maps.vercel.app/api/v0?format=topojson&projection=wgs84&year=2022&shapes=lakes").then(res => res.json())
geo = topojsonClient.feature(ch, ch.objects.lakes)
console.log(JSON.stringify(geo, null, 2))