Skip to content

Instantly share code, notes, and snippets.

@7shi
7shi / convert.py
Last active May 10, 2020 09:09
[py] Novial dictionary converter (OBSOLETE!)
# extract tgz from http://www.blahedo.org/novial/nl.html
with open("novial.txt", "w", encoding="utf-8") as novial:
for i in range(ord("A"), ord("Z")):
with open("%c.txt" % i, encoding="iso-8859-1") as f:
lines = f.readlines()
texts = []
for i, line in enumerate(lines):
line = line.strip()
if i > 1 and not line:
if texts:
@7shi
7shi / Convert.fsx
Created May 8, 2020 11:04
[F#] Volapük dictionary converter
// http://personal.southern.edu/~caviness/Volapuk/Misc/eng-vol.htm
// http://personal.southern.edu/~caviness/Volapuk/Misc/vol-eng.htm
// https://gist.github.com/7shi/de072cd867f3899aa285bc9343110bff
#load "XmlParser.fsx"
open System
open System.IO
open System.Text
open XmlParser
@7shi
7shi / XmlParser.fsx
Created May 8, 2020 10:59
[F#] XML Parser
open System
open System.IO
open System.Text
let entities =
(
"acirc,â;aelig,æ;agrave,à;amp,&;auml,ä;ccedil,ç;deg,°;eacute,é;" +
"ecirc,ê;egrave,è;euml,ë;gt,>;hellip,…;iuml,ï;laquo,«;ldquo,“;" +
"lsaquo,‹;lt,<;mdash,—;nbsp, ;ndash,–;ocirc,ô;oelig,œ;ordf,ª;" +
"ordm,º;ouml,ö;quot,\";raquo,»;rdquo,”;rsaquo,›;rsquo,’;shy,­;" +
@7shi
7shi / Convert.fsx
Last active May 8, 2020 11:03
[F#] Ido dictionary converter
// https://github.com/kyegupov/ido_web_dictionary
// https://gist.github.com/7shi/de072cd867f3899aa285bc9343110bff
#load "XmlParser.fsx"
open System
open System.IO
open System.Text
open XmlParser
@7shi
7shi / gdict.sh
Last active May 11, 2020 10:53
[sh] grep the text dictionary
#!/bin/sh
CMDNAME=`basename $0`
INSERT="✔ "
DICT=""
MAX="50"
WORD="0"
OPTS="-i"
COLOR="--color=always"
function usage () {
echo "usage: $CMDNAME -d DICT [-c] [-m max] [-w] words ..." 1>&2
@7shi
7shi / test.vbs
Last active April 27, 2020 19:24
[vbs] OneCore Voice
' Save this VBS as UTF-16 LE
' ref. https://bugzilla.mozilla.org/show_bug.cgi?id=1544143
Const target = "Microsoft Hoda"
Const text = "السلام عليكم"
Const output = "test.wav"
Set voice = Nothing
Set cat = CreateObject("SAPI.SpObjectTokenCategory")
@7shi
7shi / gets.py
Last active May 24, 2020 22:11
[py][sqlite3] Tatoeba
# CC0 http://creativecommons.org/publicdomain/zero/1.0/
usage = "[-n max sentences (default 10)] [-m max translations] languages..."
import tatoeba, sys
argi = 0
def getarg():
global argi
if argi + 1 >= len(sys.argv): return None
@7shi
7shi / mkdb.py
Last active April 14, 2020 16:43
[py][dbm] Tatoeba
import dbm, os, sys
slangdb = "sentences-lang.db"
stextdb = "sentences-text.db"
linksdb = "links-all.db"
llangdb = "links-lang.db"
print("Compiling sentences.csv ...")
slang = None if os.path.exists(slangdb) else dbm.open(slangdb, "n")
stext = None if os.path.exists(stextdb) else dbm.open(stextdb, "n")
@7shi
7shi / start
Last active April 2, 2020 09:21
[sh] start wrapper for WSL
#!/bin/sh
if test "$1" = "."; then
explorer.exe .
else
cmd.exe /c start $@
fi
@7shi
7shi / katexSource.html
Last active April 1, 2020 16:14
[はてなブログ] KaTeXでTeXのソースを表示
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tingle.js@0.15.2/dist/tingle.min.css">
<script src="https://cdn.jsdelivr.net/npm/tingle.js@0.15.2/dist/tingle.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/nils-soderman/CtxMenu-Javascript@0.1.3/ctxmenu/ctxmenu.min.css">
<script src="https://cdn.jsdelivr.net/gh/nils-soderman/CtxMenu-Javascript@0.1.3/ctxmenu/ctxmenu.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", () => {
let modal = new tingle.modal();
modal.setContent('<textarea readOnly rows="10" style="width:100%;resize:none;border:none;white-space:pre-wrap;"></textarea>');
modal.getContent().style.padding = "1rem 1rem";
CtxMenu(".katex").addItem("Show TeX Commands", e => {