Skip to content

Instantly share code, notes, and snippets.

View walkermatt's full-sized avatar
💭
Drinking tea

Matt Walker walkermatt

💭
Drinking tea
View GitHub Profile
@pvgenuchten
pvgenuchten / mapml.html
Last active June 15, 2022 07:10
hugo shortcode for mapml map
<!--
Install:
Copy this file into /layouts/shortcodes
Usage:
{{% mapml %}}
<mapml-viewer projection="OSMTILE" zoom="0" lat="0.0" lon="0.0" controls style="width:100%;height:400px">

Bonus geometry types in GeoJSON

Basically two types:

  1. Rectangles
  2. Circles

Let's say you have a drawing tool that permits both. Both geometry types benefit from some non-standard drawing abilities: it would be nice to resize circles, and it would be nice to resize rectangles in a way that keeps them rectangular. However, GeoJSON does not have circle or rectangle types. Both are represented as polygons. This gives us two options:

  1. "Detect" these shapes with a heuristic. This is doable for a rectangle by checking the corners, but much, much less doable for circles. Also, circles have an additional property that I will mention in the next bit.
@scivision
scivision / setup_gnu_parallel.sh
Last active January 19, 2023 12:10
setup GNU Parallel Bash script
#!/usr/bin/env bash
# useful for platforms that don't currently have GNU Parallel in their repo.
# does NOT work on Git Bash due to missing GNU Make etc.
# it builds on Cygwin, but may have runtime issues--give it a try.
set -e
curl -O ftp://ftp.gnu.org/gnu/parallel/parallel-latest.tar.bz2
@sleepyfox
sleepyfox / 2023-05-22-zdd.md
Last active January 12, 2025 15:13
ZDD - Zero Dependency Development
author: @sleepyfox
title: ZDD - Zero Dependency Development
date: 22-May-2023

ZDD - Zero Dependency Development

Heaviest objects in the universe

from abc import ABC, abstractmethod
class PickleCache(ABC):
"""Cache Python objects on disk to save on API calls
Clients can treat this class like a key/value store. The fetch() method
must be overridden to fetch a value from the API for a specific key.
Then subclasses can be used as in this example:
cache = SubclassedPickleCache(filepath)
import { ServerResponse, type IncomingMessage } from "node:http";
import { Http2ServerRequest, Http2ServerResponse } from "node:http2";
import { isArrayBufferView } from "node:util/types";
const INTERNAL_BODY = Symbol("internal_body");
const GlobalResponse = Response;
globalThis.Response = class Response extends GlobalResponse {
[INTERNAL_BODY]: BodyInit | null | undefined = null;
@kewgis
kewgis / to_xyz.py
Created June 30, 2025 10:52
Re-order the values in the x,y and z columns of a text file (e.g. a bathymetry .pts/.xyz file) such that they conform to a true .xyz format readable by GDAL and openable in QGIS.
import csv
"""
This script re-orders the values in the x,y and z columns of a text file (e.g. a bathymetry .pts/.xyz file) such that they conform to a true .xyz format readable by GDAL and openable in QGIS.
In many cases the data in an "xyz" file falls foul of the GDAL requirement that:
“Cells with same Y coordinates must be placed on consecutive lines. For a same Y coordinate value, the lines in the dataset must be organized by increasing X values.”
https://gdal.org/en/stable/drivers/raster/xyz.html
"""