Skip to content

Instantly share code, notes, and snippets.

View bdon's full-sized avatar
😈

Brandon Liu bdon

😈
View GitHub Profile
AWSTemplateFormatVersion: 2010-09-09
Description: Serve Z/X/Y tiles through CloudFront + Lambda from an existing S3 bucket.
Parameters:
BucketName:
Description: >-
Name of an existing S3 bucket with .pmtiles tilesets. Should be in the
same region as your CloudFormation stack.
Type: String
MinLength: 1
AllowedOrigins:
@bdon
bdon / example.html
Created October 13, 2022 03:43
example use of pmtiles 2.0.0 with maplibre
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Display a map</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://unpkg.com/[email protected]/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/[email protected]/dist/maplibre-gl.css" rel="stylesheet" />
<script src="https://unpkg.com/[email protected]/dist/index.js"></script>
<style>
https://openstreetmap.org/node/26576197 ပခုက္ကူ 0.9140664431808709
https://openstreetmap.org/node/820845909 မိုးဗြဲ 0.9686313336939457
https://openstreetmap.org/node/1946810043 ကင္ပြန္းစခန္း-ကိ်ဳက္ထီး႐ိုးေတာင္ေျခ 1.0
https://openstreetmap.org/node/2107682363 ရွာမ 0.9412252972861319
https://openstreetmap.org/node/2468412726 ၿမိဳ႕မ​ေစ်း 0.9999999997070517
https://openstreetmap.org/node/2468414164 ေျမာက္ဦးေက်ာင္း 1.0
https://openstreetmap.org/node/2618245205 ေပါက္ေက်ာ္ 1.0
https://openstreetmap.org/node/2618245206 သစ္ေတာ၂၄၄ စိုက္ပ်ိဴးေမႊးျမူေရးျခံ 1.0
https://openstreetmap.org/node/2618249873 သစ္ေတာ၂၄၄ စိုက္ပ်ိဴးေမႊးျမူေရးျခံ 1.0
https://openstreetmap.org/node/2618459630 ေရႊေညာင္ပင္ 1.0
@bdon
bdon / index.html
Created June 6, 2021 06:00
MapLibre Protocol: PMTiles implementation
<!DOCTYPE html>
<html lang="en">
<head>
<title>MapLibre GL JS debug page</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel='stylesheet' href='../dist/maplibre-gl.css' />
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
name moedict_z cedict_z moedict_p cedict_p link
獅子鄉 ㄕ ˙ㄗ ㄒㄧㄤ ㄕ ㄗˇ ㄒㄧㄤ shī zi xiāng shī zǐ xiāng https://openstreetmap.org/node/60655623
北埔鄉 ㄅㄟˇ ㄆㄨˇ ㄒㄧㄤ ㄅㄟˇ ㄅㄨˋ ㄒㄧㄤ běi pǔ xiāng běi bù xiāng https://openstreetmap.org/node/60655628
大埔鄉 ㄉㄚˋ ㄆㄨˇ ㄒㄧㄤ ㄉㄚˋ ㄅㄨˋ ㄒㄧㄤ dà pǔ xiāng dà bù xiāng https://openstreetmap.org/node/60655653
新埔鎮 ㄒㄧㄣ ㄆㄨˇ ㄓㄣˋ ㄒㄧㄣ ㄅㄨˋ ㄓㄣˋ xīn pǔ zhèn xīn bù zhèn https://openstreetmap.org/node/60655661
埔里鎮 ㄆㄨˇ ㄌㄧˇ ㄓㄣˋ ㄅㄨˋ ㄌㄧˇ ㄓㄣˋ pǔ lǐ zhèn bù lǐ zhèn https://openstreetmap.org/node/60655696
暖暖區 ㄒㄩㄢ ㄒㄩㄢ ㄑㄩ ㄋㄨㄢˇ ㄋㄨㄢˇ ㄑㄩ xuān xuān qū nuǎn nuǎn qū https://openstreetmap.org/node/60655705
新埤鄉 ㄒㄧㄣ ㄆㄧˋ ㄒㄧㄤ ㄒㄧㄣ ㄆㄧˊ ㄒㄧㄤ xīn pì xiāng xīn pí xiāng https://openstreetmap.org/node/60655719
埔心鄉 ㄆㄨˇ ㄒㄧㄣ ㄒㄧㄤ ㄅㄨˋ ㄒㄧㄣ ㄒㄧㄤ pǔ xīn xiāng bù xīn xiāng https://openstreetmap.org/node/60655748
內埔鄉 ㄋㄟˋ ㄆㄨˇ ㄒㄧㄤ ㄋㄟˋ ㄅㄨˋ ㄒㄧㄤ nèi pǔ xiāng nèi bù xiāng https://openstreetmap.org/node/60655774
name moedict_z cedict_z moedict_p cedict_p
85度C ㄉㄨˋ ㄉㄨㄛˊ duó
頂好 ㄉㄧㄥˇ ㄏㄠˇ ㄉㄧㄥˇ ㄏㄠˋ dǐng hǎo dǐng hào
頂好 ㄉㄧㄥˇ ㄏㄠˇ ㄉㄧㄥˇ ㄏㄠˋ dǐng hǎo dǐng hào
台科大第一學生餐廳 ㄊㄞˊ ㄎㄜ ㄉㄚˋ ㄉㄧˋ ㄧ ㄒㄩㄝˊ ㄕㄥ ㄘㄢ ㄊㄧㄥ ㄊㄞˊ ㄎㄜ ㄉㄞˋ ㄉㄧˋ ㄧ ㄒㄩㄝˊ ˙ㄕㄥ ㄘㄢ ㄊㄧㄥ tái kē dà dì yī xué shēng cān tīng tái kē dài dì yī xué sheng cān tīng
女巫店 ㄋㄩˇ ㄨˊ ㄉㄧㄢˋ ㄋㄩˇ ㄨ ㄉㄧㄢˋ nǚ wú diàn nǚ wū diàn
得記麵包 ㄉㄜˊ ㄐㄧˋ ㄇㄧㄢˋ ㄅㄠ ㄉㄟˇ ㄐㄧˋ ㄇㄧㄢˋ ㄅㄠ dé jì miàn bāo děi jì miàn bāo
水源市場 ㄕㄨㄟˇ ㄩㄢˊ ㄕˋ ㄔㄤˊ ㄕㄨㄟˇ ㄩㄢˊ ㄕˋ ㄔㄤˇ shuǐ yuán shì cháng shuǐ yuán shì chǎng
雪可屋咖啡茶館 ㄒㄩㄝˇ ㄎㄜˇ ㄨ ㄎㄚ ㄈㄟ ㄔㄚˊ ㄍㄨㄢˇ ㄒㄩㄝˇ ㄎㄜˋ ㄨ ㄎㄚ ㄈㄟ ㄔㄚˊ ㄍㄨㄢˇ xuě kě wū kā fēi chá guǎn xuě kè wū kā fēi chá guǎn
國立台灣科技大學研揚大樓停車場 ㄍㄨㄛˊ ㄌㄧˋ ㄊㄞˊ ㄨㄢ ㄎㄜ ㄐㄧˋ ㄉㄚˋ ㄒㄩㄝˊ ㄧㄢˊ ㄧㄤˊ ㄉㄚˋ ㄌㄡˊ ㄊㄧㄥˊ ㄔㄜ ㄔㄤˊ ㄍㄨㄛˊ ㄌㄧˋ ㄊㄞˊ ㄨㄢ ㄎㄜ ㄐㄧˋ ㄉㄚˋ ㄒㄩㄝˊ ㄧㄢˊ ㄧㄤˊ ㄉㄚˋ ㄌㄡˊ ㄊㄧㄥˊ ㄔㄜ ㄔㄤˇ guó lì tái wān kē jì dà xué yán yáng dà lóu tíng chē cháng guó lì tái wān kē jì dà xué yán yáng dà lóu tíng chē chǎng
import freetype
import osmium
import sys
face = freetype.Face("/System/Library/Fonts/STHeiti Medium.ttc")
def check_tags(t,o):
for k,v in o.tags:
if k == 'name':
for char in v:
import csv
import sys
import json
from urllib import request, parse
from urllib.parse import quote
import time
features = []
with open(sys.argv[1],'r') as csvfile:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bdon
bdon / 1_lazy.py
Last active June 26, 2018 23:28
lazy
# example of how to make a method invocation
# "lazy" by not doing the work until first access
class A:
def __init__(self):
self.mValue = None
def getValue(self):
if not self.mValue:
print("doing something expensive")
self.mValue = "value"