Skip to content

Instantly share code, notes, and snippets.

View tianyuf's full-sized avatar

Tianyu Fang tianyuf

View GitHub Profile
@tianyuf
tianyuf / thucydides-chaoyang-trap
Created September 23, 2021 17:30
Thucydides' Chaoyang Trap: Can Beijing and Washington avoid the Chaoyang Trap?
// ==UserScript==
// @name Thucydides' Chaoyang Trap
// @namespace https://chaoyang.substack.com/
// @version 0.1
// @description Can Beijing and Washington avoid the Chaoyang Trap?
// @author Tianyu Fang (tianyu [at] chaoya.ng)
// @match *://*/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
@tianyuf
tianyuf / prc_travel_doc_name_encoder.py
Last active August 23, 2024 10:25
To represent Chinese characters in the machine-readable zone of Chinese passports and other border-crossing documents, the Chinese government uses an algorithm to convert Chinese words into MRZ-compliant characters. The conversion chart is found on the back cover of GA/T 704.14-2015, "Information codes for entry-exit administration. Part 14: Ser…
#!/usr/bin/env python
"""
To represent Chinese characters in the machine-readable zone of Chinese passports
and other border-crossing documents, the Chinese government uses an algorithm to
convert Chinese words into MRZ-compliant characters.
The conversion chart is found on the back cover of GA/T 704.14-2015, "Information
codes for entry-exit administration. Part 14: Serial labels of machine-readable
codes on travel permit for residents of Hong Kong and Macao to visit the mainland
of China."

Keybase proof

I hereby claim:

  • I am tianyuf on github.
  • I am tianyu (https://keybase.io/tianyu) on keybase.
  • I have a public key whose fingerprint is F8DD E4A7 F9C8 7FC8 1261 368E 78F8 6B98 6F05 7FD0

To claim this, I am signing this object:

@tianyuf
tianyuf / baidu-as-a-network-utility.css
Created May 14, 2016 15:03
BaaN: Baidu as a Network Utility - 百度的实用主义方法论.
@-moz-document domain("baidu.com") {
body {
display: none;
}
html {
margin: 30px;
}
html::after {
body {
font-family: var(--SanFrancisco);
}
.zu-top {
background: white;
border-top: 3px solid #b92b27;
/*#086ed5*/
box-shadow: 0 5px 2px -2px rgba(200,200,200,0.2);
border-bottom: none;
@-moz-document domain("zhihu.com") {
body {
font-family: var(--SanFrancisco);
}
.zu-top {
background: white;
border-top: 3px solid #b92b27;
/*#086ed5*/
box-shadow: 0 5px 2px -2px rgba(200,200,200,0.2);
border-bottom: none;
// ==UserScript==
// @name 4sq SU Progress Bar w/ Number
// @author Tianyu Fang
// @namespace http://tianyuf.xyz/
// @description Show Foursquare SU test progress bar with number
// @include https://foursquare.com/edit/*
// ==/UserScript==
var display = function(){
var review = document.querySelector("#flag-contents > div.suBar > div > div.wideColumn > ul > li:nth-child(1) > div > div").style.width;
cp "~/Library/Application Support/Google/Chrome Canary/Default/databases/chrome-extension_fjnbnpbmkenffdnngjfgmeleoegfcffe_0/26" ~/Dropbox/stylish_backup
mv "~/Dropbox/stylish_backup" "~/Dropbox/stylish_backup_`date +%+`"
@tianyuf
tianyuf / fm-megaminimal.css
Last active November 19, 2021 18:00
FastMail Megaminimal
/* This theme works with Stylish and FastMail.com Web. Please first set your FastMail theme to "Minimal". */
body {
font-family: "Roboto", sans-serif;
}
a {
color: #003445;
}
.app-toolbar {
background: #fff;