Skip to content

Instantly share code, notes, and snippets.

View typebrook's full-sized avatar

Hsieh Chin Fan typebrook

View GitHub Profile
@typebrook
typebrook / get_token.sh
Last active February 7, 2022 08:27
[curl-Github] Use curl to get Github Access Token #github #curl #token
curl https://api.github.com/authorizations \
--user "typebrook" \
--data '{"scopes":["gist"], "note": "gist"}'
read -p "2-factor code: " OTP
curl https://api.github.com/authorizations \
--user typebrook -H "X-GitHub-OTP: $OTP" \
--data '{"scopes": ["gist"], "note": "gist"}'
@typebrook
typebrook / Makefile
Last active July 30, 2022 23:59
[OSM-village] script to make Taiwan village-related files with gov data #osm #makefile #data #gov #gdal #village
SHELL := /bin/bash
data/taiwan-latest.osm.pbf:
mkdir -p data
curl -o $@ http://download.geofabrik.de/asia/taiwan-latest.osm.pbf
data/village.zip:
mkdir -p data
curl -o $@ 'https://whgis.nlsc.gov.tw/DownlaodFiles.ashx?oid=1008&path=Opendata/OpendataFiles/OFiles_71ae710e-fe25-4649-ab9c-779921dd02fb.zip'
@typebrook
typebrook / README.md
Last active October 26, 2020 01:31
[OSM-data] 台灣便利商店 from OSM queried by overpass.nchc.org.tw #geojson #osm #overpass

Overpass example to query from CLI

query nodes with tag shop=convenience

# Do not run this command,  you'll realize the response is too big
OVERPASS_API=https://overpass.nchc.org.tw/api/interpreter

echo "node[shop="convenience"];out;" \
| curl -d @- -X POST $OVERPASS_API
@typebrook
typebrook / github-release.sh
Last active August 12, 2021 08:08
[Github-release] A script manages release note or its asset with GitHub API v3 #github #release #curl #asset
#!/usr/bin/env sh
#
# Author: Hsieh Chin Fan (typebrook) <typebrook@gmail.com>
# License: MIT
# https://gist.github.com/typebrook/4947769e266173303d8848f496e272c9
#
# Originally created by stefanbuck
# fork from: https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447
#
# --
@typebrook
typebrook / layer.list.md
Last active April 26, 2020 10:24
[tilemaker] Note for mvt layers with OMT compability #tilemaker #omt #mbtiles #mvt

TODO

  • Add functions into docs (osm_lua_processing.cpp)
    • Area
    • Length
    • Holds
    • IsClosed
    • ScaleToMeter
    • ScaleToKiloMeter
    • Length
  • Set OSM IDs
@typebrook
typebrook / Makefile
Last active July 30, 2022 23:59
[gov-data] Address location in Tainan, thanks kiang! #gov #data #addr #csv
all: 108.csv output.csv output.geojson
# CSV file for address in Tainan
# see dataset at web page: https://data.tainan.gov.tw/dataset/108-address-location
108.csv:
curl -LO https://data.tainan.gov.tw/dataset/32d604ed-9c9e-4d12-9c55-d33b1bb5fd60/resource/2389d5b2-451b-4b6a-b808-d2803717b196/download/108.csv
# Transform from TWD97 to EPSG:4326
# see GDAL release page: https://gdal.org/download.html
# and doc for CSV driver: https://gdal.org/drivers/vector/csv.html
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 8 columns, instead of 7. in line 9.
圖號,行政區1,行政區2,行政區3,起始頁,結束頁,新頁碼,連結
1916-1,澎湖縣,,,2,3,6,https://map.happyman.idv.tw/~happyman/cv/comicview.php?filename=.%2Fcontents/TW3.zip#&gid=1&pid=6
1917-2,澎湖縣,,,4,5,7,https://map.happyman.idv.tw/~happyman/cv/comicview.php?filename=.%2Fcontents/TW3.zip#&gid=1&pid=7
2017-4,澎湖縣,,,6,19,8,https://map.happyman.idv.tw/~happyman/cv/comicview.php?filename=.%2Fcontents/TW3.zip#&gid=1&pid=8
2018-3,澎湖縣,,,20,21,15,https://map.happyman.idv.tw/~happyman/cv/comicview.php?filename=.%2Fcontents/TW3.zip#&gid=1&pid=15
2114-1,高雄縣,屏東縣,高雄市,22,38,16,https://map.happyman.idv.tw/~happyman/cv/comicview.php?filename=.%2Fcontents/TW3.zip#&gid=1&pid=16
2114-2,高雄縣,屏東縣,,38,45,24,https://map.happyman.idv.tw/~happyman/cv/comicview.php?filename=.%2Fcontents/TW3.zip#&gid=1&pid=24
2115-1,高雄縣,台南縣,,46,66,28,https://map.happyman.idv.tw/~happyman/cv/comicview.php?filename=.%2Fcontents/TW3.zip#&gid=1&pid=28
2115-2,高雄縣,屏東縣,,66,90,38,https://map.happyman.idv.tw/~happyman/cv/comicview.php?filename=.%2Fcontents/TW3.zip#&gid=1&pid=38
2115-3,高雄縣,,,90,92,
@typebrook
typebrook / sh
Last active August 17, 2020 06:34
Sync 2 files between different git repos with blob object #script #git #sync
#!/usr/bin/env bash
target=$(cd $(dirname $1) && git rev-parse --show-toplevel)
cd $target
file=${1#$target/}
anchor=$(git rev-parse HEAD:$file)
cd $2
if ! git cat-file -e $anchor 2>/dev/null; then
echo $anchor not found
@typebrook
typebrook / github.graphql
Last active July 30, 2022 23:59
A simple github graphql example to fetch user gists #graphql #wip
curl -d @- -X POST --header "Authorization: token $(token github)" https://api.github.com/graphql <<EOF
{
"query": "{
user(login: \"typebrook\") {
gists(last: 50) {
nodes {
isPublic
resourcePath
description
stargazerCount
@typebrook
typebrook / README.md
Last active July 26, 2020 16:19
Merge all <trkseg> into a single <trk> in gpx file. Donload exe file at https://git.io/JfQeW #sed #gpx #track #trk #trkseg #bat #磐石

Make .EXE file on Windows for GPX track merging

  1. Get bat-to-ext-converter and sed
  2. Open bat-to-ext-converter, and wrap merge.bat, sed.exe, merge.sed into a single exe file
  3. Run signtool /a /tr http://tsa.starfieldtech.com merge.exe to sign exe file