Skip to content

Instantly share code, notes, and snippets.

@doraTeX
doraTeX / word2tipa.swift
Created December 13, 2022 14:00
英単語から \textipa の入力に自動変換するツール
View word2tipa.swift
import Foundation
/// 設定のデフォルト値
// (ə)のような括弧で囲まれた発音記号の扱い
enum ParenTreatment: Int {
case none = 1, // そのまま
flatten, // 括弧を開く
remove // 発音記号ごと削除する
}
// デフォルトは(ə)などはそのまま
@doraTeX
doraTeX / ipaex-vs-sourcehansans.tex
Last active February 8, 2020 15:02
IPAex Gothic にあって Source Han Sans にないグリフをリストアップ
View ipaex-vs-sourcehansans.tex
%#!xelatex
\documentclass[xelatex]{bxjsarticle}
\usepackage{xltxtra}
\usepackage{multicol}
\pagestyle{empty}
\ExplSyntaxOn
\NewDocumentCommand{\codepoint}{m}{
U+
\int_compare:nNnTF{#1}<{"1000}{0}{}
@doraTeX
doraTeX / unzip.py
Last active March 14, 2021 06:17
Windowsで作られた日本語ファイル名入りのZIPアーカイブにも対応した unzip 用 Python スクリプト
View unzip.py
#!/usr/bin/env python3
import sys
import re
from zipfile import ZipFile
from getpass import getpass
if len(sys.argv) == 1:
print("Usage: {} ZIP_FILE(S)...".format(sys.argv[0]))
exit(0)
@doraTeX
doraTeX / MagneticStirrer.svg
Last active July 5, 2022 15:48
SVG graphics of a magnetic stirrer ( trace of Ruhrfisch's work (GFDL), https://commons.wikimedia.org/wiki/File:Magnetic_Stirrer.JPG )
View MagneticStirrer.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@doraTeX
doraTeX / README.md
Last active July 31, 2020 13:16
引数に与えられた日本語文字列を形態素解析しひらがなに変換して出力するコマンドラインユーティリティ on macOS
View README.md

コンパイル法

Objective-C 版

$ clang -framework Foundation -o ToHiragana ToHiragana.m  

Swift 版

@doraTeX
doraTeX / saizeriyaKnapsackDP.tex
Last active February 25, 2021 23:32
「サイゼリヤで1000円あれば最大何kcal摂れるのか」をTeX言語で計算する ~TeX言語で動的計画法(DP)~ https://doratex.hatenablog.jp/entry/20190520/1558323856
View saizeriyaKnapsackDP.tex
%#!(u)platex
\documentclass[dvipdfmx,autodetect-engine]{jsarticle}
\usepackage{pgffor}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable}
\tcbset{enhanced jigsaw,colback=red!5!white,colframe=red!75!black,breakable,fonttitle=\gtfamily,before upper=\setlength\parindent{1zw}}
\makeatletter
@doraTeX
doraTeX / uuid.sty
Created April 30, 2019 06:22
A LaTeX package for generating UUID Version 4
View uuid.sty
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{uuid}[2019/04/30 v0.1]
\newif\ifuuid@lowercase
\uuid@lowercasefalse
\DeclareOption{lowercase}{\uuid@lowercasetrue}
\ProcessOptions\relax
@doraTeX
doraTeX / randomshuffle.sty
Last active January 18, 2019 03:43
A LaTeX package for random shuffling
View randomshuffle.sty
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{randomshuffle}[2019/01/18 v0.2]
\RequirePackage{keyval}
\ifdefined\pdfuniformdeviate
\let\randomshuffle@uniformdeviate\pdfuniformdeviate
\let\randomshuffle@setrandomseed\pdfsetrandomseed
\else\ifdefined\uniformdeviate
\let\randomshuffle@uniformdeviate\uniformdeviate
\let\randomshuffle@setrandomseed\setrandomseed
@doraTeX
doraTeX / currentpage.tex
Last active May 15, 2019 05:20
jsarticle + mag + gentombow + pdfbox + pxpgfmark の両立実験
View currentpage.tex
% (u)pLaTeX + dvipdfmx
\documentclass[8pt,b6paper,dvipdfmx,autodetect-engine,tombo]{jsarticle}
\usepackage[pdfbox]{gentombow}
\usepackage{tikz}
\usepackage{pxpgfmark}
\def\test{%
\begin{tikzpicture}[remember picture, overlay]
\coordinate (NE) at (current page.north east);
@doraTeX
doraTeX / generateQRcode.swift
Last active February 15, 2019 22:50
QR Code Generator written in Swift 4
View generateQRcode.swift
import Quartz
extension CGImage {
class func qrCodeImage(from string: String, scale: CGFloat = 1) -> CGImage? {
let stringData = string.data(using: .utf8)
let transform = CGAffineTransform(scaleX: scale, y: scale)
guard let filter = CIFilter(name: "CIQRCodeGenerator") else {
return nil
}