Skip to content

Instantly share code, notes, and snippets.

View z-rui's full-sized avatar

张睿 Zhang Rui z-rui

  • Los Gatos, CA
  • 07:29 (UTC -07:00)
View GitHub Profile
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>sans-serif</family>
<prefer>
<family>Source Sans Pro</family>
<family>Source Han Sans SC</family>
</prefer>
</alias>
@z-rui
z-rui / bf.awk
Created September 19, 2018 12:19
Brainf*** interpreter in AWK
BEGIN {
FS = ""
AMOD = 65536
VMOD = 256
pc = 0
for (ch = 0; ch < VMOD; ch++)
ORD[sprintf("%c", ch)] = ch
}
{
@z-rui
z-rui / bf.tex
Last active May 8, 2018 17:39
Brainf*** interpreter in TeX
% Brainf*** interpreter
% Usage:
%
% tex bf <file>
%
% Be aware that this interpreter is very slow...
\newcount\memptr \newcount\maxptr \newcount\minptr
\newcount\memval \newcount\maxval \newcount\minval
@z-rui
z-rui / moo.tex
Created May 8, 2018 02:32
The Moo game written in TeX
\def\writeln#{\immediate\write16}
\def\readln#1{{\catcode`\^^M=9 \global\read16 to#1}}
\newcount\seed \seed=1
\def\rand{\the\seed\randnext}
\def\modulo#1#2{{\count255=#1\divide\count255 by#2\multiply\count255 by#2%
\global\advance#1by-\count255}}
\def\randnext{{%
@z-rui
z-rui / fix-goucima.patch
Created December 17, 2017 10:03
ibus-table-1.9.18 构词码补丁
diff --git a/engine/tabsqlitedb.py b/engine/tabsqlitedb.py
index 26d1f7f..b555adb 100644
--- a/engine/tabsqlitedb.py
+++ b/engine/tabsqlitedb.py
@@ -1169,16 +1169,9 @@ class tabsqlitedb:
% {'p': phrase, 'r': self.rules})
if type(phrase) != type(u''):
phrase = phrase.decode('UTF-8')
- # Shouldn’t this function try first whether the system database
- # already has an entry for this phrase and if yes return it
@z-rui
z-rui / ext-e.txt
Created April 17, 2017 07:21
郑码 Ext-E 码表
HDAA 𫠠 HD
AOI 𫠡 AO
IDAA 𫠢 IA
HDYO 𫠣 HY
CIYM 𫠤 CY
ZALO 𫠥 ZA
AIMI 𫠦 AI
MAAI 𫠧 ME
MYA 𫠨 MY
AZZZ 𫠩 AZ
@z-rui
z-rui / 1.txt
Created March 31, 2017 15:41
通用规范汉字表 (2013)
@z-rui
z-rui / cjk.txt
Last active April 2, 2017 16:27
郑码的补充码表
# 部分 CJK 汉字的编码表
#
# 说明:U+9FCD - U+9FD5 的字似无编码。
#
# 字 编码 构词码
#
鿍 BRMB BR
鿎 GWGD GW
鿏 PCRS PC
鿐 RVFD RV
@z-rui
z-rui / errata.md
Last active March 26, 2017 09:01
郑码码表勘误

郑码码表勘误

rime-zhengma 中 Ext-C 区域的汉字编码均有误。

Windows Vista 附带的 TableTextServiceSimplifiedZhengma.txt 应该是中易公司官方制作的码表(可能是所谓的6.6版),包含 CJK、Ext-A、Ext-B、Ext-C 中的字符和部分繁简体词汇,质量较高,但不含构词码。 Windows 7 以后的版本因版权问题不再含有此文件。

我借用 rime-zhengma 中的构词码,对官方码表中的词汇编码(不含简码,简码的编码具有随意性)做了检查。发现了部分编码错误。其中,有一些可以认为是容错码,因为正确的编码同样在码表中,这种情况我没有订正。

构词码本身也有错误的。好在错误不多,这里我总结如下:

--- dmenu.c.orig 2015-11-09 06:42:21.000000000 +0800
+++ dmenu.c 2016-05-10 01:46:51.139220000 +0800
@@ -117,7 +117,6 @@
static void
drawmenu(void)
{
- int curpos;
struct item *item;
int x = 0, y = 0, h = bh, w;