Skip to content

Instantly share code, notes, and snippets.

@doraTeX
doraTeX / search-dockerhub.sh
Last active April 26, 2024 16:10
Shell functions to list tags and supported CPU architectures for Docker Hub images
#!/bin/bash
function docker-list-tags () {
if [ $# -ne 1 ]; then
echo "Usage: $0 [<NAMESPACE>/]<IMAGE>" 1>&2
echo ""
echo "Argument Specifications:"
echo ' <NAMESPACE> : Docker Hub namespace or username (default: `library`)'
echo ' <IMAGE> : Image name (mandatory)'
echo
@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 / 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
相関係数格付けチェックのランダム生成
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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")";
@doraTeX
doraTeX / generateQRcode.swift
Last active December 21, 2023 10:32
QR Code Generator written in Swift 4
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
}
%#!uplatex
\documentclass[autodetect-engine,dvipdfmx]{jsarticle}
\usepackage{mydate}
\begin{document}
% テスト:n日後の日付を出力する
2023年4月1日の247日後は\n日後を出力{2023}{4}{1}{247}です。
% テスト:2つの日付の差を出力する
@doraTeX
doraTeX / randomshuffle.sty
Last active December 8, 2023 04:57
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
@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];