Skip to content

Instantly share code, notes, and snippets.

@alexkuang0
alexkuang0 / mweb-solarized-light-alexkuang0-mod.css
Last active January 13, 2021 08:01
MWeb Preview CSS mod for better PDF export and font size consistency.
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
nav,
section,
@alexkuang0
alexkuang0 / 青蛙兒歌.wy
Created December 27, 2019 16:10
挺無聊地試用一下文言 wenyan-lang
吾有一術。名之曰「青蛙兒歌」
欲行是術。必先得一物。曰「蛙數」。
乃行是術曰。
吾有一物。曰「蛙數」。名之曰「口」
乘「蛙數」以二。名之曰「目」。
乘「蛙數」以四。名之曰「足」。
批曰。字符串合併
加「蛙數」以「「隻青蛙」」。名之曰「言」。
加「言」以「口」。名之曰「言」。
@alexkuang0
alexkuang0 / thor-downloader.py
Last active April 3, 2020 08:57
thor-downloader
import requests
from bs4 import BeautifulSoup
main_url = "https://www.thorlabs.com/newgrouppage9.cfm?objectgroup_id=3569"
main_page = BeautifulSoup(requests.get(main_url).text, 'html.parser')
products = main_page.find_all(class_="prodNumber")
prod_urls = []
for product in products:
prod_urls.append("https://www.thorlabs.com/" + product.contents[0].get('href'))
@alexkuang0
alexkuang0 / calc_hexagram.py
Last active April 22, 2020 20:18
Calculate Hexagram for Ancient Chinese divination. (易经六十四卦)
from random import randint
results = []
for i in range(0,6):
sum = 0
for i in range(0,3):
sum += randint(2, 3)
results.append(sum)
for res in reversed(results):
@alexkuang0
alexkuang0 / use-alexs-lan-play-server.md
Last active January 13, 2021 07:59
(Deprecated) Use Alex's lan-play server on macOS

Install lan-play on macOS

You can either download compiled binary or compile it from source yourself.

Download compiled binary

Go to http://lan-play.com/download

The GitHub releases page currently doesn't provide compiled binary for macOS

@alexkuang0
alexkuang0 / svg2png.sh
Created June 26, 2020 17:45
Batch converting SVG to PNG
for svg in $(ls ./svg); do
filename=$(echo $svg | cut -d'.' -f1)
convert -background none -density 1000 -resize 1000x svg/$(echo $filename).svg png/$(echo $filename).png
echo [DONE] $filename converted!
done
@alexkuang0
alexkuang0 / biliFollower.js
Last active September 27, 2022 06:49
Scriptable iOS 14 Widget - Bilibili followers count monitor 哔哩哔哩粉丝数监控
const UID = args.widgetParameter
if (!/^\d+$/.test(UID)) throw new Error('请提供正确的 UID')
let widget = createWidget(await getData(UID))
if (!config.runsInWidget) {
await widget.presentSmall()
}
@alexkuang0
alexkuang0 / biliNewVid.js
Last active November 5, 2021 14:31
Scriptable iOS 14 Widget - Bilibili latest video in your subcription feed 哔哩哔哩动态最新视频
const UID = 00000000 // 改为你的用户 ID
const COOKIE = "" // (可选,推荐设置)改为你的 cookie
let { title, user, image, videoUrl } = await getVideo(UID, COOKIE)
let widget = createWidget(title, user, videoUrl, image)
if (!config.runsInWidget) {
await widget.presentMedium()
}
@alexkuang0
alexkuang0 / labelMailsByAddress.js
Created December 29, 2020 14:33
Apps Script for Gmail - Label mails by address
const PARENT_LABEL = 'example.com'
const LABEL_SEPARATOR = '-'
const LEVEL_SEPARATOR = '.'
const getLabelOrCreate = (labelName) => GmailApp.getUserLabelByName(labelName) || GmailApp.createLabel(labelName)
function labelMailsByAddress() {
const allTargetThreads = GmailApp.search(`label:${PARENT_LABEL} `)
allTargetThreads.forEach(thread => {
@alexkuang0
alexkuang0 / Brewfile
Created January 13, 2021 07:57
My Homebrew dump file.
tap "beeftornado/rmtree"
tap "homebrew/bundle"
tap "homebrew/cask", "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git"
tap "homebrew/cask-drivers", "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git"
tap "homebrew/cask-fonts", "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git"
tap "homebrew/cask-versions", "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-versions.git"
tap "homebrew/core", "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
tap "homebrew/services"
brew "asciinema"
brew "bat"