This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useState } from "react"; | |
| const useLocalStorageState = (storageKey, defaultValue) => { | |
| const [value, setValue] = useState( | |
| JSON.parse(localStorage.getItem(storageKey) || "null") || defaultValue | |
| ); | |
| const wrappedSetValue = (newValue) => { | |
| localStorage.setItem(storageKey, JSON.stringify(newValue)); | |
| setValue(newValue); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| An Instagram Top 9 generator that doesn't require connecting your account | |
| to an untrustworthy 3rd party Instagram app. | |
| Install the requirements with `pip3 install igramscraper Pillow click` | |
| then run `python3 top9.py` | |
| When done, you will have a YOURUSERNAME-top9.jpg in your working directory. | |
| """ | |
| from datetime import datetime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "features": [ | |
| { | |
| "geometry": { | |
| "coordinates": [ | |
| [ | |
| [ | |
| -76.99545991625094, | |
| 38.8494249445368 | |
| ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript:(() => { | |
| const newSc = prompt('enter shortcuts to restore'); | |
| /* Parse cookies into a map */ | |
| const cookies = new Map(document.cookie.split(/\s*;\s*/g).map(kv => kv.split('='))); | |
| /* decode and parse the noflush_awscnm cookie */ | |
| const noflush_awscnm = JSON.parse(decodeURIComponent(cookies.get('noflush_awscnm'))); | |
| /* set shortcuts to those input by user */ | |
| noflush_awscnm.sc = newSc.split(','); | |
| /* set the noflush_awscnm cookie (stringified & encoded) */ | |
| document.cookie = `noflush_awscnm=${encodeURIComponent(JSON.stringify(noflush_awscnm))}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript:(() => { | |
| /* Parse cookies into a map */ | |
| const cookies = new Map(document.cookie.split(/\s*;\s*/g).map(kv => kv.split('='))); | |
| /* decode and parse the noflush_awscnm cookie */ | |
| const noflush_awscnm = JSON.parse(decodeURIComponent(cookies.get('noflush_awscnm'))); | |
| /* display the comma delimited shortcuts to user */ | |
| alert(`current shortcuts: ${noflush_awscnm.sc.join(',')}`); | |
| })() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from requests_html import HTMLSession | |
| session = HTMLSession() | |
| resp = session.get('https://mailchi.mp/badcee76d7db/groupcamping?e=f74653273d') | |
| groups = resp.html.find('#docs-internal-guid-242d83ee-6477-f6f4-5448-18ced87471f3', first=True).text.split('\n') | |
| sites = resp.html.find('#docs-internal-guid-349ccfaa-6479-e25f-134f-289c9f089e3a', first=True).text.split('\n') | |
| for group, site in zip(groups, sites): | |
| print(f'{group}: {site}') |