\documentclass{beamer}
\mode<presentation>
{
%  \usetheme{AnnArbor}
%  \usetheme{Dresden}
%  \usetheme{Montpellier}
%  \usetheme{Antibes}
%  \usetheme{Frankfurt}
%  \usetheme{PaloAlto}
%  \usetheme{Bergen}
%  \usetheme{Goettingen}
%  \usetheme{Pittsburgh}	%!!
%  \usetheme{Berkeley}
%  \usetheme{Hannover}
%  \usetheme{Rochester}		%!!!
%  \usetheme{Berlin}
%  \usetheme{Ilmenau}
%  \usetheme{Singapore}
%  \usetheme{Boadilla}		%viel platz
%  \usetheme{JuanLesPins}
%  \usetheme{Szeged}		%!
%  \usetheme{boxes}
%  \usetheme{Luebeck}
%  \usetheme{Warsaw}
% \usetheme{Copenhagen}
  \usetheme{Madrid}
%  \usetheme{Darmstadt}
%  \usetheme{Malmoe}
%  \usetheme{default}
%  \usetheme{Marburg}

%  \setbeamercovered{transparent}
  % oder auch nicht

  %navigation aus, klaut nur platz
  %\setbeamertemplate{navigation symbols}{}
  \beamertemplatenavigationsymbolsempty  
}
\usepackage[latin1]{inputenc}
%\usepackage[german]{babel}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amssymb}
%\usepackage{natbib}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{subfigure}
% oder was auch immer

\usepackage[latin1]{inputenc}
% oder was auch immer

\usepackage{times}
\usepackage[T1]{fontenc}
% Oder was auch immer. Zu beachten ist, das Font und Encoding passen
% müssen. Falls T1 nicht funktioniert, kann man versuchen, die Zeile
% mit fontenc zu löschen.

\usepackage{listings} 

\lstset{
language=Matlab,                % choose the language of the code
tabsize=2,
frame=none, 
numbers=left, 
numberstyle=\tiny, 
numbersep=5pt,
stepnumber=2,
basicstyle=\tiny
}


\lstset{captionpos=b,
	tabsize=3,
	frame=lines, 
	numbers=none, 
	stepnumber=0, 
	escapeinside=,
	showstringspaces=false,
	numbersep=10pt
}

\title[]% (optional, nur bei langen Titeln nötig)
{Beyond the Mouse -- A Short Course on Programming}

\subtitle
{7. Unix Tools II}

\author[Ronni Grapenthin]% (optional, nur bei vielen Autoren)
{Ronni Grapenthin}
\institute[UAF/GI] % (optional, aber oft nötig)
{
Geophysical Institute, University of Alaska Fairbanks
}

% - Namen müssen in derselben Reihenfolge wie im Papier erscheinen.
% - Der \inst{?} Befehl sollte nur verwendet werden, wenn die Autoren
%   unterschiedlichen Instituten angehören.

% - Der \inst{?} Befehl sollte nur verwendet werden, wenn die Autoren
%   unterschiedlichen Instituten angehören.
% - Keep it simple, niemand interessiert sich für die genau Adresse.

\date[\today] % (optional, sollte der abgekürzte Konferenzname sein)
{\today}
% - Vollee oder abgekürzter Name sind möglich.
% - Dieser Eintrag ist nicht für das Publikum gedacht (das weiß
%   nämlich, bei welcher Konferenz es ist), sondern für Leute, die die
%   Folien später lesen.

