Skip to content

Instantly share code, notes, and snippets.

@kkdd
kkdd / file0.txt
Last active February 23, 2020 05:17
find コマンドの出力を while read ループ処理(シェルスクリプト) ref: https://qiita.com/kkdd/items/3665b208a448c965aeb2
$ ./ls.sh "*.jpg"
./1.jpg
./2.jpg
./3.jpg
@kkdd
kkdd / tky2wgs_approx.py
Last active January 23, 2020 12:18
日本測地系からWGS84へ変換 ref: https://qiita.com/kkdd/items/f5ac764d5e35c1b540fe
# angle units in degrees
def tky2wgs_approx(lon_tky, lat_tky, degree=2):
L = lon_tky - 135
B = lat_tky - 35
if degree == 1:
dL = -2.80641517e-3 - 4.98891541e-5*B - 8.33469263e-5*L
dB = 3.20321021e-3 - 1.15452990e-4*B + 2.47032059e-5*L
elif degree == 2:
a00,a01,a02,a03,a04,a05,a10,a11,a12,a13,a14,a15 = -2.79648156e-03, -3.64571151e-05, -1.00958714e-06, -8.83091873e-05, -8.33002662e-07, 3.54561248e-07, 3.19774649e-03, -1.13997082e-04, -7.51313530e-07, 2.34640477e-05, 6.06731757e-07, 3.28340222e-07
dL = a00+a01*B+a02*B**2+a03*L+a04*B*L+a05*L**2
@kkdd
kkdd / file0.txt
Last active March 12, 2018 14:01
Python から JavaScript ソース(zlib 圧縮データも含める)を生成 ref: https://qiita.com/kkdd/items/755cad98b2fa2d74f731
$ ./print_html.py > temp.html
$ cat temp.html
<script src="pako.min.js"></script>
<script>
var jsonz = "789cab56caad54b252502a2e2d482d52d251502a0033ac14a24d4ccd74144ccdcc63818289e5a9c5f9b9a920850589d9f94ab500bf3b1015";
console.log(parse(jsonz));
function parse(hexstr) {
return JSON.parse(pako.inflate(unhexlify(hexstr), {to: 'string'}));
}
@kkdd
kkdd / file0.txt
Last active September 9, 2020 14:06
Viterbi アルゴリズム(最適経路解法) ref: https://qiita.com/kkdd/items/6cbd949d03bc56e33e8e
$ ./viterbi.py 1 2 4 4 2 1
0. transition: [0]
1. transition: [0, 0]
2. transition: [1, 1, 1, 1]
3. transition: [3, 3, 2, 3]
4. transition: [1, 3]
5. transition: [1]
minimum_cost_path = [0, 1, 3, 3, 1, 0]
@kkdd
kkdd / file0.txt
Last active July 7, 2020 14:40
OpenStreetMap データ(japan-latest.osm.pbf)から指定範囲切り出し ref: https://qiita.com/kkdd/items/b30db8fe72ad3861ad74
$ wget https://download.geofabrik.de/asia/japan-latest.osm.pbf
$ wget https://download.geofabrik.de/asia/japan.poly
@kkdd
kkdd / du_dir.sh
Last active September 8, 2019 10:22
ディレクトリに含まれるサイズの大きいファイルを検索(シェルスクリプト) ref: https://qiita.com/kkdd/items/21c3707b4d5f0a7f6bb1
#!/bin/sh
### default value
nmax=4
###
for OPT in "$@"
do
case "$OPT" in
-n* )
nmax="$(echo $1 | sed 's/^-n//')"
@kkdd
kkdd / file0.txt
Last active February 12, 2018 11:00
ディレクトリ内のファイルの改行コードをLFに統一(nkfコマンド) ref: https://qiita.com/kkdd/items/ac8796b790dc5978aadf
$ nkf --guess * | grep -e MIXED\ NL -e CR | awk -F: '{print $1}' | xargs nkf -Lu -d --overwrite
$ nkf --guess * | grep -e EUC-JP -e Shift_JIS | awk -F: '{print $1}' | xargs nkf -Lu --overwrite
$ nkf --guess * | awk '{$1=""; print $0}' | sort | uniq
ASCII
ASCII (LF)
BINARY
UTF-8 (LF)
@kkdd
kkdd / file0.txt
Last active February 20, 2018 15:07
pip コマンドでパッケージ名を完全一致で検索(シェルスクリプト) ref: https://qiita.com/kkdd/items/137574dd346ac2160f07
$ ./pip_search.sh gdal
using pip pip3
GDAL (2.2.3) - GDAL: Geospatial Data Abstraction Library
INSTALLED: 2.2.3 (latest)
GDAL (2.2.3) - GDAL: Geospatial Data Abstraction Library
INSTALLED: 2.2.3 (latest)
@kkdd
kkdd / file0.txt
Last active February 5, 2018 12:41
Leaflet.VectorGrid で GeoJSON データの読み込み ref: https://qiita.com/kkdd/items/b696a5a305ceb93829fa
loading county.geo.json 1325 ms
parsing 195.67 MB 9515 ms
indexing 3221 features
with 7384329 vertexes and 0 points
adding to map 17426 ms
@kkdd
kkdd / file0.txt
Last active January 26, 2018 13:42
NetworkX の有向グラフをプロット(netgraph) ref: https://qiita.com/kkdd/items/44cd46e4b3e8e18d3185
$ pip install netgraph