Skip to content

Instantly share code, notes, and snippets.

View stefanschmidt's full-sized avatar

Stefan stefanschmidt

  • Hamburg, Germany
View GitHub Profile
@stefanschmidt
stefanschmidt / google-search-annoyances.txt
Last active May 13, 2021 12:44
Remove annoyances from Google search results
! 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 03:24
Convert list of german last names from pdf to plain text
# 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 03:24
Convert list of german last names from html to plain text
# 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 April 7, 2019 22:24
Generate salted SHA-512 hashes
# 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 12:05
Dovecot command collection
# 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 March 1, 2019 15:58
Perform a DNS query with Ruby
# 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 March 1, 2019 15:19
Perform an MX query with Ruby
# 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 March 1, 2019 15:19
Authenticate via LDAP with Ruby
# 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'
@stefanschmidt
stefanschmidt / authenticate-ldap.sh
Last active April 25, 2024 07:23
Authenticate via LDAP on the command line
# Using an LDAP test server we will authenticate the user newton
# http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
# method 1: using ldapwhoami
# should return "Result: Success (0)" if authentication was successful
ldapwhoami -vvv -h ldap.forumsys.com -D "uid=newton,dc=example,dc=com" -x -w password
# method 2: using ldapsearch
# should return "result: 0 Success" if authentication was successful
ldapsearch -h ldap.forumsys.com -x -D uid=newton,dc=example,dc=com -w password -b "dc=example,dc=com" "(uid=newton)"
@stefanschmidt
stefanschmidt / nrrd-dims.sh
Created April 13, 2016 06:25
Show dimensions of an NRRD volume on OS X
# depends on teem (available via Homebrew)
unu head volume.nrrd | grep sizes