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 / 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 / remove-annotations.sh
Last active Aug 8, 2020
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 / show-third-party-osx.sh
Last active Jul 18, 2020
Show all third party extensions on OS X (From forum posting by Linc Davis)
View show-third-party-osx.sh
# Show all thirdparty kernel extensions
kextstat -kl | awk '!/com\.apple/ {print $6 $7}'
# Show all thirdparty launch services (root)
sudo launchctl list | sed 1d | awk '!/0x|com\.apple/ {print $3}'
# Show all thirdparty launch services (user)
launchctl list | sed 1d | awk '!/0x|com\.apple/ {print $3}'
# Show all extensions in the library folders
@stefanschmidt
stefanschmidt / uninstall-parallels7-ml.sh
Last active Jul 13, 2020
Completely Uninstall Parallels Desktop 7 on OS X 10.8 (Mountain Lion)
View uninstall-parallels7-ml.sh
# Unload all Parallels kernel extensions
for kext in $(kextstat | grep parallels | awk '{print $6}'); do kextunload -v 1 -b $kext; done
# Delete all Parallels kernel extensions
rm -v /System/Library/Extensions/prl*
# Delete all other Parallels files
rm -vr \
/Applications/Parallels\ Desktop.app \
/Library/Parallels/Parallels\ Service.app \
@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 / toggle-screen-sharing
Last active May 18, 2020
Enable/Disable Screen Sharing on OSX
View toggle-screen-sharing
# Enable Screen Sharing
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
# Disable Screen Sharing
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
@stefanschmidt
stefanschmidt / osx-software-update-urls.txt
Created Jan 4, 2014
URLs of the index files used by the software update client on OS X
View osx-software-update-urls.txt
10.3 (Panther): http://swscan.apple.com/scanningpoints/scanningpointX.xml
10.4 (Tiger): http://swscan.apple.com/content/catalogs/index-1.sucatalog
10.5 (Leopard): http://swscan.apple.com/content/catalogs/others/index-leopard.merged-1.sucatalog
10.6 (Snow Leopard): http://swscan.apple.com/content/catalogs/others/index-leopard-snowleopard.merged-1.sucatalog
10.7 (Lion): http://swscan.apple.com/content/catalogs/others/index-lion-snowleopard-leopard.merged-1.sucatalog
10.8 (Mountain Lion): http://swscan.apple.com/content/catalogs/others/index-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog
10.9 (Mavericks): http://swscan.apple.com/content/catalogs/others/index-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog
10.9 (Mavericks incl. seeds): http://swscan.apple.com/content/catalogs/others/index-10.9seed-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog
@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 / authenticate-ldap.sh
Last active Apr 7, 2019
Authenticate via LDAP on the command line
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)"
You can’t perform that action at this time.