Skip to content

Instantly share code, notes, and snippets.

@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 / join.sh
Created December 24, 2023 05:03
A shell script to join PDFs using macOS API ( https://doratex.hatenablog.jp/entry/20220330/1648629672 )
#!/bin/bash
SCRIPTNAME=$(basename "$0")
function realpath () {
f=$@;
if [ -d "$f" ]; then
base="";
dir="$f";
else
base="/$(basename "$f")";
%#!uplatex
\documentclass[autodetect-engine,dvipdfmx]{jsarticle}
\usepackage{mydate}
\begin{document}
% テスト:n日後の日付を出力する
2023年4月1日の247日後は\n日後を出力{2023}{4}{1}{247}です。
% テスト:2つの日付の差を出力する
@doraTeX
doraTeX / CorrelationCoefficient.pdf
Last active December 24, 2023 05:15
相関係数格付けチェックのランダム生成
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@doraTeX
doraTeX / pdf2text.sh
Created July 5, 2023 08:44
A shell script to extract text from PDF on macOS
#!/bin/bash
SCRIPTNAME=$(basename "$0")
function realpath () {
f=$@;
if [ -d "$f" ]; then
base="";
dir="$f";
else
@doraTeX
doraTeX / ocr.m
Last active November 22, 2023 02:31
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 / ocr.sh
Last active April 19, 2024 13:04
A shell script to perform OCR on images/PDFs using macOS built-in OCR engine
#!/bin/bash
SCRIPTNAME=$(basename "$0")
function realpath () {
f=$@;
if [ -d "$f" ]; then
base="";
dir="$f";
else
base="/$(basename "$f")";
@doraTeX
doraTeX / test-zarabic.tex
Created June 14, 2023 15:42
カウンタ値を全角数字で出力する完全展開可能な命令 \zarabic を定義する
%!uplatex
\documentclass[autodetect-engine,dvipdfmx]{jsarticle}
\usepackage{pgffor}
\usepackage{xcolor}
\usepackage{zarabic}
\newcounter{testCounter}
\makeatletter
\def\test#1{%
@doraTeX
doraTeX / quiz-dora.tex
Created May 31, 2023 17:22
\futurelet  芸人クイズを解いてみる
% オリジナルの quiz.tex が \Parse{#1} から \Parsed を生成するのと同様に,
% \doraParse{#1} から \doraParsed を生成する命令を,\futurelet を使わずに定義する
\catcode`\@=11 %----------------------------------
\newcount\dora@parse@depth
\def\safescantokens#1#2{\scantokens{\def#1{#2}\ignorespaces}}
\catcode`[=1
\catcode`]=2