Skip to content

Instantly share code, notes, and snippets.

View ckhung's full-sized avatar

Chao-Kuei Hung ckhung

View GitHub Profile
#!/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
Created September 4, 2021 02:07
把 「xml-js 所轉出的噗浪 rss => json」 再轉成 html
#!/usr/bin/python3
# for f in *.xml ; do xml-js $f --compact | jq . > ${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')
@ckhung
ckhung / xfadeffmpeg.py
Created May 22, 2021 02:46
generate ffmpeg command to do xfade
#!/usr/bin/python3
# https://stackoverflow.com/a/66546687
# https://newtoypia.blogspot.com/2021/05/ffmpeg.html
# 一口氣串接爆多影片? ffmpeg 拯救可憐的手指
import argparse, subprocess, re
def gen_filter(segments, effect='fade', duration=0.3):
video_fades = ''
# fail! audio_fades = '\\\n[0:a]aresample=async=1;'
@ckhung
ckhung / json2erd.py
Last active March 14, 2024 09:40
[Generating ER Diagrams directly from *.sql files without even installing mysql](https://ckhung.medium.com/drawing-er-diagram-from-sql-file-alone-e7bef8cfe34b) / [在命令列上從 *.sql 檔直接產生 ER Diagram](https://newtoypia.blogspot.com/2022/04/sql-er-diagram.html)
#!/usr/bin/python3
# convert the output (as json) of
# https://github.com/iamcal/SQLParser
# to the input of
# https://github.com/BurntSushi/erd
# or to the input of
# https://github.com/ehne/ERDot
#
# For example, suppose you have ~/sakila-schema.sql from https://downloads.mysql.com/docs/sakila-db.tar.gz