Skip to content

Instantly share code, notes, and snippets.

Avatar

Stefan stefanschmidt

View GitHub Profile
@stefanschmidt
stefanschmidt / epub2pdf.sh
Created May 24, 2015
Convert from EPUB to PDF format
View epub2pdf.sh
# depends on Calibre (http://calibre-ebook.com)
# the CSS snippet prevents images from filling the page
# adapt margins, page size and font size as needed
ebook-convert doc.epub doc.pdf \
--smarten-punctuation \
--pretty-print \
--preserve-cover-aspect-ratio \
--insert-blank-line \
--margin-top 60 \
--margin-left 60 \
@stefanschmidt
stefanschmidt / remove-annotations.sh
Last active Nov 7, 2021
Remove all annotations from a PDF document
View remove-annotations.sh
pdftk original.pdf output uncompressed.pdf uncompress
LANG=C sed -n '/^\/Annots/!p' uncompressed.pdf > stripped.pdf
pdftk stripped.pdf output final.pdf compress
@stefanschmidt
stefanschmidt / fix-homebrew-owner-perms.sh
Created Apr 12, 2016
Fix ownership and permissions of a multi-user Homebrew installation
View fix-homebrew-owner-perms.sh
# fix owner of files and folders recursively
sudo chown -vR $(whoami) /usr/local /opt/homebrew-cask /Library/Caches/Homebrew
# fix read/write permission of files and folders recursively
chmod -vR ug+rw /usr/local /opt/homebrew-cask /Library/Caches/Homebrew
# fix execute permission of folders recursively
find /usr/local /opt/homebrew-cask /Library/Caches/Homebrew -type d -exec chmod -v ug+x {} +
@stefanschmidt
stefanschmidt / silence-dropbox.sh
Created Aug 27, 2013
Stop Dropbox from asking for admin password after installation to ~/Applications
View silence-dropbox.sh
chmod 0000 ~/Applications/Dropbox.app/Contents/Resources/*.tgz
@stefanschmidt
stefanschmidt / libpff.rb
Created May 21, 2021
Homebrew formula for libpff
View libpff.rb
class Libpff < Formula
desc "libpff is a library to access the Personal Folder File (PFF) and the Offline Folder File (OFF) format"
homepage "https://github.com/libyal/libpff"
license "LGPLv3+"
head "https://github.com/libyal/libpff.git", :branch => "main"
# depends_on "cmake" => :build
depends_on "gettext"
depends_on "automake"
depends_on "libtool"
@stefanschmidt
stefanschmidt / install-markdeck.sh
Last active May 16, 2021
Installing markdeck on macOS Mojave
View install-markdeck.sh
# MarkDeck: presentations as code
# https://arnehilmann.github.io/markdeck/
# install Docker Desktop (requires root privileges)
brew install --cask docker
# install Docker command line binaries
# /usr/local/bin/docker
# /usr/local/bin/docker-compose
open /Applications/Docker.app
@stefanschmidt
stefanschmidt / google-search-annoyances.txt
Last active May 13, 2021
Remove annoyances from Google search results
View google-search-annoyances.txt
! For use in Adguard for Safari on macOS: http://adguard.com
! Syntax for filters: https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters
! See also: https://adblockplus.org/filter-cheatsheet#elementhideemulation
! Takes about ten seconds after saving for changes to be reflected in browser
! Removes the sections "People also search for", "People also ask", "Related searches" and "Featured snippet from the web"
www.google.com#?#div:-abp-has( > div > div > div > h4:-abp-contains(People also search for))
www.google.com#?#div:-abp-has( > div > div > div > div > h2:-abp-contains(People also ask))
www.google.com#?#div:-abp-has( > div> div > div > div > div > h3 > span:-abp-contains(Related searches))
www.google.com#?#div:-abp-has( > div > div > div > div > h2:-abp-contains(Featured snippet from the web))
@stefanschmidt
stefanschmidt / dovecot.sh
Last active May 13, 2021
Dovecot command collection
View dovecot.sh
# reload configuration
doveadm reload
# restart
service dovecot restart
# test authentication
doveadm auth test user@domain.com
# test login with passdb and userdb lookup
@stefanschmidt
stefanschmidt / scrape-dfd.sh
Last active May 8, 2021
Convert list of german last names from html to plain text
View scrape-dfd.sh
# Using htmlparser we will convert an extensive list of german last names from html to plain text
# Digitales Familiennamenwörterbuch Deutschlands (DFD) is available from https://www.namenforschung.net
#
# depends on htmlparser go package
# https://github.com/htmlparser/htmlparser
# single-page view: currently 46035 names (May 2021)
curl -s 'https://www.namenforschung.net/dfd/woerterbuch/gesamtliste-veroeffentlichter-namenartikel/' |
htmlparser '#maincontent > ul:nth-child(even) > li > a text{}' > dfd.txt
@stefanschmidt
stefanschmidt / scrape-dfa.sh
Created May 8, 2021
Convert list of german last names from pdf to plain text
View scrape-dfa.sh
# Using pdf2txt we will convert an extensive list of german last names from pdf to plain text
# Deutscher Familiennamenatlas (DFA) is available from https://www.namenforschung.net
#
# depends on pdftotext from poppler package (available via Homebrew)
# currently 54152 names (May 2021)
curl https://www.namenforschung.net/fileadmin/user_upload/dfa/Inhaltsverzeichnisse_etc/Index_Band_I-V_Gesamt_Stand_September_2016.pdf > temp.pdf
pdftotext temp.pdf
# remove page titles, page numbers, etc. from text with regular expressions