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
# https://newtoypia.blogspot.com/2019/01/pandas-multiindex.html | |
# 「拿股票三維資料學習 pandas 的 multiindex」 | |
import re, os, time | |
import pandas as pd | |
import numpy as np | |
from numpy import NaN | |
from warnings import warn | |
datapath = os.environ['HOME']+'/stock/day' |
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/python3 | |
# -*- coding: utf-8 -*- | |
# slightly modified from https://stackoverflow.com/questions/53778588/two-condition-variables-attached-to-the-same-lock-different-behaviors-in-python | |
# 也請見 「概念性、宏觀視野的程序/執行緒同步機制總覽」 | |
# https://newtoypia.blogspot.com/2017/12/synchronization.html | |
# Note: pip3 install colored | |
from threading import Thread, Lock, Condition | |
import time |
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
# https://github.com/lengstrom/fast-style-transfer | |
FROM ckhung/fast-style-transfer:18C | |
# https://www.faqforge.com/linux/how-to-install-ffmpeg-on-ubuntu-14-04/ | |
RUN add-apt-repository -y ppa:mc3man/trusty-media | |
RUN apt-get update | |
RUN apt-get -y dist-upgrade | |
RUN apt-get -y install ffmpeg | |
RUN pip install moviepy | |
# possible ramifications on proxmox: |
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
# https://newtoypia.blogspot.com/2018/09/proxmox-lxc-storage.html | |
# 幫 proxmox 的 lxc 擴充硬碟 | |
arch: amd64 | |
hostname: whale | |
memory: 1024 | |
mp0: local-zfs:subvol-371-disk-2,mp=/var/lib/docker,size=10G | |
net0: bridge=vmbr35,hwaddr=ff:ff:ff:ff:ff:71,ip=192.168.35.99/24,name=eth0,type=veth | |
onboot: 0 | |
ostype: debian | |
rootfs: local-zfs:subvol-371-disk-1,size=4G |
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
<?php | |
# 範例參數: | |
# bus-pos.php?city=Taichung&rid=151 | |
# 其他城市名稱請見 http://ptx.transportdata.tw/ptx/Download/API_URI_Convention%E6%96%87%E4%BB%B6_v1.pdf 第 4 頁 | |
parse_str($_SERVER["QUERY_STRING"], $Q); | |
$time_string = gmdate('D, j M Y H:i:s') . ' GMT'; | |
$signature = base64_encode(hash_hmac("sha1", "x-date: $time_string", $_SERVER['PTX_KEY'], true)); |
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
<?php | |
# PTX (公共運輸整合資訊流通服務平臺) 的 php 查詢範例 | |
# 詳見: https://newtoypia.blogspot.tw/2018/01/ptx-bash-php.html | |
# 使用方式: | |
# php ptx-example.php 'https://ptx.transportdata.tw/MOTC/v2/Bus/DisplayStopOfRoute/City/Taichung/151?%24format=JSON' | |
# 或 | |
# php ptx-example.php 'https://ptx.transportdata.tw/MOTC/v2/Bus/DisplayStopOfRoute/City/Taichung/151?%24format=JSON' 'Thu, 10 Feb 2022 09:07:10 GMT' | |
# 本程式不需要任何外加套件; 但關於 「如何保護私密資訊」, 請見 | |
# http://phpsec.org/projects/guide/3.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
#!/bin/bash | |
# PTX (公共運輸整合資訊流通服務平臺) 的 bash 查詢範例 | |
# 詳見: https://newtoypia.blogspot.tw/2018/01/ptx-bash-php.html | |
# 需要安裝 httpie 及 openssl 等套件 | |
# 使用方式: | |
# ./ptx-example.bash 'https://ptx.transportdata.tw/MOTC/v2/Bus/DisplayStopOfRoute/City/Taichung/151?%24format=JSON' | |
# 或 | |
# ./ptx-example.bash 'https://ptx.transportdata.tw/MOTC/v2/Bus/DisplayStopOfRoute/City/Taichung/151?%24format=JSON' 'Thu, 10 Feb 2022 09:07:10 GMT' | |
# 會印出 (1) http 指令 (2) 查詢結果 | |
# (3) 查詢用的時間戳記及簽章 (在五分鐘內可供再次使用) |
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/python3 | |
# coding=utf-8 | |
# -*- coding: utf-8 -*- | |
# example output at umap: https://umap.openstreetmap.fr/zh-tw/map/python3-gj-voronoipy-tkecgeojson_774525 | |
import argparse, scipy, warnings, json, scipy.spatial, math | |
import numpy as np | |
def voronoi(data): | |
if type(data) is dict: |
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 | |
# -*- coding: utf-8 -*- | |
# This script adds an "area" field (in square meters) | |
# and a "centroid" field to feature.geometry | |
# for Polygon's and MultiPolygon's in a geojson file. | |
# Usage example: | |
# ./gj-area-centroid.py university.geojson |
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/gnuplot | |
# http://gnuplot.sourceforge.net/demo/transparent.html | |
Gauss(x,mu,sigma) = 1./(sigma*sqrt(2*pi)) * exp( -(x-mu)**2 / (2*sigma**2) ) | |
set xrange [-4:4] | |
plot \ | |
Gauss(x,0.03,1.02) title '', \ | |
Gauss(x,-0.05,1.03) title '', \ | |
Gauss(x,0.05,0.98) title '', \ | |
Gauss(x,0.02,0.97) title '', \ | |
Gauss(x,-0.02,0.96) title '' |