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
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)
@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

@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

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.
@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">
@mnofresno
mnofresno / README.md
Last active March 25, 2025 19:17
This script allows to do on Linux desktop PC some simple ocr tasks that we currently can do on Android using Google lens

Google Lens For Ubuntu

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 
@kmatt
kmatt / slugify.postgres.sql
Last active February 1, 2023 12:51 — forked from abn/slugify.postgres.sql
A slugify function for postgres
-- 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
@AsgerPetersen
AsgerPetersen / create_voronoi_function.sql
Last active November 17, 2021 15:41
Fast(er) voronoi polygons in PostGIS
-- 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:
@alexaleluia12
alexaleluia12 / flask_logging_requests.py
Last active November 22, 2024 05:11
Flask Logging (every request)
#/usr/bin/python
# http://exploreflask.com/en/latest/views.html
# https://stackoverflow.com/questions/51691730/flask-middleware-for-specific-route
# https://dev.to/rhymes/logging-flask-requests-with-colors-and-structure--7g1
import logging
from logging.handlers import RotatingFileHandler
from flask import Flask, request, jsonify
from time import strftime