author: @sleepyfox
title: ZDD - Zero Dependency Development
date: 22-May-2023
| 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 | |
| """ |
| 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; |
| 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) |
| #!/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 |
Basically two types:
- Rectangles
- 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:
- "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.
| <!-- | |
| 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"> |
For those who use Google Lens on Android as an OCR to capture text from images, screenshots, etc.. here is a bash script that does the same on Ubuntu.
Sometimes we need to copy a telephone number in an APP where there isn't a copy to clipboard feature enabled or maybe to copy texts from an picture.
This can be done with a OCR, this script does that allowing to drag&drop select a region of the screen and copy to clipboard the text parsed from the image.
#!/bin/bash | -- original source: https://medium.com/adhawk-engineering/using-postgresql-to-generate-slugs-5ec9dd759e88 | |
| -- https://www.postgresql.org/docs/9.6/unaccent.html | |
| CREATE EXTENSION IF NOT EXISTS unaccent; | |
| CREATE OR REPLACE FUNCTION public.slugify(v TEXT) RETURNS TEXT | |
| LANGUAGE plpgsql | |
| STRICT IMMUTABLE AS | |
| $function$ | |
| BEGIN |
| -- plpython needs to be enabled. Furthermore scipy needs to be installed in the python used. | |
| -- CREATE LANGUAGE plpythonu; | |
| CREATE OR REPLACE FUNCTION septima.voronoi(geom geometry, boundingpointdistance double precision) | |
| RETURNS SETOF geometry_dump AS | |
| $BODY$ | |
| from scipy.spatial import Voronoi | |
| import numpy | |
| class GeoVoronoi: |
