Skip to content

Instantly share code, notes, and snippets.

@victorlin
victorlin / speak-chinese-siri-shortcut.md
Created June 8, 2025 18:04
Read Chinese text from clipboard using the Shortcuts app

Read Chinese text from clipboard using the Shortcuts app

Apple's Siri voices sound very natural and are great for learning.

demo.mov

Steps to set up:

1. Download a Siri voice

@victorlin
victorlin / 1-webhook-summary.sh
Last active March 28, 2025 19:17
generate list of webhooks used by all repos under a github organization
ORG="nextstrain"
repos=$(gh api --paginate \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/orgs/$ORG/repos?per_page=100" \
| jq -r '.[].name')
declare -A hook_repos
@victorlin
victorlin / 1_longest_tokens.py
Last active October 26, 2024 21:40 — forked from ctlllll/longest_chinese_tokens_gpt4o.py
Longest tokens per language in gpt4o
import iso639
import json
import langdetect
import tiktoken
REQUIRED_LANGUAGES = ["zh-cn"]
# Minimum for required languages
# Maximum for optional languages
TOKENS_PER_LANGUAGE = 20
@victorlin
victorlin / 1-icons.jpeg
Last active June 26, 2024 15:09
CenturyLink Adtran C424G device table icon options
1-icons.jpeg
@victorlin
victorlin / 1.t
Created October 31, 2022 21:55
testing Cram's temp directories
Create a new file in the test's temp directory.
$ cat newfile.txt
cat: .*: No such file or directory (re)
[1]
$ echo "hello" > newfile.txt
Create a new file in the test runner's temp directory (shared).
$ cat "$TMP"/newfile.txt
@victorlin
victorlin / github-delete-stale-branches.js
Last active March 20, 2024 02:27
Delete stale branches from the GitHub repo's stale branches page (github.com/user/repo/branches/stale). Originally from https://stackoverflow.com/a/69089905
// Paste in browser console and run
async function deleteStaleBranches(delay=500) {
var stale_branches = document.getElementsByClassName('js-branch-delete-button');
for (var i = 0; i < stale_branches.length; i++)
{
stale_branches.item(i).click();
await new Promise(r => setTimeout(r, delay));
}
}

Reset Final Cut Pro Trial

This still works on FCP 10.6.9.

  1. Open Terminal app.

  2. Paste the following line:

    mv -v ~/Library/Application\ Support/.ffuserdata ~/.Trash
@victorlin
victorlin / concat-wyze-video-files.sh
Last active September 10, 2023 20:13
Wyze cameras store video files in a folder hierarchy. This script creates a time lapse video file per hour.
#!/bin/bash
#
# Wyze cameras store video files in a folder hierarchy. This script creates a time lapse video file per hour.
date_folder="$1"
for hour_folder in $(ls "$date_folder")
do
echo "$date_folder-$hour_folder"
for hour_video in $(ls "$date_folder/$hour_folder" | grep -v "\-800k\.mp4")
for ext in 360 MP4 JPG THM LRV
do
mkdir $ext
mv *.$ext $ext
done
@victorlin
victorlin / populate-github-project-beta.py
Last active March 24, 2022 09:28
Helper functions to add all issues of a repository to a GitHub project (beta), with example usage at bottom of script. For https://github.com/github/feedback/discussions/6765
import requests
import json
GH_GRAPHQL_URL = 'https://api.github.com/graphql'
TOKEN = '' # add your PAT with read:org and write:org scope
def get_json_result(query):
headers={'Authorization': f'token {TOKEN}'}
r = requests.post(GH_GRAPHQL_URL, json={'query': query}, headers=headers)