Skip to content

Instantly share code, notes, and snippets.

tevino /
Last active June 21, 2021 08:02
A simulation of The Ultimate Machine built by Claude Shannon
for _ in {1..3}; do
printf '.'
sleep 0.2
tevino /
Created June 6, 2020 06:38
A way of implementing subtraction using addition only. Available operations: loop, assign, add by one. Restrictions: no negative numbers, integers only.
# A way of implementing subtraction using addition only.
# Available operations: loop, assign, add by one.
# Restrictions: no negative numbers, integers only.
# Aadit M Shah on StackOverflow says this method was devised by Stephen Cole Kleene, but I can't find any sources.
def subtract(minuend, subtrahend):
for _ in range(subtrahend):
tevino /
Last active July 21, 2022 15:23
Signing gdb on macOS with codesign
CERT_ID='gdb-cert' # the name of the certificate used for signing
if ! security find-certificate -c "$CERT_ID" &>/dev/null; then
echo >&2 "> ❌ certificate($CERT_ID) not found"
echo "Here is a brief note on how to create one:"
echo "1. Open Keychain Access"
echo "2. Open the menu item: Keychain Access -> Certificate Assistant -> Create a Certificate..."
tevino /
Last active January 13, 2020 08:32
A BitBar plugin that runs duplicacy backup hourly
#!/usr/bin/env python3
# <bitbar.title>Duplicacy Scheduler</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <>Tevin</>
# <>tevino</>
# <bitbar.desc>Run duplicacy backup every hour.</bitbar.desc>
# <bitbar.dependencies>duplicacy,python3</bitbar.dependencies>
import os
tevino / Daily Journal.applescript
Created October 12, 2019 08:23
Markdown daily journal template based on builtin smart template "Daily Journal" in DEVONthink 3
Based on script by Chuck Lane October 2, 2013
Updated and optimized for DEVONthink 3 by Christian Grunenberg April 30, 2019
Localized and styles updated by Eric Böhnisch-Volkmann June 28, 2019
Changes done by Tevin Zhang 2019-10-12
- Use markdown instead of rtd
- Remove news
- Use date format specified by ISO 8601 to reduce the effort of localization
function r(r){for(var t={};i=r.pop();)t[i]=1;return t}function FindProxyForURL(r,i){if(isPlainHostName(i))return e;var f=i,o=0;do{if(_.hasOwnProperty(f))return t;if(n.hasOwnProperty(f))return e;o=i.indexOf(".",o)+1,f=i.substring(o)}while(o>0);var u=dnsResolve(i);if(!u)return t;if(u.indexOf(":")>=0)return e;var l=u.split("."),p=(255&l[1])<<8|255&l[2],v=l[0],d=s[v],h=a[v];if(0===d)return t;if(16===h)return e;var w=0,L=d.length,c=L>>1;do d[c]>p?L=c:w=c,c=w+L>>1;while(w+1<L);return p-d[w]>>h[w]===0?e:t}var t="PROXY;",e="DIRECT",n=r("||cn|||||||||||||||||||||||||||||||||||||||||||||cctvcom|||||zoosn
tevino /
Last active August 27, 2019 02:34
A spider to get CASIO(including G-SHOCK) watch specs, to help you make your choice.
import re
import scrapy
def parse_date(s):
if s:
s = s.replace('年', '').replace('月', '').replace('NEW', '')
if len(s) == 5:
month = s[-1]
s = s[:4] + "0" + month # add a leading zero to month
s = int(s)
while you.is_single and you.love_letter in you.code_written:
you.is_single = True
-- Find Similar Contents.
-- Created by Christian Grunenberg on Thu Feb 10 2005.
-- Copyright (c) 2005-2014. All rights reserved.
-- Limit for more or less identical contents (0.0: no similarity, 1.0: almost identical)
property pLimit : 0.9
-- Max. number of similar results to display
tevino /
Last active April 7, 2019 15:44
A script to split long(e.g. 4096 bits) private keys into qr codes so you could print on a paper.
# Q&As
# Q: Why not use [paperkey][paperkey]?
# A: It brings much more complexity and dependencies, and I don't have time to check the implementation for security.
# Q: Why not OCR?
# A: I didn't find an open-source ocr software that works for normal photos.
# even though I used [OCR-A][OCR-A] for printing and [ScannerPro][ScannerPro] for image processing.