Mount OSX SMB Share From Linux

A small reminder for all the options:
mount.cifs //1.2.3.4/public /mnt/public -o user=myusername,password=mypassword,nounix,sec=ntlmssp,noperm,rw


Time Machine & Local Snapshots

Time machine can keep local snapshots. While this feature is useful if you travel and don’t have access to your Time Capsule, the local snapshots can consume a lot of the local disk space in /.MobileBackups. There is a complex Removal Algorithm for old local snapshots based on the remaining free disk space.

To find out how much space your local snapshots consume (Local Snapshots):

  • Apple-Logo → About This Mac → Further Information → Storage: Backup == Local Snapshot Space
  • Alternatively from commandline:
    test -d /.MobileBackups && du -hcs /.MobileBackups

It is useful to control the behavior of the local snapshots yourself (Controlling Local Snapshots) using tmutil disablelocal and tmutil enablelocal.


Start VNC Server on OSX from Commandline

The builtin VNC server can be started using commandline (i.e. with ssh). As root do:

cd /Library/Preferences
echo enabled > com.apple.ScreenSharing.launchd
touch /etc/ScreenSharing.launchd


Movie Import Problem iTunes 11 – Workaround

In iTunes 11.0.11 (12) 64-Bit there is a bug, which prevents movie import. Once a movie is imported (Drag & Drop or manually) it does not show up in iTunes. Nevertheless the file is copied to the iTunes directory Home Videos and is inserted into the library file iTunes Library.xml. If you wait a while the movies will show up (at least some in my case…).

This is a workaround:

  1. Click on Movies
  2. Click on Home Videos
  3. Right-Click on any movie here:
    1. Get Info
    2. Options tab
    3. Change media kind to movie

Your movies will start to show up slowly…


Creating an Envelope from Commandline Using LaTeX

This small piece of code will create an envelope from commandline…

#!/bin/zsh

MYADDRESS = “Mr X // Street 1 // ZIP”

usage() {
   echo “$0 – print envelopes using LaTeX”
   echo ”   address:   Mr. A // Street 123 // ZIP City, State // Country”
   echo ”   -f <a4,c4,c5,c6,dl> default: $fomat”
   echo ”         a4: a4              “
   echo ”         c4: a4              “
   echo ”         c5: a4 folded in 1/2″
   echo ”         c6: a4 folded in 1/4″
   echo ”         dl: a4 folded in 1/3″
   exit 0
}

while getopts “f:h” opt; do
   case $opt in
      f) format=$OPTARG; ;;
      h) usage; ;;
   esac
done
shift $(($OPTIND -1))

if [[ $format == c6 ]]; then
   lx=114mm
   ly=162mm
elif [[ $format == c5 ]]; then
   lx=162mm
   ly=229mm
elif [[ $format == a4 ]]; then
   lx=210mm
   ly=397mm
elif [[ $format == c4 ]]; then
   lx=229mm
   ly=324mm
elif [[ $format == dl ]]; then
   lx=100mm
   ly=210mm
else
   exit 1
fi


ADDRESS=${@//\/\//\\newline}
MYADDRESS=${MYADDRESS//\/\//\/}

[[ -z $ADDRESS ]] && usage

TMP=$(mktemp -d /tmp/envelope-XXXXXX)
cd $TMP

cat << eof > envelope.tex
\documentclass{article}
\usepackage[margin=0.2cm,top=0.7cm,papersize={$lx,$ly},landscape,twoside=false]{geometry}
\usepackage{oldgerm}
\usepackage[latin1]{inputenc}

\setlength\parskip{0pt}
\pagestyle{empty}

\def\myaddress{$MYADDRESS}
\def\address{$ADDRESS}

\begin{document}

\begin{minipage}{\textwidth}
{\fontencoding{U}\fontfamily{yswab}\fontseries{m}\fontshape{n}\selectfont
\myaddress 
}
\end{minipage} 
 
\Large
\vspace{$((${lx/mm/}-60))mm}
\setlength\parindent{$((${ly/mm/}/2))mm}
 
\begin{minipage}{\textwidth}
\address
\end{minipage}
 
\end{document}
eof
 
pdflatex envelope.tex
lpr -o Duplex=None -o Manualfeed=On -o InputSlot=Envelope -o PageSize=Custom.${lx/mm/}x${ly} -o PageRegion=Custom.${lx/mm/}x${ly} -Penvelope envelope.pdf
rm -rf $TMP

Make an Image with Email Address

This is a small piece of code to create an image from your Email address:

#!/bin/bash
echo $0 Name Emailaddress
[[ -z $2 ]] && exit 2
NAME=$1
shift
convert -size 250×30 xc:transparent -font Verdana -fill “#003399” -pointsize 16 -draw “text 5,15 ‘Email: $@'” $NAME-mail.png


Scan PDF from Commandline

In the following I show a small piece of code to scan PDF files from commandline:

#!/bin/bash
cat << EOF 
— $0 — Scan Images -> PNG-Archive & PDF
Parameters:
   (1) Name
   -> Scanning: counter_start counter_increment
   -> Postprocessing: 
      -rotate (by 90 deg)
      -gray (keep it grayscale)
EOF

function DIE { echo “$@”>&2; exit -1; }
function is_installed {
   while [[ -n $1 ]]; do
      [[ -z $( type -p $1  ) ]] && DIE “missing: $1”
      shift
   done
}
#is_installed convert pdftk scanimage

[[ -z $1 ]] && DIE “missing name”
NAME=$1
shift

if [[ -n $2 ]]; then
   CNT=$1
   CNT_INC=$2
   shift 2

   MODE=Lineart
   RES=300
   echo “Scanning images”
   scanimage –batch=$NAME”_%d”.tif –batch-increment $CNT_INC –batch-start $CNT –source ADF –mode $MODE –resolution $RES -x 210 -y 297 -v
   exit
fi

#unpaper –layout double –output-pages 2
#http://unpaper.berlios.de/unpaper.html

ROTATE=””
GRAY=”-threshold 50%”
while [[ -n $1 ]]; do
   case $1 in 
      -rotate) ROTATE=”-rotate 90″; shift; ;;
      -gray) GRAY=””; shift; ;;
      *) shift; ;;
   esac
done
 
echo “Processing images:”
for FILE in $NAME*tif; do
   echo “Processing “$FILE”:”
   PREFIX=`echo $FILE | sed ‘s/.tif//g’`
   LIMITS=”-limit memory 512 -limit map 512″
   PAGE=”$ROTATE -page a4 +repage”
   COMPRESSION=”-compress Group4″
   #[[ ! -e $PREFIX.png ]] && convert $LIMITS $GRAY -monitor $FILE $PREFIX.png
   [[ ! -e $PREFIX.pdf ]] && convert $LIMITS $PAGE $GRAY $COMPRESSION -monitor $FILE $PREFIX.pdf
done
 
echo “Creating PDF”
CNT_MAX=`find -name “$NAME*pdf” | tr -cd 0-9″\n” | awk ‘$1>max{max=$1}END{print max}’`
FILES=””
for I in `seq 1 $CNT_MAX`; do FILES=$FILES” ${NAME}_$I.pdf”; done;
pdftk $FILES cat output $NAME.pdf
 
echo “Creating archive”
#tar cvjf ${NAME}_png.tar.bz2 ${NAME}*png
tar cvjf ${NAME}_tif.tar.bz2 ${NAME}*tif
 
echo “Cleanup”
rm ${NAME}_*.pdf *tif #*png