Skip to content

Instantly share code, notes, and snippets.

View dschep's full-sized avatar

Daniel Schep dschep

View GitHub Profile
@dschep
dschep / gejsonio-add-raster-overlay.js
Created February 1, 2025 15:07
Add Raster Overlay to geojson.io
javascript:(()=>{
if (window.location.host!=='geojson.io') {
alert('This bookmarlet only works on geojson.io');
return;
}
const m = window.api.map;
const xyz = prompt("Enter your XYZ Raster Tile URL to overlay");
if (m.getLayer('overlay')) m.removeLayer('overlay');
if (m.getSource('overlay')) m.removeSource('overlay');
m.addSource('overlay', {type: 'raster', tileSize: 256, tiles: [xyz]});
@dschep
dschep / example.js
Created November 18, 2024 14:07 — forked from jcubic/example.js
Simple S-Expression (lisp) paser in JavaScript
console.log(parse(`(define (square x)
"Function calculate square of a number"
(* x x))`)[0].toString());
// ==> (define (square x) "funkcja square wywołanie (square 10) zwraca 100" (* x x))
---
options:
hash: m
attributionControl:
customAttribution: '<a href=".">Overpass Ultra</a>'
bounds: [-77.49784362036736,37.50408772391166,-77.40437276428577,37.57742791260068]
maxBounds: [-77.49784362036736,37.50408772391166,-77.40437276428577,37.57742791260068]
controls:
- type: GeolocateControl
options:
@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
Loading
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