Skip to content

Instantly share code, notes, and snippets.

View dschep's full-sized avatar

Daniel Schep dschep

View GitHub Profile
{
"version": 8,
"name": "heatmask",
"metadata": {"maputnik:renderer": "mbgljs"},
"sources": {
"openmaptiles": {
"type": "vector",
"url": "https://d1zqyi8v6vm8p9.cloudfront.net/planet.json"
},
"stravaheatfreemapsk": {
@dschep
dschep / staticfavicon.js
Last active December 6, 2023 14:41
Disable favicon updates
javascript:(() => {
const observer = MutationObserver(({addedNodes, removedNodes}) => {
console.log("favicon change!", addedNodes, removedNodes);
});
observer.observe(document.head, {childList: true});
})();
@dschep
dschep / _Customizing MapSwap List.md
Last active December 1, 2023 19:19
MapSwap Presets

Sample MapSwap configs

This gist contains a few example MapSwap configs.

@dschep
dschep / RegionalBikeways.geojson
Last active November 2, 2023 14:40
Richmond, VA Regional Bikeways
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dschep
dschep / go-to-gh-repo-from-page.js
Created September 13, 2023 12:39
Go to Github Repo from Page
javascript:javascript=window.location=window.location.host.replace(/([^.]+)\.github\.io/, `https://github.com/$1/${window.location.pathname.split("/")[1]}`)
.PHONY: help
help: # Print help
@awk 'BEGIN {FS = ":.*?# *"} /^[.a-zA-Z_-]+:.*?# */ {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@dschep
dschep / wordle-cheat
Last active February 11, 2022 15:00
Solve Wordle
javascript:JSON.parse(window.localStorage.getItem('nyt-wordle-state')).solution.split('').concat(['Enter']).map(key=>window.dispatchEvent(new KeyboardEvent('keydown',{key})))&&undefined;
@dschep
dschep / ST_LineChunk.sql
Last active January 10, 2021 02:43
Line chunking implementations for PostGIS
CREATE OR REPLACE FUNCTION ST_LineChunk(geom geometry, max_length float8) RETURNS SETOF geometry AS $$
WITH
points AS (
SELECT generate_series(0, CEIL(ST_Length(geom) / max_length)::int)
/ CEIL(ST_Length(geom) / max_length) "end"
),
line_points AS (SELECT LAG("end", 1) OVER (ORDER BY "end") "start", "end" FROM points)
SELECT ST_LineSubstring(geom, "start", "end")
FROM line_points
WHERE "start" IS NOT NULL AND "start" <> 1
@dschep
dschep / ST_TileEnvelope.sql
Last active January 9, 2021 18:41
ST_TileEnvelope backport
-- ported from https://github.com/pramsey/minimal-mvt/blob/58f3e695a305f42024dcf0ba395590bf39b0b573/minimal-mvt.py#L63-L81
CREATE OR REPLACE FUNCTION ST_TileEnvelope(tileZoom integer, tileX integer, tileY integer) RETURNS geometry AS $$
-- Width of world in EPSG:3857
DECLARE worldMercMax float = 20037508.3427892;
DECLARE worldMercMin float = -1 * worldMercMax;
DECLARE worldMercSize float = worldMercMax - worldMercMin;
-- Width in tiles
DECLARE worldTileSize float = power(2, tileZoom);
-- Tile width in EPSG:3857
DECLARE tileMercSize float = worldMercSize / worldTileSize;
@dschep
dschep / partially.py
Created October 1, 2020 12:51
A decorator version of functools.partial
def partially(*args, **kwargs):
"""
A decorator version of functools.partial
eg, this:
def _foo(x, y):
pass
foo = partial(_foo, 1)
is the same as:
@partially(1)