Skip to content

Instantly share code, notes, and snippets.

@doraTeX
doraTeX / randomshuffle.sty
Last active March 14, 2026 16:30
A LaTeX package for random shuffling
\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
\documentclass{jlreq}
%\documentclass[dvipdfmx]{jlreq} %% (u)pLaTeX + dvipdfmx を使う場合はドキュメントクラスオプションに [dvipdfmx] が必要
\usepackage{tikz}
\usepackage{amsmath}
\makeatletter
\def\proportionalto{%
\mathrel{\mathchoice
{\@proportionalto\tf@size}{\@proportionalto\tf@size}%
{\@proportionalto\sf@size}{\@proportionalto\ssf@size}}}
@doraTeX
doraTeX / ocr.sh
Last active January 16, 2026 14:57
A shell script to perform OCR on images/PDFs using macOS built-in OCR engine -- https://doratex.hatenablog.jp/entry/20230629/1687977178
#!/bin/bash
SCRIPTNAME=$(basename "$0")
function realpath () {
f=$@;
if [ -d "$f" ]; then
base="";
dir="$f";
else
base="/$(basename "$f")";
@doraTeX
doraTeX / pdf2text.sh
Last active November 6, 2025 06:09
A shell script to extract text from PDF on macOS -- https://doratex.hatenablog.jp/entry/20230705/1688554958
#!/bin/bash
SCRIPTNAME=$(basename "$0")
function realpath () {
f=$@;
if [ -d "$f" ]; then
base="";
dir="$f";
else
@doraTeX
doraTeX / ocr.m
Last active October 28, 2025 08:10
Original Swift / Objective-C / AppleScriptObjC codes from which ocr.sh (https://gist.github.com/doraTeX/da9a1a26dffbf3fe5d6ec12a9c79267c) is converted
#import <Quartz/Quartz.h>
#import <Vision/Vision.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSString *target = @"test.pdf";
CGFloat dpi = 200;
PDFDocument *doc = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:target]];
NSUInteger pageCount = [doc pageCount];
@doraTeX
doraTeX / haiten.tex
Last active July 30, 2025 10:59
「可能なら一定の空白を空けて同行に、無理なら同行に右寄せで、それも無理なら次行の行末に」出力する命令
\documentclass[a4j,autodetect-engine,twocolumn]{jsarticle}
\usepackage[margin=20truemm]{geometry}
\columnseprule1pt
\makeatletter
\newbox\Answer@box
\newdimen\Answer@parindent
\NewDocumentEnvironment{Answer}{}{%
@doraTeX
doraTeX / unzip.py
Last active June 5, 2025 02:41
Windowsで作られた日本語ファイル名入りのZIPアーカイブにも対応した unzip 用 Python スクリプト
#!/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 / mosaicFaces.sh
Last active March 27, 2024 13:42
A macOS script that applies mosaic effects to faces of individuals in photos ( https://doratex.hatenablog.jp/entry/20240327/1711546952 )
#!/bin/bash
SCRIPTNAME=$(basename "$0")
function realpath () {
f=$@
if [ -d "$f" ]; then
base=""
dir="$f"
else
base="/$(basename "$f")"
@doraTeX
doraTeX / maskFaces.sh
Last active March 27, 2024 12:43
A macOS script that masks faces of individuals in photos using emojis ( https://doratex.hatenablog.jp/entry/20240324/1711246435 )
#!/bin/bash
SCRIPTNAME=$(basename "$0")
function realpath () {
f=$@
if [ -d "$f" ]; then
base=""
dir="$f"
else
base="/$(basename "$f")"
@doraTeX
doraTeX / CorrelationCoefficient.pdf
Last active December 24, 2023 05:15
相関係数格付けチェックのランダム生成
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.