\AtBeginSection[]
{
  \frame{
    \frametitle{Today's schedule}
    \tableofcontents[currentsection,currentsubsection]
  }
}

% Falls Aufzählungen immer schrittweise gezeigt werden sollen, kann
% folgendes Kommando benutzt werden:

%\beamerdefaultoverlayspecification{<+->}

%\pgfdeclareimage[width=1.75cm,height=1.75cm]{logo_hu}{redoubt_images/pdc_cloud_2.pdf}
%\titlegraphic{\pgfuseimage{logo_hu}}

\setbeamertemplate{footline}[frame number]

\begin{document}

\frame{
	\begin{columns}[t]
	\column{0.5\textwidth}
		\titlepage
	\column{0.5\textwidth}
		\begin{center}
		\includegraphics[width=.75\textwidth]{images/xkcd_2009_04_14_well_2_panel_2.pdf}
		\end{center}
		\begin{flushright}
			\tiny{``The Uncomfortable Truths Well'',\\ http://xkcd.com/568 (April 13, 2009)}
		\end{flushright}
	\end{columns}
}

\frame{
  \frametitle{Today's schedule \dots}
  \tableofcontents
}

\section[Introduction]{Introduction}
\frame{
  \frametitle{Introduction}
	\begin{block}{Goal for today:}
	\begin{itemize}
		\item introduce a couple tools: ssh, rsync, make, svn
		\item explain how they work by themselves
		\item show how you can orchestrate them into a decent project management suite 
	\end{itemize}
	\end{block}
}
		

\section[SSH]{Remote access: ssh}
\frame{
  \frametitle{Remote access: ssh}
	{\tt ssh} (secure shell): log into and execute commands on remote machine
	\begin{center}
		\includegraphics<1>[width=\textwidth]{images/07_login_01.pdf}
		\includegraphics<2>[width=\textwidth]{images/07_login_02.pdf}
		\includegraphics<3>[width=\textwidth]{images/07_login_03.pdf}
		\includegraphics<4>[width=\textwidth]{images/07_login_04.pdf}
		\includegraphics<5>[width=\textwidth]{images/07_login_05.pdf}
		\includegraphics<6>[width=\textwidth]{images/07_login_06.pdf}
	\end{center}
}


\frame{
  \frametitle{Remote access: ssh}
	\begin{block}{Command line syntax (see man page!)}<1->
	    {\tt ssh [A LOT OF OPTIONS] [user@]hostname [command]}
	\end{block}
	\begin{block}{Example -- Logging into GPS webserver}<2->
	    {\tt > ssh -2Y ronni@fairweather.gps.alaska.edu} \\
	Opens a new session on host {\tt fairweather.gps.alaska.edu} for user {\tt ronni} 
	using protocol SSH 2 with trusted X11 forwarding.
	\end{block}
	\begin{block}{Why/when would you need that?}<3->
	\begin{itemize}	
		\item Whenever you don't want to walk to the machine.
		\item Can't access data locally.
		\item You are actually, physically, and really on that machine (isn't the Internet great?)
		\item Many tools (svn, rsync, ...) offer to use ssh tunnels (they do their job after an SSH session has been established).
	\end{itemize}
	\end{block}
}

\section[Backup]{Backup Strategies}
\frame{
  \frametitle{What is a \emph{backup}?}
	\begin{block}{Backup, backup!}
	\begin{itemize}
		\item Creating a copy of something that must never get lost.
		\item data, results, settings, figures, writing (YOUR THESIS), \dots
		\item \dots because hard drives sometimes die, laptops get lost, fires burn down houses, you get the idea.
	\end{itemize}
	\end{block}

	\begin{block}{General strategies}<2->
	\begin{itemize}
		\item<2-> Episodically create a physical copy on a medium different from your hard drive (usb drive).
		\item<3-> OR use one of the gazillion tools that help you with this. 
		\item<4-> We'll concentrate on {\tt rsync}
		\item<5-> Whatever method you choose, every now and then make sure the files can indeed be recovered!
	\end{itemize}
	\end{block}
}

\frame{
  \frametitle{{\tt rsync}: a fast, versatile, remote (and local) file-copying tool}
	\begin{block}{Command line syntax (see man page!)}<1->
		\lstset{language=sh}
		\lstinputlisting{./listings/07_unixtools2/rsync_usage.txt}
	\end{block}
	\begin{itemize}
		\item<2-> If any of the files already exist on the remote system then {\tt rsync} sends only the differences.
		\item<3-> {\tt -avz} transfer in ``archive'' mode: ensures  that  symbolic  links, permissions, etc. 
			  are preserved. Compression is used to reduce the size of data portions.
	\end{itemize}

}

\frame{
  \frametitle{{\tt rsync}: example}
	\begin{block}{}
		\lstset{language=sh}
		\lstinputlisting{/home/roon/bin/webupdate}
	\end{block}
	\begin{block}{}<2->
		\lstset{language=sh}
		\lstinputlisting{./listings/07_unixtools2/rsync_examples.csh}
	\end{block}
}

\section[Makefiles]{Makefiles}
\frame{
  \frametitle{{\tt make} my day!}
	\begin{block}{}<1->
	\begin{itemize}
		\item {\tt make} is a program that (usually) lives in {\tt /usr/bin}
		\item determines which parts of a project need to be updated depending on those that changed
		\item {\tt make} does that according to rules defined in a {\tt Makefile}
		\item has its roots in the programming world, but can be used for anything (link coffee machine to USB port, write rules, {\tt make coffee})
	\end{itemize}
	\end{block}
}

\frame{
  \frametitle{{\tt make} my day!}
	\begin{block}{Make Rules}<1->
	{\tt target ... : prerequisites ... \\
		<TAB> command 1 \\
		<TAB> command 2 \\
		    ... \\
		<TAB> command N \\
	}
	\end{block}

	\begin{block}{}<2->
	\begin{itemize}
		\item {\tt target}: name of a file to be created or an action to be carried out (e.g. {\tt update})
		\item {\tt prerequisite}: a file/target necessary to create the target, often there are many prerequisite{\bf s}, is optional.
		\item {\tt command}: action that {\tt make} carries out. \alert{Tabulator, tab, <TAB>, whatever this one character} MUST be at the beginning of each command line
   	\end{itemize}
	\end{block}{}
}

\frame{
  \frametitle{{\tt make} my day!}
	\begin{block}{Make Example}<1->
	\lstset{language=make}
	\lstinputlisting{./listings/07_unixtools2/Makefile-delta}
	\end{block}
}

\frame{
  \frametitle{{\tt make} my day even better!}
	\begin{block}{Make can do variables (and a lot more), too:}<1->
	\lstset{language=make}
	\lstinputlisting{./listings/07_unixtools2/Makefile-vars}
	\end{block}
}

\section[Version Control]{Version control (with subversion)}
\frame{
  \frametitle{Version control (with subversion)}
	\begin{block}{What is `version control'?}<1->
		``Version control is the art of managing changes to information.'' (svnbook) 
		\begin{itemize}
			\item a fileserver that remembers every change ever written to it.
			\item traditionally used by programmers: change little bits of code on one day only to undo it the next day.
			\item well, that's just what we do with papers, theses, \dots
		\end{itemize}
	\end{block}

	\begin{block}{What is `version control' NOT?}<2->
	\begin{itemize}
		\item NOT a backup: creates value (history, log entries, \dots)\\
		\item Backup your repository every now and then.
	\end{itemize}
	\end{block}

	\begin{block}{What can be under version control?}<3->
		Depends on tool: CVS -- only text files, subversion -- text and binary files
	\end{block}
}	

\frame{
  \frametitle{How it works}
	\includegraphics[width=\textwidth]{images/07_svn.pdf}
}	

\frame{
  \frametitle{Creating/managing a repository: {\tt svnadmin}}
	\begin{block}{Repository creation (in your home directory}
		{\tt \$> svnadmin create --fs-type fsfs /home/USER/repos}
	\end{block}
	\begin{block}{Preparing your project (repository layout):}
		{\tt \$> mkdir my_project}\\
		{\tt \$> cd my_project}\\
		{\tt \$> mkdir trunk branches tags}\\
		{\tt \$> mv <project-files> trunk}\\
	\end{block}
	\begin{block}{Putting your stuff under version control}
		{\tt \$> svn import my_project file::///home/USER/repos}
	\end{block}
}	


\section[Putting it all together]{Putting it all together \dots}
\frame{
  \frametitle{Putting it all together \dots (assuming we're the only ones working on a project)}


	-setting up a repository (locally, server, anywhere) (pick the right filesystem!)
	-setting up a project, 
	-first commit
	-commit-update cycle


	- create a new project: {\tt new\_project.csh <project-name>}
	- what is version control, why should we use it?
	- don't mistake that with backup! (creates additional value: the history, logs, etc, you wanna back up your versioning system from time to time)
	-what can be controlled (depends on tool: svn: pretty much everything)
	-setting up a repository (locally, server, anywhere) (pick the right filesystem!)
	-setting up a project, 
	-first commit
	-commit-update cycle
}	

\end{document}
