Skip to content

Instantly share code, notes, and snippets.

View z-rui's full-sized avatar

张睿 Zhang Rui z-rui

View GitHub Profile
@z-rui
z-rui / makepdf.sh
Created July 14, 2019 04:16
Make a 16-page booklet
#!/bin/bash
size="3300x2550" # 11" x 8"
# size="3508x2480" # 297mm x 210mm
cvtopts="+append -adaptive-resize $size -gravity center -extent $size -set density 300 -unsharp 0x5+0.3+0"
if [[ ! -z $1 ]]; then
N=$1
elif [[ $PWD =~ FILE([0-9]+) ]]; then
@z-rui
z-rui / .tmux.conf
Created November 17, 2018 18:35
Tmux configuration
unbind C-b
bind-key C-a send-prefix
set -g prefix C-a
set -g mouse on
set -g set-titles on
set -g status off
set -g escape-time 100
setw -g mode-keys vi
@z-rui
z-rui / hash.c
Created November 2, 2018 19:59
Open addressing, linear probing hash table
#include "hash.h"
#include <assert.h>
void **hash_find(void **base, size_t n, void *key,
size_t hash, int (*equal)(const void *, const void *))
{
void **p, **q, **end;
p = q = base + hash % n;
end = base + n;
<?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)