Skip to content

Instantly share code, notes, and snippets.

@nobucshirai
nobucshirai / img2pdf.py
Last active February 18, 2025 02:22
Image to PDF Converter: Easily combine multiple images into a single PDF file. Just provide image paths and an optional output name. Perfect for quick document assembly tasks.
#!/usr/bin/env python3
"""
Merge image files into a single PDF, optionally annotating images with their filenames using ImageMagick.
The grid layout is controlled by the number of rows and columns.
Use the --with-text flag to enable filename annotation (default is without text).
You can adjust the annotation font size by using the --font-scale option.
"""
import argparse
import os
@nobucshirai
nobucshirai / annotated_pages_extractor.py
Created February 12, 2025 03:38
PDF Annotation Extractor – This script processes PDF files, detecting and extracting only the pages that contain annotations. Useful for reviewing highlighted or commented content.
#!/usr/bin/env python3
"""
Extract annotated pages from PDF files.
This script reads one or more PDF files, checks each page for annotations,
and writes a new PDF containing only those pages that contain annotations.
If an output filename is not provided, the script uses the input file's basename
but adds "_extracted" before the ".pdf" extension.
Before overwriting an existing file, the user is prompted for confirmation.
@k16shikano
k16shikano / jackpodsc.tex
Last active May 22, 2020 10:01
TeXでスロットマシン
% inspired by https://tex.stackexchange.com/questions/524022/switch-string-commands-based-on-random-values-to-produce-random-cards
\documentclass{article}
\usepackage{xparse}
\usepackage{scsnowman}
\usepackage{multicol}
\ExplSyntaxOn
\NewDocumentCommand{\jackpodsc}{}
{\three_snowmen:}
@zr-tex8r
zr-tex8r / okashi.tex
Last active May 26, 2020 06:28
expl3:単価が異なるお菓子をどういう組み合わせで買えば目標の合計値になるか問題
% upLaTeX文書
\documentclass[uplatex,a4paper]{jsarticle}
\usepackage{xparse}
\ExplSyntaxOn
\int_new:N \l_xx_total_int
\clist_new:N \l_xx_price_clist
\prop_new:N \l_xx_count_prop
\bool_new:N \l_xx_solved_bool
\int_new:N \l_xx_instid_int
@aminophen
aminophen / gentombow-ctm.tex
Last active April 12, 2018 13:01
デジタルトンボをつける何か
%#!pdflatex
%
% 動作には,拙作 gentombow / pxgentombow パッケージのセットの最新版が必要。
% TeX Live 2018 pretest の最新版か,
% 最新版 (2018/03/16) の gentombow.sty と pxgentombow.sty のセットを
% ダウンロードしてください → https://github.com/aminophen/gentombow
%
% この例では pdflatex を使っている。
% なお,(u)pLaTeX + dvipdfmx あるいは (u)pLaTeX + dvips で似たことをするのは少し難しい。
% (\special を一回でなく毎ページ発行しなければならないはず)
@zr-tex8r
zr-tex8r / kana-mix-tate.tex
Created April 16, 2017 06:50
LaTeX:LuaLaTeXだとかな混植が簡単にできて最高だという件
% LuaLaTeX文書,UTF-8
% jlreqクラス・縦組の例
\documentclass[lualatex,tate,paper=a6,twocolumn]{jlreq}
\usepackage{luatexja-fontspec}
\setmainjfont[
YokoFeatures={JFM=jlreq}, %jlreqのJFMを
TateFeatures={JFM=jlreqv}, %維持する
AltFont={% 代替フォント設定
{Range="3040-"30FF, Font=IPAexMincho},
{Range={`☃,`⛄}, Font=SourceHanSans}},
@zr-tex8r
zr-tex8r / tczeeen.sty
Created March 26, 2017 13:22
LaTeXで斬新な表現をするやつ
%%
%% This is file 'tczeeen.sty'.
%%
%% Copyright (c) 2017 Takayuki YATO (aka. "ZR")
%% GitHub: https://github.com/zr-tex8r
%% Twitter: @zr_tex8r
%%
%% This package is distributed under the MIT License.
%%
@aminophen
aminophen / cjk-gs-integrate.md
Last active December 23, 2020 15:17
cjk-gs-integrate の仕様 (2016/12/03 03:10)

cjk-gs-integrate.pl のデータベースと symlink / snippet 作成の仕様

拡張子 otf のファイルの場合

データベースのかきかた:

  • 【必須】Name エントリには「TEXMFLOCAL に作りたい symlink 名(dvipdfmx 用 map などにある名称)」を書く。
  • PSName エントリは、Name エントリの内容と実フォントの PostScript Name が異なる場合に書く。
  • 【必須】Class エントリは Adobe-ナントカ1-[Supplement] の「ナントカ」を書く(Japan / GB / CNS / Korea)。
  • Provides エントリは、当該の実フォントを代表的な PostScript 標準フォントへのエイリアスに採用したい場合に書く。
@munepi
munepi / list-cid-otf-moripass.txt
Created September 27, 2016 09:34
モリサワパスポート2016に含まれる{A,AP,G}-OTF*.otfに対する family name, CIDFont name, full path のリスト
A-OTF A1 Mincho Std Bold A1MinchoStd-Bold /Library/Fonts/A-OTF-A1MinchoStd-Bold.otf
A-OTF Akashi Std L AkashiStd-Light /Library/Fonts/A-OTF-AkashiStd-Light.otf
A-OTF Antique Std AN1 AntiqueStd-AN1 /Library/Fonts/A-OTF-AntiqueStd-AN1.otf
A-OTF Antique Std AN2 AntiqueStd-AN2 /Library/Fonts/A-OTF-AntiqueStd-AN2.otf
A-OTF Antique Std AN3 AntiqueStd-AN3 /Library/Fonts/A-OTF-AntiqueStd-AN3.otf
A-OTF Antique Std AN4 AntiqueStd-AN4 /Library/Fonts/A-OTF-AntiqueStd-AN4.otf
A-OTF Antique Std AN B AntiqueStd-ANB /Library/Fonts/A-OTF-AntiqueStd-ANB.otf
A-OTF Antique Std AN DB AntiqueStd-ANDB /Library/Fonts/A-OTF-AntiqueStd-ANDB.otf
A-OTF Antique Std AN H AntiqueStd-ANH /Library/Fonts/A-OTF-AntiqueStd-ANH.otf
A-OTF Antique Std AN L AntiqueStd-ANL /Library/Fonts/A-OTF-AntiqueStd-ANL.otf
@kmaed
kmaed / test-scantokens.tex
Created January 6, 2016 19:36
\scantokens の使い方
%% 眠れないので書いた.etoolbox.sty を読むと勉強になるなあ(つらい).
%% まずは基本形で準備運動.
%% 一度保存された,パラメータ文字を含むトークン列を定義とする,
%% パラメータをとるマクロを定義したいとする.
\def\a{##2##1} % カテゴリコードが6である限り,# は二重にせざるをえない.
\expandafter\def\expandafter\b\expandafter#\expandafter1\expandafter#\expandafter2\expandafter{\a}
\show\b % #1#2->#2#1
%% これはひどい.\edef 使いましょうよ.
\edef\b{%