Skip to content

Instantly share code, notes, and snippets.

View ckhung's full-sized avatar

Chao-Kuei Hung ckhung

View GitHub Profile
@ckhung
ckhung / country-codes.csv
Last active April 28, 2023 12:05
Prepend the 3-letter ISO country code and continent name to every line, except the 1st line, of a csv file containing country names
iso3 m49 owid_name other_name reg1 reg2 continent region_type is_historical defined_by
ABW 533 Aruba Aruba Caribbean Latin America and the Caribbean North America country False owid
AFG 4 Afghanistan Afghanistan Southern Asia Asia country False owid
AGO 24 Angola Angola Middle Africa Sub-Saharan Africa Africa country False owid
AIA 660 Anguilla Anguilla Caribbean Latin America and the Caribbean North America country False owid
ALA 248 Åland Islands Aland Islands Northern Europe Europe country False owid
ALB 8 Albania Albania Southern Europe Europe country False owid
AND 20 Andorra Andorra Southern Europe Europe country False owid
ANT Netherlands Antilles country True owid
ARE 784 United Arab Emirates United Arab Emirates Western Asia Asia country False owid
@ckhung
ckhung / pfs.py
Last active January 12, 2022 11:42
priority first search on a graphviz dot file
#!/usr/bin/python3
# See this article for more explanations:
# https://ckhung.medium.com/4-in-1-priority-first-search-in-python-bfs-dfs-prims-and-dijkstra-s-algorithms-4e9fe8ccba87
# pip3 install pqdict pydot networkx
# python3 pfs.py -a dijk -0 E t02.dot
# python3 pfs.py -a prim -0 G t02.dot
# https://github.com/nvictus/priority-queue-dictionary
#!/usr/bin/python3
# https://medium.com/mycrypto/the-journey-from-mnemonic-phrase-to-address-6c5e86e11e14
# pip3 install bip_utils
# python3 bip_demo.py
# For the 1st example, private key and address of path0
# have been verified using exodus wallet.
# For the 2nd example, the computed master key does not match the article...?
# If you have a private key stored in a file named priv_key_file.txt
# this program will also create a derived pair of keys from it
# as a 3rd example.
@ckhung
ckhung / gecko.php
Last active December 5, 2021 04:05
generate a csv listing of your favorite cryptocurrencies, suitable for importing into a google sheet
<?php
// usage:
// http://.../gecko.pgp??q=bitcoin,ethereum,solana,polkadot
// or
// http://.../gecko.pgp??q=mycrypto.csv
// where mycrypto.csv contains the id of a coin on each line.
// Find the exact id of your coin in this list:
// https://api.coingecko.com/api/v3/coins/list
// See this doc for more info:
@ckhung
ckhung / example.pdmenu
Last active December 3, 2021 02:37
pdmenu example
# https://newtoypia.blogspot.com/2021/09/pdmenu.html
# pdmenu 幫麻瓜製作常用功能文字選單
title:貴哥的 pdmenu 教學範例
color:desktop:yellow:black
color:menu:yellow:blue
color:menuhot:cyan:blue
color:unselmenu:green:black
color:selbar:black:yellow
@ckhung
ckhung / mcnc.py
Last active December 3, 2021 02:33
multicast netcat
#!/usr/bin/python3
# multicast netcat
# https://newtoypia.blogspot.com/2021/09/netcat.html
# 齊步走! 用 netcat 同步指揮教室裡的所有電腦
import argparse, sys, re, readline
from warnings import warn
from subprocess import Popen, PIPE
@ckhung
ckhung / _voicmd.py
Last active September 4, 2021 07:26
primitive voice command interface w/ pocketsphinx as backend
#!/usr/bin/python3
import argparse, os, re
from warnings import warn
import subprocess
parser = argparse.ArgumentParser(
description='invoke pocketsphinx and produce keystrokes',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-k', '--kwokfn', type=str, default='',
@ckhung
ckhung / prj2html.py
Last active May 28, 2024 08:57
噗浪 rss: 用 xq 轉 json 再用 prj2html.py 轉 html
#!/usr/bin/python3
# for f in *.xml ; do xq . $f > ${f/%xml/json} ; done
# python3 prj2html.py *.json > new.html
# 詳見 https://newtoypia.blogspot.com/2021/09/xml-js-jq-rss.html
import argparse, json, re
from warnings import warn
#!/usr/bin/python3
# https://github.com/pyexcel/pyexcel-ods/issues/41
# pyexcel-ods issue: use "<text:p>" instead of "<text:line-break/>" for newlines (line breaks) in cells
import argparse, re, sys, json
from pyexcel_ods3 import save_data
from warnings import warn
parser = argparse.ArgumentParser(
description='read many text files into two columns of an ods file, with filenames as the key column and contents as the value column',
@ckhung
ckhung / aasize.py
Last active December 3, 2021 02:28
print android app size as .csv: adb shell dumpsys diskstats | aasize.py
#!/usr/bin/python3
# https://newtoypia.blogspot.com/2021/05/android-app-size.html
# 揪出手機上的腫脹軟體: android app 佔用空間大小散點圖
import argparse, fileinput, re, json
parser = argparse.ArgumentParser(
description='print android app size as .csv: adb shell dumpsys diskstats | aasize.py',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('files', nargs='*', help='files')