Skip to content

Instantly share code, notes, and snippets.

View typebrook's full-sized avatar

Hsieh Chin Fan typebrook

View GitHub Profile
@typebrook
typebrook / Makefile
Last active February 4, 2023 02:52
Extract fields from county raw data #gis #gov #taiwan
kaohsiung.csv:
curl -Lo $@ https://data.kcg.gov.tw/dataset/7b142b2b-4d92-4a22-ac63-339c95bb0dfc/resource/d6e12411-8655-40ff-a2b2-ea3791c7c586/download/firehydrantonground.csv
taipei.csv:
curl -L https://data.taipei/api/getDatasetInfo/downloadResource\?id\=c106a00b-5a21-4393-b213-475a0ece9f2b\&rid\=b9f8154d-c627-48a8-b3ef-512ed9cde9e7 \
| iconv -f BIG-5 -t UTF-8 >$@
taoyuan_97.csv:
curl -Lo raw.json https://data.tycg.gov.tw/opendata/datalist/datasetMeta/download\?id\=3fd4a492-bcae-45be-8184-aa6fad506701\&rid\=ea487112-ef5b-481a-b49a-26f52dc04b93
echo 'FID,類別碼,識別碼,高程,x,y' >$@
@typebrook
typebrook / .env.template
Last active February 4, 2023 02:15
Invoice API
CARD_TYPE=
CARD_NO=
APPID=
CARD_ENCRYPT=
@typebrook
typebrook / cnn_news.sh
Last active January 4, 2023 13:26
Coninuouly print news from RSS
#! /bin/sh
RSS_URL=http://feeds.bbci.co.uk/news/rss.xml
#RSS_URL=http://feeds.bbci.co.uk/news/rss.xml
PRINT_INTERVAL=${PRING_INTERVAL:-30}
FETCH_INTERVAL=${FETCH_INTERVAL:-600}
RSS=$(mktemp)
LOCK=$(mktemp)
@typebrook
typebrook / mermaid.md
Created September 15, 2022 03:58
Test mermaid diagram
gantt
dateFormat  YYYY-MM-DD
title Adding GANTT diagram to mermaid
excludes weekdays 2014-01-10

section A section
Completed task            :done,    des1, 2014-01-06,2014-01-08
Active task               :active,  des2, 2014-01-09, 3d
Future task : des3, after des2, 5d
@typebrook
typebrook / geojson_for_tippecanoe.sh
Last active July 31, 2022 00:23
[contour-tippecannoe] Script to add extra info into contour geojson for tippecannoe #tile #mapbox #tippecanoe #contour
#!/bin/sh
for size in 500 200 100 50 20 10 ; do
if [ $size -ne 10 ]; then
rm $size"m.geojson"
fi
awk -v size=$size 'BEGIN{
ele[500]=9
ele[200]=10
@typebrook
typebrook / Makefile
Last active July 31, 2022 00:23
[rudymap-wiki] Parse rudymap mapsforge style file and create a Markdown #mapsforge #rudymap
all: detail-layers detail-cats
MOI_OSM.xml:
curl -o $@ https://raw.githubusercontent.com/alpha-rudy/taiwan-topo/master/styles/mapsforge_style/MOI_OSM.xml
rudymap.json: MOI_OSM.xml
xq . <$< >$@
layers: rudymap.json
@jq -r '.rendertheme.stylemenu.layer | map(select(has("overlay"))) + map(select(has("overlay") | not)) | .[] | .["@id"]' $< | tee $@
@typebrook
typebrook / geojson2gpx.sh
Last active July 31, 2022 00:23
[geojson-script] Transform geojson from GoPro video to gpx format, jq needed #geojson #gpx #garmin
#!/bin/bash
paste <(jq '.geometry.coordinates[]' $1 -c | sed -r 's/\[|\]//g' \
|sed -r 's/^([^,]+),([^,]+),.*/<trkpt lat="\2" lon="\1">/') \
<(jq '.properties.AbsoluteUtcMicroSec[]' $1 \
| sed -r 's/(.*)(.{3})$$/\1,\2/' \
| xargs -I time date -d @time +"%Y-%m-%dT%H:%M:%S") |\
# If you want to keep points at the same seconds, comment out the next line
uniq -f3 |\
sed -r 's/\t(.*)/<time>\1<\/time><\/trkpt>/' |\
@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 / 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
@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