Skip to content

Instantly share code, notes, and snippets.

Avatar

Stefan stefanschmidt

View GitHub Profile
@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 / 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
@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 / hash-sha512.sh
Last active Apr 7, 2019
Generate salted SHA-512 hashes
View hash-sha512.sh
# Using mkpasswd and slappasswd we will generate salted SHA-512 hashes
# password: secret
# method 1: using mkpasswd
# requires whois package on Ubuntu
mkpasswd --method=sha-512 --salt=foobar42
$6$foobar42$weYmU8biHjFLegPCuvGBSDaG0QMNucFv4Wq6.TGVK53/U0dp6bTrLYCLAdjecyX5mS1IA8vezYNjzTduU988B0
# method 2: using slappasswd
# requires slapd package on Ubuntu
@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 / dns-query.rb
Last active Mar 1, 2019
Perform a DNS query with Ruby
View dns-query.rb
# requires net-dns gem
# query defaults to A record
require 'net/dns'
res = Net::DNS::Resolver.new
packet = res.query("google.com")
packet.answer.first.value
@stefanschmidt
stefanschmidt / mx-query.rb
Created Mar 1, 2019
Perform an MX query with Ruby
View mx-query.rb
# requires net-dns gem
require 'net/dns'
res = Net::DNS::Resolver.new
mx = res.mx("google.com")
mx.first.exchange
@stefanschmidt
stefanschmidt / autenticate-ldap.rb
Last active Mar 1, 2019
Authenticate via LDAP with Ruby
View autenticate-ldap.rb
# Using an LDAP test server we will authenticate the user newton
# http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
# requires net-ldap gem
require 'net/ldap'
ldap = Net::LDAP.new
ldap.host = 'ldap.forumsys.com'
ldap.auth "uid=newton,dc=example,dc=com", "password"
if ldap.bind
puts 'authentication succeeded'