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 |
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 |
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 |
View mx-query.rb
# requires net-dns gem | |
require 'net/dns' | |
res = Net::DNS::Resolver.new | |
mx = res.mx("google.com") | |
mx.first.exchange |
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' |
View authenticate-ldap.sh
# 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)" |
View nrrd-dims.sh
# depends on teem (available via Homebrew) | |
unu head volume.nrrd | grep sizes |
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 {} + |
View pdftk.rb
require 'formula' | |
class PkgExtract < CurlDownloadStrategy | |
def stage | |
safe_system '/usr/bin/xar', '-xf', @tarball_path | |
chdir | |
safe_system 'mv *.pkg/Payload Payload.gz' | |
safe_system 'ls | grep -v Payload | xargs rm -r' | |
end | |
end |
View switch-guillemets.sh
# 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 |
NewerOlder