Skip to content

Instantly share code, notes, and snippets.

Avatar

Stefan stefanschmidt

View GitHub Profile
@stefanschmidt
stefanschmidt / authenticate-ldap.sh
Last active Feb 24, 2021
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)"
@stefanschmidt
stefanschmidt / nrrd-dims.sh
Created Apr 13, 2016
Show dimensions of an NRRD volume on OS X
View nrrd-dims.sh
# depends on teem (available via Homebrew)
unu head volume.nrrd | grep sizes
@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 / 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
chdir
safe_system 'mv *.pkg/Payload Payload.gz'
safe_system 'ls | grep -v Payload | xargs rm -r'
end
end
@stefanschmidt
stefanschmidt / switch-guillemets.sh
Last active Mar 13, 2016
Switch orientation of guillemets in Textmate from outwards to inwards (or vice-versa)
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
@stefanschmidt
stefanschmidt / convert-img-to-pdf.sh
Created Dec 13, 2015
Convert raster images with same pixel size but different resolution to same size PDF
View convert-img-to-pdf.sh
convert page.png -units PixelsPerInch -density 300x300 page.pdf
@stefanschmidt
stefanschmidt / screen.rb
Created Dec 7, 2015
Linuxbrew Formula for GNU Screen with properly working task bar and custom session folder
View screen.rb
class Screen < Formula
homepage "https://www.gnu.org/software/screen"
stable do
url "http://ftpmirror.gnu.org/screen/screen-4.2.0.tar.gz"
mirror "https://ftp.gnu.org/gnu/screen/screen-4.2.0.tar.gz"
sha256 "7dc1b7a3e7669eefe7e65f32e201704d7a11cc688244fcf71757f7792a5ff413"
end
head do
@stefanschmidt
stefanschmidt / parallel.rb
Last active Dec 7, 2015
Linuxbrew Formula for GNU Parallel, patched to ignore global configuration (/etc/parallel/config) thus avoiding the --tollef flag
View parallel.rb
class Parallel < Formula
desc "GNU parallel shell command"
homepage "https://savannah.gnu.org/projects/parallel/"
url "http://ftpmirror.gnu.org/parallel/parallel-20151122.tar.bz2"
mirror "https://ftp.gnu.org/gnu/parallel/parallel-20151122.tar.bz2"
sha256 "550a63be340f931b91dbfe0e726c64522f74ec5afd7a64086603533c694b165e"
head "http://git.savannah.gnu.org/r/parallel.git"
conflicts_with "moreutils", :because => "both install a 'parallel' executable."
@stefanschmidt
stefanschmidt / sharpen-text-image.sh
Last active Dec 1, 2015
Sharpen blurry low-resolution images with scanned text
View sharpen-text-image.sh
convert input.png -sharpen 2x10 output.png
@stefanschmidt
stefanschmidt / repeat-text.sh
Created Nov 11, 2015
Repeat a text snippet from the pasteboard n times
View repeat-text.sh
yes pbpaste | head -n 100 | bash