Skip to content

Instantly share code, notes, and snippets.

@kbauer
kbauer / imagemagick-scan-pdf-to-mono.sh
Last active May 16, 2019 02:23
Converts a PDF obtained from scanning into a fax-like monochrome PDF. Assumes that the PDF consists of only a sequence of page-filling images. Requires my other gist imagemagick-scan-to-mono.sh
#!/usr/bin/env bash
# -*- mode: sh; coding: us-ascii-unix -*-
source libstacktrace || true
# set -e -u -E
MANUAL="
Usage: $0 [options] INPUT OUTPUT
$0 --inplace [options] INPUT
@kbauer
kbauer / imagemagick-scan-to-mono.sh
Last active May 31, 2021 17:26
A tool for converting scanned or photographed pages into a fax-style bi-level png with minimal storage use. Also removes background color gradients. See also my other gist `imagemagick-scan-pdf-to-mono.sh`
#!/usr/bin/env bash
# -*- mode: sh; coding: us-ascii-unix -*-
source libstacktrace || true
set -e -u -E
MANUAL="
Usage: $0 INFILE OUTFILE [BLURRADIUS;default:20px]
Takes a document scan INFILE (an image) and produces a monochromatized
@kbauer
kbauer / chrome-comic-rocket-navigation.ahk
Last active December 15, 2015 16:22
An AutoHotKey script for navigating comic-rocket. For use with other Browsers than Chrome, change the RegEx in the #IfWinActive line accordingly.
SetTitleMatchMode RegEx
#IfWinActive .*Comic Rocket webcomic list - Google Chrome
ComicRocketChangePage(bynum)
{
oldclip := clipboard
Send ^l
Sleep 50
Send ^c
Sleep 50
@kbauer
kbauer / Meaning
Created July 15, 2015 15:52
For debugging/learning LaTeX internals it is useful to dump the definition of commands. Reading the output of `\show` from the console however is inconvenient. The command `\meaning` is useful here (as it prints the definition to the document) but limited. `\mymeaning` is a wrapper, where you specifiy the name of a macro rather than the `\macro`…
% \mymeaning{command} -> Definition of \command
\makeatletter
\newcommand{\mymeaning}[1]{
\begingroup%
\setlength{\parindent}{0em}
\setlength{\hangindent}{1em}
\edef\@tmp{\ifmmode\noexpand\mathtt\else\noexpand\texttt\fi}
\@tmp{%
\expandafter\string\csname #1\endcsname->%
\expandafter\meaning\csname #1\endcsname;%
@kbauer
kbauer / lyx-header-util.py
Last active April 1, 2016 19:29
A script for extracting and overwriting headers in lyx files.
#!/usr/bin/env python3
import sys
import tempfile
import io
import os
MANUAL="""
Usage: my-lyx-headerutil.py COMMAND ARG ...