Skip to content

Instantly share code, notes, and snippets.

View stefanschmidt's full-sized avatar

Stefan stefanschmidt

  • Hamburg, Germany
View GitHub Profile
@stefanschmidt
stefanschmidt / smart-selftest-osx.sh
Last active December 16, 2015 23:09
Run an extended S.M.A.R.T. selftest on a hard disk drive on OS X
brew install smartmontools
# launch selftest in background during regular system operation (~2h)
smartctl -c -t long disk0
# get test results from S.M.A.R.T. error log
smartctl -l selftest disk0
@stefanschmidt
stefanschmidt / gnu-getopt-in-libsystem_c.log
Last active December 17, 2015 06:28
GNU-like getopt function in Mountain Lion's libsystem_c.dylib
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.8.3
BuildVersion: 12D78
$ otool -L /usr/lib/system/libsystem_c.dylib | sed -nE 's/.*libsystem_c.dylib.*current version (.*)\)/\1/p'
825.26.0
$ nm /usr/lib/system/libsystem_c.dylib | grep getopt
000000000005d624 T _getopt
@stefanschmidt
stefanschmidt / install_calibre_cli_tools.py
Created June 10, 2013 20:56
Install Calibre CLI Tools to a non-standard location (e.g. Homebrew Cellar)
#!/usr/bin/python
import os
calibre_bin_dir = '/opt/homebrew-cask/Caskroom/calibre/latest/calibre.app/Contents/MacOS'
console_bin_dir = '/opt/homebrew-cask/Caskroom/calibre/latest/calibre.app/Contents/console.app/Contents/MacOS'
destination_bin_dir = '/Users/stefan/.homebrew/Cellar/calibre/0.9.34/bin'
calibre_scripts = [
'lrfviewer',
'calibre',
@stefanschmidt
stefanschmidt / disable-supply-levels-check.sh
Created June 11, 2013 14:49
Disable Check of Printer Supply Levels on OS X
#!/bin/bash
# If not root then update sudo time stamp
if [[ $EUID -ne 0 ]]; then
sudo -v
fi
for file in /etc/cups/ppd/*.ppd; do
echo "Disabling printer supply check for $file"
sudo bash -c "echo -e \"\n*cupsSNMPSupplies: False\" >> $file"
@stefanschmidt
stefanschmidt / disable-continuous-spell-checking-osx.sh
Created June 22, 2013 22:33
Disable Continuous Spell Checking on OS X
defaults write -g NSAllowContinuousSpellChecking -bool false
@stefanschmidt
stefanschmidt / close-all-gnu-screens.sh
Created July 31, 2013 14:44
Close all GNU Screens on Linux
screen -ls | sed -nr 's/\s+([0-9]+).*/\1/p' | xargs kill
@stefanschmidt
stefanschmidt / xcode_cli_without_admin_rights.sh
Last active December 21, 2015 07:49
Using Xcode Command Line Tools on OS X Lion without Admin Rights
lion_sdk="$HOME/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk"
lion_bin="$HOME/Applications/Xcode.app/Contents/Developer/usr/bin"
lion_libexec="$HOME/Applications/Xcode.app/Contents/Developer/usr/libexec"
lion_llvm="$HOME/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11"
python_include="$lion_sdk/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7"
export C_INCLUDE_PATH="$lion_sdk/usr/include"
export LIBRARY_PATH="$lion_sdk/usr/lib"
export CPPFLAGS="-I$python_include"
export PATH=$HOME/.python/bin:$HOME/Library/Python/2.7/bin:$lion_bin:$lion_libexec:$lion_llvm:$PATH
@stefanschmidt
stefanschmidt / set-safari-language.sh
Created August 23, 2013 01:22
Set Safari to use English instead of the system-wide Language
defaults write -app Safari AppleLanguages -array en
@stefanschmidt
stefanschmidt / monodevelop-pantheon.sh
Last active December 21, 2015 15:58
Make MonoDevelop work in a external terminal window on elementary OS
sudo apt-get install gnome-terminal xterm
@stefanschmidt
stefanschmidt / silence-dropbox.sh
Created August 27, 2013 10:37
Stop Dropbox from asking for admin password after installation to ~/Applications
chmod 0000 ~/Applications/Dropbox.app/Contents/Resources/*.tgz