Skip to content

Instantly share code, notes, and snippets.

View missinglink's full-sized avatar

Peter Johnson missinglink

View GitHub Profile
@missinglink
missinglink / gnaf-sqlite.sh
Last active October 21, 2021 08:56
generate a SQLite import script for the AUS G-NAF dataset
#!/bin/bash
# ref: https://github.com/data61/gnaf/blob/master/gnaf-db/src/main/script/createGnafDb.sh
# input dir
DATA_DIR="/data/gnaf/G-NAF/G-NAF AUGUST 2021"
EXTRAS_DIR="/data/gnaf/G-NAF/Extras"
# fast import pragmas
echo '.output /dev/null'
echo 'PRAGMA main.foreign_keys=OFF;'
@missinglink
missinglink / errors.txt
Created September 29, 2021 17:57
whosonfirst geometry validation errors 29/10/2021
85632505|meso|0|Self-intersection[-69.31 -28.27]|POINT(-69.31 -28.27)
85632793|quattroshapes-reversegeo|-1||
85632793|quattroshapes|-1||
85681583||0|Self-intersection[144.652483533911 -40.3811760786903]|POINT(144.652484 -40.381176)
85770383|quattroshapes|0|Ring Self-intersection[147.317205739621 -42.9812372030377]|POINT(147.317206 -42.981237)
85775753|quattroshapes|0|Ring Self-intersection[150.501708984 -23.3725138223999]|POINT(150.501709 -23.372514)
85781949|quattroshapes|0|Ring Self-intersection[117.927246094 -35.0344943317]|POINT(117.927246 -35.034494)
85632475|meso|0|Self-intersection[88.906686 22.921783]|POINT(88.906686 22.921783)
85801287|quattroshapes|0|Ring Self-intersection[4.47143554686997 50.8891740489]|POINT(4.471436 50.889174)
85929283|quattroshapes|0|Ring Self-intersection[23.3294677734 42.6622413763001]|POINT(23.329468 42.662241)
@missinglink
missinglink / Install-darwin-brew-s2geometry.txt
Last active September 8, 2021 22:08
install s2geometry (c++ libs) on mac with brew / plus hello world s2geometry example
# based on: https://s2geometry.io/about/platforms
# note: set -DOPENSSL_ROOT_DIR instead of -DOPENSSL_INCLUDE_DIR
brew install gflags glog openssl
brew install cmake
# Download Googletest release 1.8.0 and unpack it in a directory of your choosing.
# (Take note of this directory as you will need to point CMake to it.)
# https://github.com/google/googletest/releases/tag/release-1.8.0
@missinglink
missinglink / featureCollectionSandwich.sh
Last active March 3, 2020 10:32
Convert a stream of geojson features to a feature collection
#!/bin/bash
featureCollectionSandwich() {
echo '{ "type": "FeatureCollection", "features":'
cat - | jq -s .
echo '}'
}
@missinglink
missinglink / timeseries.js
Created January 29, 2020 12:44
functions for computing time windows for data series
const interval = {
millisecond: 1,
second: 1000,
minute: 1000 * 60,
hour: 1000 * 60 * 60,
day: 1000 * 60 * 60 * 24
}
const period = 'day'
const d1 = truncate(new Date('2020-01-01 22:22:22'), period)
@missinglink
missinglink / mines.js
Last active June 25, 2023 17:39
Javascript one-liner to calculate total minesweeper neighbours
var m = [
[' ',' ',' ',' ',' '],
[' ',' ',' ',' ',' '],
['X',' ',' ',' ',' '],
[' ','X',' ',' ',' '],
[' ',' ','X',' ',' '],
]
var m = [
[' ',' ','X'],
@missinglink
missinglink / repo-list.sh
Created June 11, 2019 15:55
List all repositories by organization
ORG='whosonfirst-data';
rm -f "${ORG}.txt"
for i in {0..15}; do
curl -s "https://api.github.com/orgs/${ORG}/repos?page=${i}&per_page=100" \
| jq -r '.[] | .name' \
>> "${ORG}.txt"
done
@missinglink
missinglink / nyc.geojson
Last active July 25, 2018 14:16
'Postal City' for New York City
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@missinglink
missinglink / sanfran.geojson
Created July 25, 2018 13:29
'Postal Cities' for San Francisco
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@missinglink
missinglink / postal_cities.txt
Created July 25, 2018 12:42
Candidate 'postal cities', based off places the Census lists as a 'principal city', and whos geometry intersects with the geometry of more than one ZCTA
5300100|Aberdeen city
4801000|Abilene city
4000200|Ada city
1301052|Albany city
4101000|Albany city
3700680|Albemarle city
0100988|Albertville city
3502000|Albuquerque city
0101132|Alexander City city
2200975|Alexandria city