This file contains hidden or 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 | |
| # screenshot caption concatenation | |
| # assumption: | |
| # 1. all screenshot files are of the same extension, of the same size, with ordered file names. | |
| # 2. there are no other files with names sscapcat[059]-* in /tmp. | |
| read -r x_pad y_header y_content y_caption out_file <<<$(echo 0 0 0 0 result.jpg) | |
| while getopts 'x:y:o:h' opt; do |
This file contains hidden or 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
| # Norman Wildberger + Dean Rubine | |
| # Finding a root of a cubic polynomial with geode | |
| # https://youtu.be/oIHd3zDDDCE?si=BIlgB9ub57UPdJ38&t=1730 | |
| def Q(t2, t3): | |
| return 1 + (t2+t3) * (1+2*t2+3*t3+5*t2*t2+16*t2*t3+12*t3*t3) | |
| def shift(C, ap): | |
| return [ | |
| C[0] + ap*C[1] + ap*ap*C[2] + ap*ap*ap*C[3], |
This file contains hidden or 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
| // dot -Tsvg flow.dot > flow.svg | |
| digraph "gs2umap 資料流向 (上下游關係)" { | |
| rankdir = TB; | |
| overlap = scale; | |
| key [ label="gsheet-key.txt" ]; | |
| gs [ label="google sheet" ]; | |
| php [ label="gs2umap.php" ]; | |
| python [ label="gs2umap.py" ]; |
This file contains hidden or 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 | |
| // 共筆維護試算表、地圖自動更新 https://newtoypia.blogspot.com/2025/03/gsheet-umap.html | |
| if (! (isset($_GET['html']) && filter_var($_GET['html'], FILTER_VALIDATE_URL))) { | |
| echo 'needs "html" variable on command line'; | |
| return; | |
| } | |
| $url = $_GET['html']; | |
| $htmlContent = file_get_contents($url); | |
| $tmpHtmlFile = tempnam(sys_get_temp_dir(), 'html_'); |
This file contains hidden or 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 | |
| # This script processes the output of: | |
| # notmuch show --format=json '*' | jq 'map(.[0][0] | [.headers.Date, .id, .headers.Subject])' | |
| # to create a csv file with date time strings that are easier to sort. | |
| use Date::Parse; | |
| while (<>) { | |
| next unless /"(.*)"/; | |
| my $item = $1; |
This file contains hidden or 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 | |
| import argparse, re, csv | |
| parser = argparse.ArgumentParser( | |
| description='read csv files and print to stdout in vcf format', | |
| formatter_class=argparse.ArgumentDefaultsHelpFormatter) | |
| parser.add_argument('-d', '--delimiter', type=str, default=',', | |
| help='field delimiter character') | |
| parser.add_argument('mapping', |
This file contains hidden or 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
| # ~/.mbsyncrc | |
| # modified from https://www.cosroe.com/2024/05/neomutt-isync.html | |
| # Global defaults that apply to all channels / accounts / stores | |
| # Create in both places | |
| Create Both | |
| # Do not remove if missing in one place | |
| Remove None | |
| # Permanently delete those messages marked for deletion |
This file contains hidden or 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/env python3 | |
| # https://stackoverflow.com/a/12803967 | |
| # IMAP folder path encoding (IMAP UTF-7) for Python | |
| import sys, re | |
| from imapclient import imap_utf7 | |
| for line in sys.stdin: | |
| line = line.strip().encode('ascii') |
This file contains hidden or 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
| # lagrange points as seen using effective potential plot | |
| len(x,y) = sqrt(x*x+y*y) | |
| # mass of planet relative to that of star | |
| alpha = 0.01 # "mu" in wikipedia | |
| # mass of star and mass of planet | |
| Ms = 1000 | |
| Mp = Ms * alpha |
This file contains hidden or 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
| # 2025/10/04 把原先的黃/綠色框改成紫色框,跟 Sweet-Dark-v40 原來的顏色比較搭 | |
| ACTIVE_BORDER_COLOR="#ce93ff" | |
| INACTIVE_BORDER_COLOR="#7944aa" | |
| TITLE_HEIGHT=18 | |
| for i in 1 2 3 4 5 ; do convert -size 24x$TITLE_HEIGHT xc:$ACTIVE_BORDER_COLOR title-$i-active.png ; done | |
| convert -size 5x$TITLE_HEIGHT xc:$ACTIVE_BORDER_COLOR top-left-active.png | |
| convert -size 5x$TITLE_HEIGHT xc:$ACTIVE_BORDER_COLOR top-right-active.png | |
| convert -size 3x16 xc:$ACTIVE_BORDER_COLOR left-active.png | |
| convert -size 3x16 xc:$ACTIVE_BORDER_COLOR right-active.png |
NewerOlder