Skip to content

Instantly share code, notes, and snippets.

Stefan stefanschmidt

Block or report user

Report or block stefanschmidt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
stefanschmidt /
Last active Apr 7, 2019
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
# method 2: using slappasswd
# requires slapd package on Ubuntu
stefanschmidt /
Created Mar 24, 2019
Dovecot Command Collection
# reload configuration
doveadm reload
# restart
service dovecot restart
# test authentication
doveadm auth test
# test login with passdb and userdb lookup
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 =
packet = res.query("")
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 =
mx ="")
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
# requires net-ldap gem
require 'net/ldap'
ldap = = ''
ldap.auth "uid=newton,dc=example,dc=com", "password"
if ldap.bind
puts 'authentication succeeded'
stefanschmidt /
Last active Apr 7, 2019
Authenticate via LDAP on the command line
# Using an LDAP test server we will authenticate the user newton
# method 1: using ldapwhoami
# should return "Result: Success (0)" if authentication was successful
ldapwhoami -vvv -h -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 -x -D uid=newton,dc=example,dc=com -w password -b "dc=example,dc=com" "(uid=newton)"
stefanschmidt /
Created Apr 13, 2016
Show dimensions of an NRRD volume on OS X
# depends on teem (available via Homebrew)
unu head volume.nrrd | grep sizes
stefanschmidt /
Created Apr 12, 2016
Fix ownership and permissions of a multi-user Homebrew installation
# 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 / pdftk.rb
Last active Apr 11, 2016
PDFtk Homebrew formula for OS X 10.10 Yosemite
View pdftk.rb
require 'formula'
class PkgExtract < CurlDownloadStrategy
def stage
safe_system '/usr/bin/xar', '-xf', @tarball_path
safe_system 'mv *.pkg/Payload Payload.gz'
safe_system 'ls | grep -v Payload | xargs rm -r'
stefanschmidt /
Last active Mar 13, 2016
Switch orientation of guillemets in Textmate from outwards to inwards (or vice-versa)
# user preferences for the builtin text bundle
PREF_FILE="$HOME/Library/Application Support/Avian/Bundles/Text.tmbundle/Preferences/Miscellaneous.tmPreferences"
# single and double guillemets in both directions
SINGLE_LEFT="<string>‹<\/string>"; SINGLE_RIGHT="<string>›<\/string>"
DOUBLE_LEFT="<string>«<\/string>"; DOUBLE_RIGHT="<string>»<\/string>"
# perl syntax used below
# -i: inplace editing
# -p: iterate over files
You can’t perform that action at this time.