View gh2umap.sh
This file contains 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
#!/bin/bash | |
# usage: gh2umap.sh directions.gpx > directions.geojson | |
# see http://newtoypia.blogspot.tw/2015/07/fs-biking.html | |
TMPDIR=/tmp/gh2umap-$$ | |
mkdir $TMPDIR | |
ogr2ogr -f geojson $TMPDIR/tr.geojson $1 tracks | |
jq '.features' $TMPDIR/tr.geojson > $TMPDIR/tracks.geojson | |
ogr2ogr -f geojson $TMPDIR/rp.geojson $1 route_points | |
opencc < $TMPDIR/rp.geojson | jq '.features | map(.properties+={_storage_options: {"iconClass": "Ball"}} | .properties.name=.properties.desc )' > $TMPDIR/route_points.geojson |
View get-mail-header.perl
This file contains 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/perl -w | |
# http://newtoypia.blogspot.com/2015/09/gmail-mbox.html | |
# 備份/清空 gmail, 以及命令列查詢/切割 mbox 格式檔案 | |
use MIME::Base64; | |
while (<STDIN>) { | |
foreach $kw (@ARGV) { | |
next unless (($line) = /^$kw:\s*(.*)/); | |
$line = decode_base64($1) | |
if $line =~ /=\?utf-8\?\w+\?(.*)/i; |
View slippy-tiles.py
This file contains 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/python | |
# http://newtoypia.blogspot.com/2015/09/vector-tiles.html | |
# 用向量圖磚 (vector tiles) 自製陽春離線地圖 | |
import math, sys, argparse, os, re | |
def deg2tile_id(zoom,lon,lat): | |
lat_rad = math.radians(lat) | |
n = 2.0 ** zoom | |
xtile = int((lon + 180.0) / 360.0 * n) |
View multi2maxpolygon.py
This file contains 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/python | |
# -*- coding: utf-8 -*- | |
# http://newtoypia.blogspot.tw/2015/08/admin-boundary.html | |
# 「臺灣各級行政區域(縣市/鄉鎮/村里)邊界座標檔, 自選解析度、 存成 csv、 畫成 svg 」 | |
import json, argparse, sys, math, warnings | |
def area(coords): | |
n = len(coords) | |
if n < 3: |
View geojson2csv.py
This file contains 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/python | |
# -*- coding: utf-8 -*- | |
# http://newtoypia.blogspot.tw/2015/08/admin-boundary.html | |
# 「臺灣各級行政區域(縣市/鄉鎮/村里)邊界座標檔, 自選解析度、 存成 csv、 畫成 svg 」 | |
import json, argparse, sys, math, warnings | |
def ispoint(coords): | |
return isinstance(coords, list) and isinstance(coords[0], (int, long, float)) and len(coords)==2 |
View toCammel.perl
This file contains 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/perl -wp | |
my @saved = (); | |
while (s#((['"]).*?\2)#<<toCammelSkip>>#) { | |
push @saved, $1; | |
} | |
while (/([a-z0-9]+)(_[a-z0-9]+)+/i) { | |
$cammelled = $orig = $&; | |
$cammelled =~ s/(_[a-z0-9]+)/$x=substr($1,1); "\u$x"/ieg; |
View gen-dot-tree.py
This file contains 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/python | |
import argparse, numpy as np | |
def gen_tree(depth, id, branch): | |
label = id if args.label is None else args.label | |
print ' '*depth + id + '[label="' + label + '"];' | |
if depth >= args.depth: | |
return | |
nchild = np.random.poisson(branch) |
View dynamic-legend.html
This file contains 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
<html> | |
<head> | |
</head> | |
<body> | |
<div id="main-content"> | |
</div> | |
<script type="text/javascript" src="d3.js"></script> | |
<script type="text/javascript" src="d3-legend.js"></script> | |
<script> | |
var canvas = d3.select('#main-content') |
View falc.perl
This file contains 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/perl -w | |
# http://newtoypia.blogspot.tw/2015/08/cordova-debug.html | |
# 徒手除錯 Cordova | |
$kw = ($ARGV[0] or "console"); | |
while (<STDIN>) { | |
if (m#console#i) { | |
print "\x1b[30;46m$_\x1b[m"; | |
} elsif (m#$kw#i) { | |
print "\x1b[31m$_\x1b[m"; | |
} elsif (not m#^[VDIW]/#) { |
View tidy.conf
This file contains 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
# 詳見 「既輕鬆上手又無限擴充的跨平臺文字編輯器 geany」 | |
# http://newtoypia.blogspot.tw/2016/03/geany.html | |
tidy-mark: yes | |
markup: yes | |
wrap: 40 | |
tab-size: 8 | |
indent: auto | |
indent-spaces: 2 | |
output-xhtml: yes | |
doctype: loose |
OlderNewer