Skip to content

Instantly share code, notes, and snippets.

@eddy-geek
eddy-geek / slope.html
Last active March 10, 2026 07:21
Slope/Aspect map viewer & track editor — MapLibre GL JS
<!DOCTYPE html>
<html lang="en">
<head>
<!-- https://gist.github.com/eddy-geek/ff8c4f3d74e1be6747baf3c91b41a50c -->
<!-- .../gh api --method PATCH /gists/ff8c4f3d74e1be6747baf3c91b41a50c -F "files[slope.html][content]=@slope.html" -F "files[slope.md][content]=@slope.md" --jq '.html_url' -->
<meta charset="utf-8" />
<title>Hybrid DEM Slope/Aspect with Border Backfill — MapLibre GL JS</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no" />
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl@5.18.0/dist/maplibre-gl.css" />
slope: [
'step', ['slope'],
"#ffffff", // white
20, "#c0ffff", // light sky blue
24, "#57ffff", // bright cyan
28, "#00d3db", // aqua blue
31, "#fffa32", // sunshine yellow
34, "#ffc256", // macaroni
37, "#fd7100", // orange
40, "#ff0000", // cherry red
@eddy-geek
eddy-geek / README.md
Last active February 27, 2026 19:39
maplibre-gl slope/aspect debug viewer

What this does

full interactive slope/aspect debug viewer using only maplibre-gl-js with:

  • Hybrid DEM pipeline

    • Uses internal backfilled DEM tiles when available
    • Falls back to custom border-fixed tiles when needed
    • Status counters show internal vs fallback usage
  • Terrain analysis overlay

How to convert terrarrium terrain RGB mbtiles back into tif ?

You can do it with GDAL in two steps:

  1. pick the correct decoder (Terrarium vs Mapbox Terrain‑RGB),
  2. apply the formula to the RGB PNG tiles inside the MBTiles and write out a Float32 GeoTIFF (then optionally reproject to WGS84).

Below I give ready‑to‑run commands for both encodings, plus tips to choose the zoom level, mask with the alpha band, and reproject.

#!/bin/bash
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
@eddy-geek
eddy-geek / necessary-verbs.sh
Created September 18, 2023 23:32
Audio fix for ALC298 in 16T90R-K.ADB9U1, kernel bug 212041 #13
#!/bin/sh
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x0
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x0
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x99
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x99
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x99
hda-verb /dev/snd/hwC0D0 0x20 0x480 0x0
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x99
hda-verb /dev/snd/hwC0D0 0x20 0x480 0x0
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x99
def get_jpg_quality(pim: 'PIL.Image.Image') -> int:
"""
Implement quality computation following ImageMagick heuristic algorithm:
https://github.com/ImageMagick/ImageMagick/blob/7.1.0-57/coders/jpeg.c#L782
Usage:
```
pim = Img.open(...)
quality = get_jpg_quality(pim)
```
See also https://stackoverflow.com/questions/4354543/

Comparing length of json-encoded DataFrame. to_json doc

Conclusions with my sample dataset

  • CSV
    • can be signifantly more compact if your data has lots of nans / strings, since their encoding is empty / not-quoted
    • but index is lost
    • and careful with incompatible quoting if you embed csv in json
  • split is the most compact json encoding that keeps column and index names, use it over columns (default) / record