summaryrefslogtreecommitdiff
path: root/slides
diff options
context:
space:
mode:
authorHardik Ghaghada2014-06-12 13:26:52 +0530
committerHardik Ghaghada2014-06-12 13:26:52 +0530
commit870dc1fbb3c2ab9a93395dfcabab341253d287ac (patch)
treee5f494493a6eef5a317a49ad0759d05684de6ed7 /slides
parent1f7318ca9553270899537d98d75e9f4fced85ed4 (diff)
downloadsees-870dc1fbb3c2ab9a93395dfcabab341253d287ac.tar.gz
sees-870dc1fbb3c2ab9a93395dfcabab341253d287ac.tar.bz2
sees-870dc1fbb3c2ab9a93395dfcabab341253d287ac.zip
moving tex files to the respective slides directory of each tool
Diffstat (limited to 'slides')
-rw-r--r--slides/advanced-python/advanced_py.tex53
-rw-r--r--slides/advanced-python/more_py.tex51
-rw-r--r--slides/basic-python/func.tex294
-rw-r--r--slides/basic-python/intro.tex477
-rw-r--r--slides/basic-python/io_files_parsing.tex239
-rw-r--r--slides/basic-python/python.tex56
-rw-r--r--slides/basic-python/strings_loops_lists.tex457
-rw-r--r--slides/basic-python/tmp.tex1
-rw-r--r--slides/basic-python/tuples_dicts_sets.tex258
-rw-r--r--slides/latex/examples/glimpse-at-scipy.tex426
-rw-r--r--slides/latex/examples/sine.pngbin0 -> 27614 bytes
-rw-r--r--slides/latex/lab-workbook.tex133
-rw-r--r--slides/latex/slides.tex694
-rw-r--r--slides/latex/workbook/bibtex.rst35
-rw-r--r--slides/latex/workbook/example1.tex4
-rw-r--r--slides/latex/workbook/example10.tex19
-rw-r--r--slides/latex/workbook/example2.tex26
-rw-r--r--slides/latex/workbook/example3.tex23
-rw-r--r--slides/latex/workbook/example4.tex11
-rw-r--r--slides/latex/workbook/example5.tex24
-rw-r--r--slides/latex/workbook/example6.tex31
-rw-r--r--slides/latex/workbook/example7.tex13
-rw-r--r--slides/latex/workbook/example8.tex176
-rw-r--r--slides/latex/workbook/example9.tex11
-rw-r--r--slides/latex/workbook/lion_orig.pngbin0 -> 32381 bytes
-rw-r--r--slides/tdd/tdd.tex514
-rw-r--r--slides/ult/ult.tex1721
-rw-r--r--slides/vcs/vcs.tex516
28 files changed, 6263 insertions, 0 deletions
diff --git a/slides/advanced-python/advanced_py.tex b/slides/advanced-python/advanced_py.tex
new file mode 100644
index 0000000..b15419e
--- /dev/null
+++ b/slides/advanced-python/advanced_py.tex
@@ -0,0 +1,53 @@
+\documentclass[12pt,presentation]{beamer}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{green},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
+
+\title{Advanced Python}
+\author{FOSSEE}
+
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+
+\AtBeginSection[]
+{
+ \begin{frame}<beamer>
+ \frametitle{Outline}
+ \tableofcontents[currentsection]
+ \end{frame}
+}
+
+\begin{document}
+
+\maketitle
+
+\begin{frame}
+\frametitle{Outline}
+\setcounter{tocdepth}{3}
+\tableofcontents
+\end{frame}
+
+\include{slides/plotting}
+\include{slides/arrays}
+\include{slides/scipy}
+\include{slides/modules}
+
+\end{document}
diff --git a/slides/advanced-python/more_py.tex b/slides/advanced-python/more_py.tex
new file mode 100644
index 0000000..8b50ec4
--- /dev/null
+++ b/slides/advanced-python/more_py.tex
@@ -0,0 +1,51 @@
+\documentclass[12pt,presentation]{beamer}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{green},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
+
+\title{SEES: Advanced Python(2)}
+\author{FOSSEE}
+
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+
+\AtBeginSection[]
+{
+ \begin{frame}<beamer>
+ \frametitle{Outline}
+ \tableofcontents[currentsection]
+ \end{frame}
+}
+
+\begin{document}
+
+\maketitle
+
+\begin{frame}
+\frametitle{Outline}
+\setcounter{tocdepth}{3}
+\tableofcontents
+\end{frame}
+
+\include{slides/lambda}
+\include{slides/oop}
+
+\end{document}
diff --git a/slides/basic-python/func.tex b/slides/basic-python/func.tex
new file mode 100644
index 0000000..b66be06
--- /dev/null
+++ b/slides/basic-python/func.tex
@@ -0,0 +1,294 @@
+\section{Functions}
+
+\begin{frame}[fragile]
+ \frametitle{Abstracting}
+ \begin{itemize}
+ \item Reduce duplication of code
+ \item Fewer lines of code and hence lesser scope for bugs
+ \item Re-usability of code, that's already been written
+ \item Use functions written by others, without exactly knowing how
+ they do, what they are doing
+ \item \alert{Enter Functions!}
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{Defining functions}
+ \begin{itemize}
+ \item Consider the function \texttt{f(x) = x\textasciicircum{}2}
+ \item Let's write a Python function, equivalent to this
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: def f(x):
+ ....: return x*x
+ ....:
+
+ In[]: f(1)
+ In[]: f(2)
+ \end{lstlisting}
+ \begin{itemize}
+ \item \texttt{def} is a keyword
+ \item \texttt{f} is the name of the function
+ \item \texttt{x} the parameter of the function
+ \item \texttt{return} is a keyword; specifies what should be
+ returned
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Defining functions \ldots}
+ \begin{lstlisting}
+ In[]: def greet():
+ ....: print "Hello World!"
+ ....:
+
+ In[]: greet()
+ \end{lstlisting}
+ \begin{itemize}
+ \item \texttt{greet} is a function that takes no arguments
+ \item Also, it is not returning anything explicitly
+ \item But implicitly, Python returns \texttt{None}
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: def avg(a, b):
+ ....: return (a + b)/2
+ ....:
+
+ In[]: avg(12, 10)
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Doc-strings}
+ \begin{itemize}
+ \item It's highly recommended that all functions have documentation
+ \item We write a doc-string along with the function definition
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: def avg(a, b):
+ """ avg takes two numbers as input
+ and returns their average"""
+
+ ....: return (a + b)/2
+ ....:
+
+ In[]: avg?
+ In[]: greet?
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Returning multiple values}
+ \begin{itemize}
+ \item Return area and perimeter of circle, given radius
+ \item Function needs to return two values
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: def circle(r):
+ """returns area and perimeter of a
+ circle given, the radius r"""
+
+ ....: pi = 3.14
+ ....: area = pi * r * r
+ ....: perimeter = 2 * pi * r
+ ....: return area, perimeter
+ ....:
+
+ In[]: circle(4)
+ In[]: a, p = circle(6)
+ In[]: print a
+ In[]: print p
+ \end{lstlisting}
+ \begin{itemize}
+ \item Any number of values can be returned
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{What? -- 1}
+ \begin{lstlisting}
+ In[]: def what( n ):
+ ....: if n < 0: n = -n
+ ....: while n > 0:
+ ....: if n % 2 == 1:
+ ....: return False
+ ....: n /= 10
+ ....: return True
+ ....:
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{What? -- 2}
+ \begin{lstlisting}
+ In[]: def what( n ):
+ ....: i = 1
+ ....: while i * i < n:
+ ....: i += 1
+ ....: return i * i == n, i
+ ....:
+ \end{lstlisting}
+\end{frame}
+
+\subsection*{Default \& Keyword Arguments}
+
+\begin{frame}[fragile]
+ \frametitle{Default arguments}
+ \begin{lstlisting}
+ In[]: round(2.484)
+ In[]: round(2.484, 2)
+
+ In[]: s.split() # split on spaces
+ In[]: s.split(';') # split on ';'
+
+ In[]: range(10) # returns numbers from 0 to 9
+ In[]: range(1, 10) # returns numbers from 1 to 9
+ In[]: range(1, 10, 2) # returns odd numbers from 1 to 9
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Default arguments \ldots}
+ \begin{lstlisting}
+ In[]: def welcome(greet, name="World"):
+ ....: print greet, name
+ ....:
+
+ In[]: welcome("Hi", "Guido")
+ In[]: welcome("Hello")
+ \end{lstlisting}
+ \begin{itemize}
+ \item Arguments with default values, should be placed at the end
+ \item The following definition is \alert{WRONG}
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: def welcome(name="World", greet):
+ ....: print greet, name
+ ....:
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Keyword Arguments}
+ \begin{lstlisting}
+ In[]: def welcome(greet, name="World"):
+ ....: print greet, name
+ ....:
+
+ In[]: welcome("Hello", "James")
+
+ In[]: welcome("Hi", name="Guido")
+
+ In[]: welcome(name="Guido", greet="Hey")
+
+ In[]: welcome(name="Guido", "Hey")
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Built-in functions}
+ \begin{itemize}
+ \item Variety of built-in functions are available
+ \item \texttt{abs, any, all, len, max, min}
+ \item \texttt{pow, range, sum, type}
+ \item Refer here:
+ \url{http://docs.python.org/library/functions.html}
+ \end{itemize}
+\end{frame}
+
+\subsection*{Variable Scope}
+
+\begin{frame}[fragile]
+ \frametitle{Arguments are local}
+ \begin{lstlisting}
+ In[]: def change(q):
+ ....: q = 10
+ ....: print q
+ ....:
+
+ In[]: change(1)
+ In[]: print q
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Variables inside function are local}
+ \begin{lstlisting}
+ In[]: n = 5
+ In[]: def change():
+ ....: n = 10
+ ....: print n
+ ....:
+ In[]: change()
+ In[]: print n
+ \end{lstlisting}
+ \begin{itemize}
+ \item Use the \texttt{global} statement to assign to global variables
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: def change():
+ ....: global n
+ ....: n = 10
+ ....: print n
+ ....:
+ In[]: change()
+ In[]: print n
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{global}
+ \begin{itemize}
+ \item Use the \texttt{global} statement to assign to global variables
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: def change():
+ ....: global n
+ ....: n = 10
+ ....: print n
+ ....:
+ In[]: change()
+ In[]: print n
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Mutable variables}
+ \begin{itemize}
+ \item Behavior is different when assigning to a list element/slice
+ \item Python looks up for the name, from innermost scope outwards,
+ until the name is found
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: name = ['Mr.', 'Steve', 'Gosling']
+ In[]: def change_name():
+ ....: name[0] = 'Dr.'
+ ....:
+ In[]: change_name()
+ In[]: print name
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Passing Arguments \ldots}
+ \begin{lstlisting}
+ In[]: n = 5
+ In[]: def change(n):
+ ....: n = 10
+ ....: print "n = %s inside change " %n
+ ....:
+ In[]: change(n)
+ In[]: print n
+ \end{lstlisting}
+
+ \begin{lstlisting}
+ In[]: name = ['Mr.', 'Steve', 'Gosling']
+ In[]: def change_name(n):
+ ....: n[0] = 'Dr.'
+ ....: print "n = %s inside change_name" %n
+ ....:
+ In[]: change_name(name)
+ In[]: print name
+ \end{lstlisting}
+\end{frame}
diff --git a/slides/basic-python/intro.tex b/slides/basic-python/intro.tex
new file mode 100644
index 0000000..52be064
--- /dev/null
+++ b/slides/basic-python/intro.tex
@@ -0,0 +1,477 @@
+\section{The Language}
+\begin{frame}[fragile]
+ \frametitle{Python!}
+ \begin{itemize}
+ \item Programming Language
+ \item Powerful, High-level, Interpreted, Multi-Platform
+ \item Elegant and highly readable syntax
+ \item Efficient high-level data structures
+ \end{itemize}
+ \begin{itemize}
+ \item Easy to learn
+ \item Allows to concentrate on the problem instead of the language
+ \item Increased Productivity
+ \end{itemize}
+ \begin{itemize}
+ \item Guido van Rossum -- BDFL
+ \item Conceived in December 1989
+ \item Named after ``Monty Python's Flying Circus'', a 70s comedy
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Why Python?}
+ \begin{itemize}
+ \item Extremely readable; Forces programmers to write readable code.
+ \item Interactive; Offers a very fast edit-test-debug cycle.
+ \item Doesn't get in your way; High-level data structures let you
+ focus on the problem
+ \item Handles memory management
+ \item Batteries included; Huge standard library for wide range of
+ tasks.
+ \item Object-oriented.
+ \item C, C++ and FORTRAN interfacing allows use of legacy code
+ \item Your time is more valuable than machine time!
+ \end{itemize}
+\end{frame}
+
+\section{The Interpreter}
+\begin{frame}[fragile]
+ \frametitle{Python interpreter}
+ \begin{itemize}
+ \item Let's get our hands dirty!
+ \item Start Python from your shell
+ \end{itemize}
+ \lstset{language=sh}
+ \begin{lstlisting}
+ $ python
+ \end{lstlisting} %$
+ \begin{lstlisting}
+Python 2.7.1 (r271:86832, Feb 21 2011, 01:28:26)
+[GCC 4.5.2 20110127 (prerelease)] on linux2
+Type "help", "copyright", "credits" or "license" for more information.
+>>>
+ \end{lstlisting}
+ \begin{itemize}
+ \item First line shows Python version (2.7.1)
+ \item \verb+>>>+ the interpreter's prompt
+ \item The interpreter is ready and waiting for your command!
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Hello World!}
+ \begin{itemize}
+ \item Type\texttt{print `Hello World'} and hitting enter
+ \end{itemize}
+ \begin{lstlisting}
+ >>> print 'Hello, World!'
+ Hello, World!
+ \end{lstlisting}
+ \begin{itemize}
+ \item The interpreter prints out the words \emph{Hello World}
+ \end{itemize}
+ \begin{itemize}
+ \item Hit \texttt{Ctrl-D} to exit the interpreter
+ \item We shall look at IPython, an enhanced interpreter
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Versions}
+ Before moving on \ldots
+ \begin{itemize}
+ \item Currently has two stable branches or versions, 2.x and 3.x
+ \item 3.x is not backward compatible
+ \item 3.x is deemed to be the future of Python
+ \item But, we shall stick to 2.x for this course
+ \item The ecosystem around Python 2.x hasn't yet moved to 3.x
+ \end{itemize}
+\end{frame}
+
+\subsection*{IPython}
+
+\begin{frame}[fragile]
+ \frametitle{Invoking IPython}
+ \begin{itemize}
+ \item An enhanced Python interpreter
+ \item Tab-completion, Easier access to help, Better history
+ \end{itemize}
+ \lstset{language=sh}
+ \begin{lstlisting}
+ $ ipython
+ \end{lstlisting} %$
+ \alert{If \texttt{ipython is not installed}, you need to install it!}
+ \begin{itemize}
+ \item The prompt is \texttt{In [1]:} instead of \verb+>>>+
+ \item \texttt{In} stands for input, 1 indicates the command number
+ \item Try \texttt{Hello World}
+ \end{itemize}
+ \begin{lstlisting}
+ In []: print 'Hello, World!'
+ Out[]: Hello, World!
+ \end{lstlisting}
+ {\tiny the numbers have been omitted to avoid confusion}
+ \begin{itemize}
+ \item Hit \texttt{Ctrl-D} to exit \texttt{ipython}; Say \texttt{y}
+ when prompted.
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Getting comfortable}
+ \begin{itemize}
+ \item Let's try some simple math to get comfortable
+ \end{itemize}
+ \begin{lstlisting}
+ In []: 1 + 2
+ In []: 5 - 3
+ In []: 7 - 4
+ In []: 6 * 5
+ \end{lstlisting}
+ \begin{itemize}
+ \item We get back the expected output
+ \item Output is displayed with an \texttt{Out[]}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{History \& Arrow Keys}
+ \begin{itemize}
+ \item Change the \texttt{print 1+2}
+ \item Use <UP-Arrow> to go back to \texttt{1+2} command
+ \item Use <LEFT-Arrow> to get to start of line; type \texttt{print }
+ \item Hit <RETURN>
+ \end{itemize}
+ \begin{lstlisting}
+ In []: print 1 + 2
+ \end{lstlisting}
+ \begin{itemize}
+ \item Now, change the previous command to \texttt{print 10*2}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Tab-Completion}
+ \begin{itemize}
+ \item We want to use \texttt{round} function
+ \item Type \texttt{ro}, and hit <TAB>
+ \end{itemize}
+ \begin{lstlisting}
+ In []: ro<TAB>
+ \end{lstlisting}
+ \begin{itemize}
+ \item Type \texttt{r}, and hit <TAB>
+ \item All possibilities are listed out, when ambiguous
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{?} for Help}
+ \begin{itemize}
+ \item To get help for \texttt{abs} function
+ \end{itemize}
+ \begin{lstlisting}
+ In []: abs?
+ In []: abs(19)
+ In []: abs(-10.5)
+ \end{lstlisting}
+ \begin{itemize}
+ \item Look at documentation for \texttt{round}
+ \item Optional arguments are denoted with square brackets
+ \texttt{[]}
+ \end{itemize}
+ \begin{lstlisting}
+ In []: round(2.484)
+ In []: round(2.484, 1)
+ In []: round(2.484, 2)
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{?} for Help}
+ \begin{itemize}
+ \item To get help for \texttt{abs} function
+ \end{itemize}
+ \begin{lstlisting}
+ In []: abs?
+ In []: abs(19)
+ In []: abs(-10.5)
+ \end{lstlisting}
+ \begin{itemize}
+ \item Look at documentation for \texttt{round}
+ \item Optional arguments are denoted with square brackets
+ \texttt{[]}
+ \end{itemize}
+ \begin{lstlisting}
+ In []: round(2.484)
+ In []: round(2.484, 1)
+ In []: round(2.484, 2)
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Interrupting}
+ \begin{lstlisting}
+ In []: round(2.484
+ ...:
+ \end{lstlisting}
+ \begin{itemize}
+ \item The \ldots prompt is the continuation prompt
+ \item It comes up, since we haven't completed previous command
+ \item Either complete by typing the missing \texttt{)}
+ \item OR hit \texttt{Ctrl-C} to interrupt the command
+ \end{itemize}
+ \begin{lstlisting}
+ In []: round(2.484
+ ...: ^C
+ \end{lstlisting}
+\end{frame}
+
+\section{Basic Datatypes and Operators}
+
+\begin{frame}[fragile]
+ \frametitle{Basic Datatypes}
+ \begin{itemize}
+ \item Numbers
+ \begin{itemize}
+ \item int
+ \item float
+ \item complex
+ \end{itemize}
+ \item Boolean
+ \item Sequence
+ \begin{itemize}
+ \item Strings
+ \item Lists
+ \item Tuples
+ \end{itemize}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{int}}
+ \begin{lstlisting}
+ In []: a = 13
+ In []: a
+ \end{lstlisting}
+ \begin{itemize}
+ \item \texttt{a} is a variable of the \texttt{int} type
+ \item Use the \texttt{type} command to verify
+ \end{itemize}
+ \begin{lstlisting}
+ In []: type(a)
+ \end{lstlisting}
+ \begin{itemize}
+ \item Integers can be arbitrarily long
+ \end{itemize}
+ \begin{lstlisting}
+ In []: b = 9999999999999999999999999999
+ In []: b
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{float}}
+ \begin{lstlisting}
+ In []: p = 3.141592
+ In []: p
+ \end{lstlisting}
+ \begin{itemize}
+ \item Decimal numbers are represented using the \texttt{float} type
+ \item Notice the loss of precision
+ \item Floats have a fixed precision
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{complex}}
+ \begin{lstlisting}
+ In []: c = 3+4j
+ \end{lstlisting}
+ \begin{itemize}
+ \item A complex number with real part 3, imaginary part 4
+ \end{itemize}
+ \begin{lstlisting}
+ In []: c.real
+ In []: c.imag
+ In []: abs(c)
+ \end{lstlisting}
+ \begin{itemize}
+ \item It's a combination of two floats
+ \item \texttt{abs} gives the absolute value
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Operations on numbers}
+ \begin{lstlisting}
+ In []: 23 + 74
+ In []: 23 - 56
+ In []: 45 * 76
+
+ In []: 8 / 3
+ In []: 8.0 / 3
+ In []: float(8) / 3
+ \end{lstlisting}
+ \begin{itemize}
+ \item The first division is an integer division
+ \item To avoid integer division, at least one number should be float
+ \item \texttt{float} function is changing int to float
+ \end{itemize}
+ \begin{lstlisting}
+ In []: 87 % 6
+ In []: 7 ** 8
+ \end{lstlisting}
+ \begin{itemize}
+ \item \texttt{\%} is used for modulo operation
+ \item \texttt{**} is used for exponentiation
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Variables \& assignment}
+ \begin{itemize}
+ \item All the operations could be done on variables
+ \end{itemize}
+ \begin{lstlisting}
+ In []: a = 23
+ In []: b = 74
+ In []: a * b
+
+ In []: c = 8
+ In []: d = 8.0
+ In []: f = c / 3
+ \end{lstlisting}
+ \begin{itemize}
+ \item Last two commands show assignment
+ \end{itemize}
+ \begin{lstlisting}
+ In []: c = c / 3
+ \end{lstlisting}
+ An operation like the one above, may equivalently be written as
+ \begin{lstlisting}
+ In []: c /= 3
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Booleans \& Operations}
+ \begin{itemize}
+ \item All the operations could be done on variables
+ \end{itemize}
+ \begin{lstlisting}
+ In []: t = True
+ In []: t
+ In []: f = not t
+ In []: f
+ In []: f or t
+ In []: f and t
+ \end{lstlisting}
+ \begin{itemize}
+ \item Multiple operation in a single command
+ \item We use parenthesis for explicitly stating what we mean
+ \item No discussion of operator precedence
+ \end{itemize}
+ \begin{lstlisting}
+ In []: (f and t) or t
+ In []: f and (t or t)
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Sequences}
+ \begin{itemize}
+ \item Hold a bunch of elements in a sequence
+ \item Elements are accessed based on position in the sequence
+ \item The sequence data-types
+ \begin{itemize}
+ \item str
+ \item list
+ \item tuple
+ \end{itemize}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Strings, Lists \& Tuples}
+ \begin{itemize}
+ \item Anything withing quotes is a string
+ \end{itemize}
+ \begin{lstlisting}
+ In []: greet_str = "hello"
+ \end{lstlisting}
+ \begin{itemize}
+ \item Items enclosed in \texttt{[ ]} and separated by \texttt{,}s
+ constitute a list
+ \end{itemize}
+ \begin{lstlisting}
+ In []: num_list = [1, 2, 3, 4, 5, 6, 7, 8]
+ \end{lstlisting}
+ \begin{itemize}
+ \item Items of a tuple are enclosed by \texttt{( )} instead of
+ \texttt{[ ]}
+ \end{itemize}
+ \begin{lstlisting}
+ In []: num_tuple = (1, 2, 3, 4, 5, 6, 7, 8)
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Operations on Sequences}
+ \begin{itemize}
+ \item Accessing elements
+ \end{itemize}
+ \begin{lstlisting}
+ In []: num_list[2]
+ In []: num_tuple[2]
+ In []: greet_str[2]
+ \end{lstlisting}
+ \begin{itemize}
+ \item Add two sequences of same type
+ \end{itemize}
+ \begin{lstlisting}
+ In []: num_list + [3, 4, 5, 6]
+ In []: greet_str + " world!"
+ \end{lstlisting}
+ \begin{itemize}
+ \item Get the length of a sequence
+ \end{itemize}
+ \begin{lstlisting}
+ In []: len(num_list)
+ In []: len(greet_str)
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Operations on Sequences \ldots}
+ \begin{itemize}
+ \item Check for container-ship of elements
+ \end{itemize}
+ \begin{lstlisting}
+ In []: 3 in num_list
+ In []: 'h' in greet_str
+ In []: 'w' in greet_str
+ In []: 2 in num_tuple
+ \end{lstlisting}
+ \begin{itemize}
+ \item Finding maximum and minimum
+ \end{itemize}
+ \begin{lstlisting}
+ In []: max(num_list)
+ In []: min(greet_str)
+ \end{lstlisting}
+ \begin{itemize}
+ \item Slice a sequence
+ \end{itemize}
+ \begin{lstlisting}
+ In []: num_list[1:5]
+ \end{lstlisting}
+ \begin{itemize}
+ \item Stride over a sequence
+ \end{itemize}
+ \begin{lstlisting}
+ In []: num_list[1:8:2]
+ \end{lstlisting}
+\end{frame}
+
diff --git a/slides/basic-python/io_files_parsing.tex b/slides/basic-python/io_files_parsing.tex
new file mode 100644
index 0000000..cb46cbe
--- /dev/null
+++ b/slides/basic-python/io_files_parsing.tex
@@ -0,0 +1,239 @@
+\section{I/O}
+
+\begin{frame}[fragile]
+ \frametitle{Printing}
+ \begin{lstlisting}
+ In[]: a = "This is a string"
+ In[]: a
+ In[]: print a
+ \end{lstlisting}
+ \begin{itemize}
+ \item Both \texttt{a}, and \texttt{print a} are showing the value
+ \item What is the difference?
+ \item Typing \texttt{a} shows the value; \texttt{print a} prints it
+ \item Typing \texttt{a} shows the value only in interpreter
+ \item In a script, it has no effect.
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: b = "A line \n New line"
+ In[]: b
+ In[]: print b
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{String formatting}
+ \begin{lstlisting}
+ In[]: x = 1.5
+ In[]: y = 2
+ In[]: z = "zed"
+ In[]: print "x is %2.1f y is %d z is %s" %(x, y, z)
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{print x} \& \texttt{print x,}}
+ \begin{itemize}
+ \item Open an editor
+ \item Type the following code
+ \item Save as \texttt{print\_example.py}
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: print "Hello"
+ In[]: print "World"
+
+ In[]: print "Hello",
+ In[]: print "World"
+ \end{lstlisting}
+ \begin{itemize}
+ \item Run the script using \texttt{\% run print\_example.py}
+ \item \texttt{print x} adds a newline whereas \texttt{print x,} adds
+ a space
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{raw\_input}}
+ \begin{lstlisting}
+ In[]: ip = raw_input()
+ \end{lstlisting}
+ \begin{itemize}
+ \item The cursor is blinking; waiting for input
+ \item Type \texttt{an input} and hit <ENTER>
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: print ip
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{raw\_input} \ldots}
+ \begin{lstlisting}
+ In[]: c = raw_input()
+ In[]: 5.6
+ In[]: c
+ In[]: type(c)
+ \end{lstlisting}
+ \begin{itemize}
+ \item \alert{\texttt{raw\_input} always takes a string}
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: name = raw_input("Please enter your name: ")
+ George
+ \end{lstlisting}
+ \begin{itemize}
+ \item \texttt{raw\_input} can display a prompt string for the user
+ \end{itemize}
+\end{frame}
+
+\section{Files}
+
+\begin{frame}[fragile]
+ \frametitle{Opening files}
+ \begin{lstlisting}
+ pwd # present working directory
+ cd /home/fossee # go to location of the file
+ \end{lstlisting}
+ {\tiny The file is in our present working directory}
+ \begin{lstlisting}
+ In[]: f = open('pendulum.txt')
+ In[]: f
+ \end{lstlisting}
+ \begin{itemize}
+ \item \texttt{f} is a file object
+ \item Shows the mode in which the file is open (read mode)
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Reading the whole file}
+ \begin{lstlisting}
+ In[]: pend = f.read()
+ In[]: print pend
+ \end{lstlisting}
+ \begin{itemize}
+ \item We have read the whole file into the variable \texttt{pend}
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: type(pend)
+ In[]: pend_list = pend.splitlines()
+ In[]: pend_list
+ \end{lstlisting}
+ \begin{itemize}
+ \item \texttt{pend} is a string variable
+ \item We can split it at the newline characters into a list of
+ strings
+ \item Close the file, when done; Also, if you want to read again
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: f.close()
+ In[]: f
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Reading line-by-line}
+ \begin{lstlisting}
+ In[]: for line in open('pendulum.txt'):
+ ....: print line
+ \end{lstlisting}
+ \begin{itemize}
+ \item The file object is an ``iterable''
+ \item We iterate over it and print each line
+ \item Instead of printing, collect lines in a list
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: line_list = [ ]
+ In[]: for line in open('pendulum.txt'):
+ ....: line_list.append(line)
+ \end{lstlisting}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{File parsing -- Problem}
+ \begin{lstlisting}
+ A;010002;ANAND R;058;037;42;35;40;212;P;;
+ \end{lstlisting}
+ \begin{itemize}
+ \item File with records like the one above is given
+ \item Each record has fields separated by ;
+ \item region code; roll number; name;
+ \item marks --- $1^{st}$ L; $2^{nd}$ L; math; science; social; total
+ \item pass/fail indicated by P/F; W if withheld and else empty
+ \end{itemize}
+
+ \begin{itemize}
+ \item We wish to calculate mean of math marks in region B
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Tokenization}
+ \begin{lstlisting}
+ In[]: line = "parse this string"
+ In[]: line.split()
+ \end{lstlisting}
+ \begin{itemize}
+ \item Original string is split on white-space (if no argument)
+ \item Returns a list of strings
+ \item It can be given an argument to split on that argrument
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: record = "A;015163;JOSEPH RAJ S;083;042;47;AA;72;244;;;"
+ In[]: record.split(';')
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Tokenization \ldots}
+ \begin{itemize}
+ \item Since we split on commas, fields may have extra spaces at ends
+ \item We can strip out the spaces at the ends
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: word = " B "
+ In[]: word.strip()
+ \end{lstlisting}
+ \begin{itemize}
+ \item \texttt{strip} is returning a new string
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{str} to \texttt{float}}
+ \begin{itemize}
+ \item After tokenizing, the marks we have are strings
+ \item We need numbers to perform math operations
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: mark_str = "1.25"
+ In[]: mark = int(mark_str)
+ In[]: type(mark_str)
+ In[]: type(mark)
+ \end{lstlisting}
+ \begin{itemize}
+ \item \texttt{strip} is returning a new string
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{File parsing -- Solution}
+ \begin{lstlisting}
+ In[]: math_B = [] # empty list to store marks
+ In[]: for line in open("sslc1.txt"):
+ ....: fields = line.split(";")
+
+ ....: reg_code = fields[0]
+ ....: reg_code_clean = reg_code.strip()
+
+ ....: math_mark_str = fields[5]
+ ....: math_mark = float(math_mark_str)
+
+ ....: if reg_code == "B":
+ ....: math_B.append(math_mark)
+
+ In[]: math_B_mean = sum(math_B) / len(math_B)
+ In[]: math_B_mean
+ \end{lstlisting}
+\end{frame}
diff --git a/slides/basic-python/python.tex b/slides/basic-python/python.tex
new file mode 100644
index 0000000..19be639
--- /dev/null
+++ b/slides/basic-python/python.tex
@@ -0,0 +1,56 @@
+\documentclass[12pt,presentation]{beamer}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{green},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
+
+\title{Basic Python}
+\author[FOSSEE] {FOSSEE}
+\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\date []{}
+
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+
+\AtBeginSection[]
+{
+ \begin{frame}<beamer>
+ \frametitle{Outline}
+ \tableofcontents[currentsection]
+ \end{frame}
+}
+
+\begin{document}
+
+\maketitle
+
+\begin{frame}
+\frametitle{Outline}
+\setcounter{tocdepth}{3}
+\tableofcontents
+\end{frame}
+
+\include{slides/intro}
+\include{slides/strings_loops_lists}
+\include{slides/io_files_parsing}
+\include{slides/func}
+\include{slides/tuples_dicts_sets}
+
+\end{document}
diff --git a/slides/basic-python/strings_loops_lists.tex b/slides/basic-python/strings_loops_lists.tex
new file mode 100644
index 0000000..26d7b54
--- /dev/null
+++ b/slides/basic-python/strings_loops_lists.tex
@@ -0,0 +1,457 @@
+\section{Strings}
+
+\begin{frame}[fragile]
+ \frametitle{What are Strings?}
+ \begin{itemize}
+ \item Anything quoted is a string
+ \item Single quotes, double quotes or triple single/double quotes
+ \item Any length --- single character, null string, \ldots
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: 'This is a string'
+ In[]: "This is a string too'
+ In[]: '''This is a string as well'''
+ In[]: """This is also a string"""
+ In[]: '' # empty string
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Why so many?}
+ \begin{itemize}
+ \item Reduce the need for escaping
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: "Python's strings are powerful!"
+ In[]: 'He said, "I love Python!"'
+ \end{lstlisting}
+ \begin{itemize}
+ \item Triple quoted strings can be multi-line
+ \item Used for doc-strings
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Assignment \& Operations}
+ \begin{lstlisting}
+ In[]: a = 'Hello'
+ In[]: b = 'World'
+ In[]: c = a + ', ' + b + '!'
+ \end{lstlisting}
+ \begin{itemize}
+ \item Strings can be multiplied with numbers
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: a = 'Hello'
+ In[]: a * 5
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Accessing Elements}
+ \begin{lstlisting}
+ In[]: print a[0], a[4], a[-1], a[-4]
+ \end{lstlisting}
+ \begin{itemize}
+ \item Can we change the elements?
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: a[0] = 'H'
+ \end{lstlisting}
+ \begin{itemize}
+ \item Strings are immutable!
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Problem - Day of the Week?}
+ \begin{itemize}
+ \item Strings have methods to manipulate them
+ \end{itemize}
+ \begin{block}{Problem}
+ Given a list, \texttt{week}, containing names of the days of the
+ week and a string \texttt{s}, check if the string is a day of the
+ week. We should be able to check for any of the forms like,
+ \emph{sat, saturday, Sat, Saturday, SAT, SATURDAY}
+ \end{block}
+ \begin{itemize}
+ \item Get the first 3 characters of the string
+ \item Convert it all to lower case
+ \item Check for existence in the list, \texttt{week}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Slicing}
+ \begin{lstlisting}
+ In[]: q = "Hello World"
+ In[]: q[0:3]
+ In[]: q[:3]
+ In[]: q[3:]
+ In[]: q[:]
+ In[]: q[-1:1]
+ In[]: q[1:-1]
+ \end{lstlisting}
+ \begin{itemize}
+ \item One or both of the limits, is optional
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Striding}
+ \begin{lstlisting}
+ In[]: q[0:5:1]
+ In[]: q[0:5:2]
+ In[]: q[0:5:3]
+ In[]: q[0::2]
+ In[]: q[2::2]
+ In[]: q[::2]
+ In[]: q[5:0:-1]
+ In[]: q[::-1]
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{String Methods}
+ \begin{lstlisting}
+ In[]: s.lower()
+ In[]: s.upper()
+ s.<TAB>
+ \end{lstlisting}
+ \begin{itemize}
+ \item \alert{Strings are immutable!}
+ \item A new string is being returned
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Solution - Day of the Week?}
+ \begin{lstlisting}
+ In[]: s.lower()[:3] in week
+ \end{lstlisting}
+ OR
+ \begin{lstlisting}
+ In[]: s[:3].lower() in week
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{join} a list of strings}
+ \begin{itemize}
+ \item Given a list of strings
+ \item We wish to join them into a single string
+ \item Possibly, each string separated by a common token
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: email_list = ["info@fossee.in",
+ "enquiries@fossee.in",
+ "help@fossee.in"]
+ \end{lstlisting}
+ \begin{lstlisting}
+ In[]: '; '.join(email_list)
+ In[]: ', '.join(email_list)
+ \end{lstlisting}
+\end{frame}
+
+\section{Conditionals}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{if-else} block}
+ \begin{lstlisting}
+ In[]: a = 5
+ In[]: if a % 2 == 0:
+ ....: print "Even"
+ ....: else:
+ ....: print "Odd"
+ \end{lstlisting}
+ \begin{itemize}
+ \item A code block -- \texttt{:} and indentation
+ \item Exactly one block gets executed in the \texttt{if-else}
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{if-elif-else}}
+ \begin{lstlisting}
+ In[]: if a > 0:
+ ....: print "positive"
+ ....: elif a < 0:
+ ....: print "negative"
+ ....: else:
+ ....: print "zero"
+ \end{lstlisting}
+ \begin{itemize}
+ \item Only one block gets executed, depending on \texttt{a}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{else} is optional}
+ \begin{lstlisting}
+ In[]: if user == 'admin':
+ ....: admin_Operations()
+ ....: elif user == 'moderator':
+ ....: moderator_operations()
+ ....: elif user == 'client':
+ ....: customer_operations()
+ \end{lstlisting}
+ \begin{itemize}
+ \item Note that there is no \texttt{else} block
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Ternary operator}
+ \begin{itemize}
+ \item \texttt{score\_str} is either \texttt{'AA'} or a string of one
+ of the numbers in the range 0 to 100.
+ \item We wish to convert the string to a number using \texttt{int}
+ \item Convert it to 0, when it is \texttt{'AA'}
+ \item \texttt{if-else} construct or the ternary operator
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: if score_str != 'AA':
+ ....: score = int(score_str)
+ ....: else:
+ ....: score = 0
+ \end{lstlisting}
+ \begin{lstlisting}
+ In[]: ss = score_str
+ In[]: score = int(ss) if ss != 'AA' else 0
+ \end{lstlisting}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{pass}}
+ \begin{itemize}
+ \item \texttt{pass} is a syntactic filler
+ \item When a certain block has no statements, a \texttt{pass} is
+ thrown in
+ \item Mostly, when you want to get back to that part, later.
+ \end{itemize}
+\end{frame}
+
+\section{Loops}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{while}}
+ \begin{itemize}
+ \item Print squares of all odd numbers less than 10 using
+ \texttt{while}
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: i = 1
+
+ In[]: while i<10:
+ ....: print i*i
+ ....: i += 2
+ \end{lstlisting}
+ \begin{itemize}
+ \item The loops runs as long as the condition is \texttt{True}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{for}}
+ \begin{itemize}
+ \item Print squares of all odd numbers less than 10 using
+ \texttt{for}
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: for n in [1, 2, 3]:
+ ....: print n
+ \end{lstlisting}
+ \begin{itemize}
+ \item \texttt{for} iterates over each element of a sequence
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: for n in [1, 3, 5, 7, 9]:
+ ....: print n*n
+
+ In[]: for n in range(1, 10, 2):
+ ....: print n*n
+ \end{lstlisting}
+ \begin{itemize}
+ \item \alert{range([start,] stop[, step])}
+ \item Returns a list; Stop value is not included.
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{break}}
+ \begin{itemize}
+ \item breaks out of the innermost loop.
+ \item Squares of odd numbers below 10 using \texttt{while} \&
+ \texttt{break}
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: i = 1
+
+ In[]: while True:
+ ....: print i*i
+ ....: i += 2
+ ....: if i>10:
+ ....: break
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{continue}}
+ \begin{itemize}
+ \item Skips execution of rest of the loop on current iteration
+ \item Jumps to the end of this iteration
+ \item Squares of all odd numbers below 10, not multiples of 3
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: for n in range(1, 10, 2):
+ ....: if n%3 == 0:
+ ....: continue
+ ....: print n*n
+ \end{lstlisting}
+\end{frame}
+
+
+\section{Lists}
+
+\begin{frame}[fragile]
+ \frametitle{Creating Lists}
+ \begin{lstlisting}
+ In[]: empty = []
+
+ In[]: p = ['spam', 'eggs', 100, 1.234]
+ In[]: q = [[4, 2, 3, 4], 'and', 1, 2, 3, 4]
+ \end{lstlisting}
+ \begin{itemize}
+ \item Lists can be empty, with no elements in them
+ \item Lists can be heterogeneous -- every element of different kind
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Accessing Elements}
+ \begin{lstlisting}
+ In[]: print p[0], p[1], p[3]
+
+ In[]: print p[-1], p[-2], p[-4]
+ In[]: print p[10]
+ \end{lstlisting}
+ \begin{itemize}
+ \item Indexing starts from 0
+ \item Indexes can be negative
+ \item Indexes should be in the valid range
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Accessing Elements \& length}
+ \begin{lstlisting}
+ In[]: print p[0], p[1], p[3]
+
+ In[]: print p[-1], p[-2], p[-4]
+ In[]: print len(p)
+ In[]: print p[10]
+ \end{lstlisting}
+ \begin{itemize}
+ \item Indexing starts from 0
+ \item Indexes can be negative
+ \item Indexes should be within the \texttt{range(0, len(p))}
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{Adding \& Removing Elements}
+ \begin{itemize}
+ \item The append method adds elements to the end of the list
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: p.append('onemore')
+ In[]: p
+ In[]: p.append([1, 6])
+ In[]: p
+ \end{lstlisting}
+ \begin{itemize}
+ \item Elements can be removed based on their index OR
+ \item based on the value of the element
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: del p[1]
+ In[]: p.remove(100)
+ \end{lstlisting}
+ \begin{itemize}
+ \item \alert{When removing by value, first element is removed}
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{Concatenating lists}
+ \begin{lstlisting}
+ In[]: a = [1, 2, 3, 4]
+ In[]: b = [4, 5, 6, 7]
+ In[]: a + b
+ In[]: print a+b, a, b
+ \end{lstlisting}
+ \begin{itemize}
+ \item A new list is returned; None of the original lists change
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: c = a + b
+ In[]: c
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Slicing \& Striding}
+ \begin{lstlisting}
+ In[]: primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
+ In[]: primes[4:8]
+ In[]: primes[:4]
+
+ In[]: num = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
+ In[]: num[1:10:2]
+ In[]: num[:10]
+ In[]: num[10:]
+ In[]: num[::2]
+ In[]: num[::-1]
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Sorting}
+ \begin{lstlisting}
+ In[]: a = [5, 1, 6, 7, 7, 10]
+ In[]: a.sort()
+ In[]: a
+ \end{lstlisting}
+ \begin{itemize}
+ \item \texttt{sort} method sorts the list in-place
+ \item Use \texttt{sorted} if you require a new list
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: a = [5, 1, 6, 7, 7, 10]
+ In[]: sorted(a)
+ In[]: a
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Reversing}
+ \begin{lstlisting}
+ In[]: a = [5, 1, 6, 7, 7, 10]
+ In[]: a.reverse()
+ In[]: a
+ \end{lstlisting}
+ \begin{itemize}
+ \item \texttt{reverse} method reverses the list in-place
+ \item Use \texttt{[::-1]} if you require a new list
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: a = [5, 1, 6, 7, 7, 10]
+ In[]: a[::-1]
+ In[]: a
+ \end{lstlisting}
+\end{frame}
diff --git a/slides/basic-python/tmp.tex b/slides/basic-python/tmp.tex
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/slides/basic-python/tmp.tex
@@ -0,0 +1 @@
+
diff --git a/slides/basic-python/tuples_dicts_sets.tex b/slides/basic-python/tuples_dicts_sets.tex
new file mode 100644
index 0000000..b09fd99
--- /dev/null
+++ b/slides/basic-python/tuples_dicts_sets.tex
@@ -0,0 +1,258 @@
+\section{Tuples}
+
+\begin{frame}[fragile]
+ \frametitle{Tuples -- Initialization}
+ \begin{lstlisting}
+ In[]: t = (1, 2.5, "hello", -4, "world", 1.24, 5)
+ In[]: t
+ \end{lstlisting}
+ \begin{itemize}
+ \item It is not always necessary to use parenthesis
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: a = 1, 2, 3
+ In[]: b = 1,
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Indexing}
+ \begin{lstlisting}
+ In[]: t[3]
+ In[]: t[1:5:2]
+ In[]: t[2] = "Hello"
+ \end{lstlisting}
+ \begin{itemize}
+ \item \alert{Tuples are immutable!}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Swapping values}
+ \begin{lstlisting}
+ In[]: a = 5
+ In[]: b = 7
+
+ In[]: temp = a
+ In[]: a = b
+ In[]: b = temp
+ \end{lstlisting}
+ \begin{itemize}
+ \item Here's the Pythonic way of doing it
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: a, b = b, a
+ \end{lstlisting}
+ \begin{itemize}
+ \item The variables can be of different data-types
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: a = 2.5
+ In[]: b = "hello"
+ In[]: a, b = b, a
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Tuple packing \& unpacking}
+ \begin{lstlisting}
+ In[]: 5,
+
+ In[]: 5, "hello", 2.5
+ \end{lstlisting}
+ \begin{itemize}
+ \item Tuple packing and unpacking, when swapping
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: a, b = b, a
+ \end{lstlisting}
+\end{frame}
+
+\section{Dictionaries}
+
+\begin{frame}[fragile]
+ \frametitle{Creating Dictionaries}
+ \begin{lstlisting}
+ In[]: mt_dict = {}
+
+ In[]: extensions = {'jpg' : 'JPEG Image',
+ 'py' : 'Python script',
+ 'html' : 'Html document',
+ 'pdf' : 'Portable Document Format'}
+
+ In[]: extensions
+ \end{lstlisting}
+ \begin{itemize}
+ \item Key-Value pairs
+ \item \alert{ No ordering of keys! }
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Accessing Elements}
+ \begin{lstlisting}
+ In[]: print extensions['jpg']
+ \end{lstlisting}
+ \begin{itemize}
+ \item Values can be accessed using keys
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: print extensions['zip']
+ \end{lstlisting}
+ \begin{itemize}
+ \item Values of non-existent keys cannot, obviously, be accessed
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Adding \& Removing Elements}
+ \begin{itemize}
+ \item Adding a new key-value pair
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: extensions['cpp'] = 'C++ code'
+ In[]: extensions
+ \end{lstlisting}
+ \begin{itemize}
+ \item Deleting a key-value pair
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: del extension['pdf']
+ In[]: extensions
+ \end{lstlisting}
+ \begin{itemize}
+ \item Assigning to existing key, modifies the value
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: extensions['cpp'] = 'C++ source code'
+ In[]: extensions
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Containership}
+ \begin{lstlisting}
+ In[]: 'py' in extensions
+ In[]: 'odt' in extensions
+ \end{lstlisting}
+ \begin{itemize}
+ \item Allow checking for container-ship of keys; NOT values
+ \item Use the \texttt{in} keyword to check for container-ship
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Lists of Keys and Values}
+ \begin{lstlisting}
+ In[]: extensions.keys()
+ In[]: extensions.values()
+ \end{lstlisting}
+ \begin{itemize}
+ \item Note that the order of the keys and values match
+ \item That can be relied upon and used
+ \end{itemize}
+ \begin{lstlisting}
+ In[]: for each in extensions.keys():
+ ....: print each, "-->", extensions[each]
+ ....:
+ \end{lstlisting}
+\end{frame}
+
+\section{Sets}
+
+\begin{frame}[fragile]
+ \frametitle{Creating Sets}
+ \begin{lstlisting}
+ In[]: a_list = [1, 2, 1, 4, 5, 6, 2]
+ In[]: a = set(a_list)
+ In[]: a
+ \end{lstlisting}
+ \begin{itemize}
+ \item Conceptually identical to the sets in mathematics
+ \item Duplicate elements not allowed
+ \item No ordering of elements exists
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Operations on Sets}
+ \begin{lstlisting}
+ In[]: f10 = set([1, 2, 3, 5, 8])
+ In[]: p10 = set([2, 3, 5, 7])
+ \end{lstlisting}
+ \begin{itemize}
+ \item Mathematical operations performed on sets, can be performed
+ \end{itemize}
+ \begin{itemize}
+ \item Union
+ \begin{lstlisting}
+ In[]: f10 | p10
+ \end{lstlisting}
+ \item Intersection
+ \begin{lstlisting}
+ In[]: f10 & p10
+ \end{lstlisting}
+ \item Difference
+ \begin{lstlisting}
+ In[]: f10 - p10
+ \end{lstlisting}
+ \item Symmetric Difference
+ \begin{lstlisting}
+ In[]: f10 ^ p10
+ \end{lstlisting}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Sub-sets}
+ \begin{itemize}
+ \item Proper Subset
+ \begin{lstlisting}
+ In[]: b = set([1, 2])
+ In[]: b < f10
+ \end{lstlisting}
+ \item Subsets
+ \begin{lstlisting}
+ In[]: f10 <= f10
+ \end{lstlisting}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Elements of sets}
+ \begin{itemize}
+ \item Containership
+ \begin{lstlisting}
+ In[]: 1 in f10
+ In[]: 4 in f10
+ \end{lstlisting}
+ \item Iterating over elements
+ \begin{lstlisting}
+ In[]: for i in f10:
+ ....: print i,
+ ....:
+ \end{lstlisting}
+ \item Subsets
+ \begin{lstlisting}
+ In[]: f10 <= f10
+ \end{lstlisting}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Sets -- Example}
+ \begin{block}{}
+ Given a list of marks, \texttt{[20, 23, 22, 23, 20, 21, 23]} list
+ all the duplicates
+ \end{block}
+ \begin{lstlisting}
+ In[]: marks = [20, 23, 22, 23, 20, 21, 23]
+ In[]: marks_set = set(marks)
+ In[]: for mark in marks_set:
+ ....: marks.remove(mark)
+
+ # left with only duplicates
+ In[]: duplicates = set(marks)
+ \end{lstlisting}
+\end{frame}
+
diff --git a/slides/latex/examples/glimpse-at-scipy.tex b/slides/latex/examples/glimpse-at-scipy.tex
new file mode 100644
index 0000000..8227c34
--- /dev/null
+++ b/slides/latex/examples/glimpse-at-scipy.tex
@@ -0,0 +1,426 @@
+\documentclass{article}
+
+\usepackage{amsmath}
+\usepackage{graphicx}
+\usepackage{color}
+\usepackage{listings}
+\usepackage{url}
+%\definecolor{darkgreen}{rgb}{0,0.5,0}
+
+\lstset{language=Python,
+ basicstyle=\ttfamily\bfseries,
+ commentstyle=\color{red}\itshape,
+ stringstyle=\color{green},
+ showstringspaces=false,
+ keywordstyle=\color{blue}\bfseries}
+
+\title{A Glimpse at Scipy}
+\author{FOSSEE}
+\date{June 2010}
+
+\begin{document}
+\maketitle
+
+\begin{abstract}
+This document shows a glimpse of the features of Scipy that will be
+explored during this course.
+\end{abstract}
+
+\section{Introduction}
+
+SciPy is open-source software for mathematics, science, and
+engineering.
+
+SciPy (pronounced ``Sigh Pie'') is a collection of mathematical
+algorithms and convenience functions built on the Numpy extension for
+Python. It adds significant power to the interactive Python session by
+exposing the user to high-level commands and classes for the
+manipulation and visualization of data. With SciPy, an interactive
+Python session becomes a data-processing and system-prototyping
+environment rivaling sytems such as \emph{Matlab, IDL, Octave, R-Lab,
+ and Scilab}. \cite{scipy}
+
+%% \begin{quote}
+%% In 1998, ... I came across Python and its numerical extension
+%% (Numeric) while I was looking for ways to analyze large data sets
+%% ... using a high-level language. I quickly fell in love with
+%% Python programming which is a remarkable statement to make about a
+%% programming language. If I had not seen others with the same view,
+%% I might have seriously doubted my sanity. -- Travis Oliphant, Creator of Numpy
+%% \end{quote}
+
+\subsection{Sub-packages of Scipy}
+
+SciPy is organized into subpackages covering different scientific
+computing domains. These are summarized in the \underline{table
+ \ref{subpkg}}.
+
+\begin{table}
+ \caption{Sub-packages available in Scipy}
+ \label{subpkg}
+\begin{tabular}{|l|l|}
+\hline
+
+\textbf{Subpackage} & \textbf{Description}\\
+
+\hline
+
+\texttt{cluster} & Clustering algorithms\\
+
+\hline
+
+\texttt{constants} & Physical and mathematical constants\\
+
+\hline
+
+\texttt{fftpack} & Fast Fourier Transform routines\\
+
+\hline
+
+\texttt{integrate} & Integration and ordinary differential equation
+solvers\\
+
+\hline
+
+\texttt{interpolate} & Interpolation and smoothing splines\\
+
+\hline
+
+\texttt{io} & Input and Output\\
+
+\hline
+
+\texttt{linalg} & Linear algebra\\
+
+\hline
+
+\texttt{maxentropy} & Maximum entropy methods\\
+
+\hline
+
+\texttt{ndimage} & N-dimensional image processing\\
+
+\hline
+
+\texttt{odr} & Orthogonal distance regression\\
+
+\hline
+
+\texttt{optimize} & Optimization and root-finding routines\\
+
+\hline
+
+\texttt{signal} & Signal processing\\
+
+\hline
+
+\texttt{sparse} & Sparse matrices and associated routines\\
+
+\hline
+
+\texttt{spatial} & Spatial data structures and algorithms\\
+
+\hline
+
+\texttt{special} & Special functions\\
+
+\hline
+
+\texttt{stats} & Statistical distributions and functions\\
+
+\hline
+
+\texttt{weave} & C/C++ integration\\
+
+\hline
+\end{tabular}
+\end{table}
+
+\subsection{Use of Scipy in this course}
+Following is a partial list of tasks we shall perform using Scipy, in
+this course.
+
+\begin{enumerate}
+ \item Plotting \footnote{using \texttt{pylab} - see Appendix
+ \ref{mpl}}
+ \item Matrix Operations
+ \begin{itemize}
+ \item Inverse
+ \item Determinant
+ \end{itemize}
+ \item Solving Equations
+ \begin{itemize}
+ \item System of Linear equations
+ \item Polynomials
+ \item Non-linear equations
+ \end{itemize}
+ \item Integration
+ \begin{itemize}
+ \item Quadrature
+ \item ODEs
+ \end{itemize}
+\end{enumerate}
+\section{A Glimpse of Scipy functions}
+
+This section gives a brief overview of the tasks that are going to be
+performed using Scipy, in future classes of this course.
+
+\subsection{Matrix Operations}
+
+Let $\mathbf{A}$ be the matrix
+\(
+\begin{bmatrix}
+1 &3 &5\\
+2 &5 &1\\
+2 &3 &8
+\end{bmatrix}
+\)
+
+To input $\mathbf{A}$ matrix into python, we do the following in
+\texttt{ipython}\footnote{\texttt{ipython} must be started with
+ \texttt{-pylab} flag}\\
+
+\begin{lstlisting}
+ In []: A = array([[1,3,5],[2,5,1],[2,3,8]])
+\end{lstlisting}
+
+\subsubsection{Inverse}
+
+The inverse of a matrix $\mathbf{A}$ is the matrix $\mathbf{B}$ such
+that $\mathbf{A}\mathbf{B} = \mathbf{I}$ where $\mathbf{I}$ is the
+identity matrix consisting of ones down the main diagonal. Usually
+$\mathbf{B}$ is denoted $\mathbf{B} = \mathbf{A}^{-1}$ . In SciPy, the
+matrix inverse of matrix $\mathbf{A}$ is obtained using
+
+\lstinline+inv(A)+.
+\begin{lstlisting}
+ In []: inv(A)
+ Out[]:
+ array([[-1.48, 0.36, 0.88],
+ [ 0.56, 0.08, -0.36],
+ [ 0.16, -0.12, 0.04]])
+\end{lstlisting}
+
+\subsubsection{Determinant}
+
+The determinant of a square matrix $\mathbf{A}$ is denoted
+$\left|\mathbf{A}\right|$. Suppose $a_{ij}$ are the elements of the
+matrix $\mathbf{A}$ and let
+$\mathbf{M}_{ij}=\left|\mathbf{A}_{ij}\right|$ be the determinant of
+the matrix left by removing the $i^{th}$ row and $j^{th}$ column from
+$\mathbf{A}$. Then for any row $i$
+
+ \[ \left|\mathbf{A}\right|=\sum_{j}\left(-1\right)^{i+j}a_{ij}\mathbf{M}_{ij} \]
+
+This is a recursive way to define the determinant where the base case
+is defined by accepting that the determinant of a $1\times1$ matrix is
+the only matrix element. In SciPy the determinant can be calculated
+with $det$ . For example, the determinant of
+
+ \[ \mathbf{A}=\begin{bmatrix} 1 & 3 & 5\\ 2 & 5 & 1\\ 2 & 3 & 8\end{bmatrix}\]
+
+is
+
+ \begin{eqnarray*}
+ |\mathbf{A}| & = & 1\begin{vmatrix} 5 & 1\\ 3 & 8\end{vmatrix}
+ -3\begin{vmatrix} 2 & 1\\ 2 & 8\end{vmatrix}
+ +5\begin{vmatrix}2 & 5\\ 2 & 3\end{vmatrix}\\
+ & = & 1(5\cdot8-3\cdot1)-3(2\cdot8-2\cdot1)+5(2\cdot3-2\cdot5)=-25
+ \end{eqnarray*}
+
+In SciPy, this is computed as shown below
+
+\begin{lstlisting}
+ In []: A = array([[1, 3, 5], [2, 5, 1], [2, 3, 8]])
+ In []: det(A)
+ Out[]: -25.0
+\end{lstlisting}
+
+\subsection{Solving Equations}
+
+\subsubsection{Linear Equations}
+
+Solving linear systems of equations is straightforward using the scipy
+command \lstinline+solve+. This command expects an input matrix and a
+right-hand-side vector. The solution vector is then computed. An
+option for entering a symmetrix matrix is offered which can speed up
+the processing when applicable. As an example, suppose it is desired
+to solve the following simultaneous equations:
+
+ \begin{eqnarray} x+3y+5z & = & 10\\ 2x+5y+z & = & 8\\ 2x+3y+8z & = & 3\end{eqnarray}
+
+We could find the solution vector using a matrix inverse:
+
+ \[ \left[\begin{array}{c} x\\ y\\ z\end{array}\right]=\left[\begin{array}{ccc} 1 & 3 & 5\\ 2 & 5 & 1\\ 2 & 3 & 8\end{array}\right]^{-1}\left[\begin{array}{c} 10\\ 8\\ 3\end{array}\right]=\frac{1}{25}\left[\begin{array}{c} -232\\ 129\\ 19\end{array}\right]=\left[\begin{array}{c} -9.28\\ 5.16\\ 0.76\end{array}\right] \]
+
+However, it is better to use the solve command which can be faster and
+more numerically stable. In this case it however gives the same
+answer.
+
+\begin{lstlisting}
+ In []: A = array([[1, 3, 5], [2, 5, 1], [2, 3, 8]])
+ In []: b = array([[10], [8], [3]])
+ In []: dot(inv(A), b)
+ Out[]:
+ array([[-9.28],
+ [ 5.16],
+ [ 0.76]])
+
+ In []: solve(A,b)
+ Out[]:
+ array([[-9.28],
+ [ 5.16],
+ [ 0.76]])
+\end{lstlisting}
+
+\subsubsection{Polynomials}
+
+Solving a polynomial is straightforward in scipy using the
+\lstinline+roots+ command. It expects the coefficients of the
+polynomial in their decreasing order. For example, let's find the
+roots of $x^3 - 2x^2 - \frac{1}{2}x + 1$ are $2$, $\sqrt{2}$ and
+$-\sqrt{2}$. This is easy to see.
+
+\begin{align*}
+x^3 - 2x^2 - \frac{1}{2}x + 1 = 0\\
+x^2(x-2) - \frac{1}{2}(x-2) = 0\\
+(x-2)(x^2 - \frac{1}{2}) = 0\\
+(x-2)(x - \frac{1}{\sqrt{2}})(x + \frac{1}{\sqrt{2}}) = 0
+\end{align*}
+
+We do it in scipy as shown below:
+\begin{lstlisting}
+ In []: coeff = array([1, -2, -2, 4])
+ In []: roots(coeff)
+\end{lstlisting}
+
+\subsubsection{Non-linear Equations}
+
+To find a root of a set of non-linear equations, the command
+\lstinline+fsolve+ is needed. For example, the following example finds
+the roots of the single-variable transcendental equation
+
+ \[ x+2\cos\left(x\right)=0,\]
+
+and the set of non-linear equations
+
+ \begin{align}
+ x_{0}\cos\left(x_{1}\right) &= 4,\\
+ x_{0}x_{1}-x_{1} &= 5
+ \end{align}
+
+The results are $x=-1.0299$ and $x_{0}=6.5041,\, x_{1}=0.9084$ .
+
+\begin{lstlisting}
+In []: def func(x):
+ ...: return x + 2*cos(x)
+
+In []: def func2(x):
+ ...: out = [x[0]*cos(x[1]) - 4]
+ ...: out.append(x[1]*x[0] - x[1] - 5)
+ ...: return out
+
+In []: from scipy.optimize import fsolve
+In []: x0 = fsolve(func, 0.3)
+In []: print x0
+-1.02986652932
+
+In []: x02 = fsolve(func2, [1, 1])
+In []: print x02
+[ 6.50409711 0.90841421]
+\end{lstlisting}
+
+\subsection{Integration}
+% To be done in the lab.
+\subsubsection{Quadrature}
+
+The function \texttt{quad} is provided to integrate a function of one
+variable between two points. The points can be $\pm\infty$ ($\pm$
+\texttt{inf}) to indicate infinite limits. For example, suppose you
+wish to integrate the expression $e^{\sin(x)}$ in the interval
+$[0,2\pi]$, i.e. $\int_0^{2\pi}e^{\sin(x)}dx$, it could be computed
+using
+
+\begin{lstlisting}
+In []: def func(x):
+ ...: return exp(sin(x))
+
+In []: from scipy.integrate import quad
+In []: result = quad(func, 0, 2*pi)
+In []: print result
+(7.9549265210128457, 4.0521874164521979e-10)
+\end{lstlisting}
+
+\subsubsection{ODE}
+
+We wish to solve an (a system of) Ordinary Differential Equation. For
+this purpose, we shall use \lstinline{odeint}. As an illustration, let
+us solve the ODE
+
+\begin{align}
+ \frac{dy}{dt} = ky(L-y)\\
+ L = 25000,\,k = 0.00003,\,y(0) = 250 \nonumber
+\end{align}
+
+We solve it in scipy as shown below.
+
+\begin{lstlisting}
+In []: from scipy.integrate import odeint
+In []: def f(y, t):
+ ...: k, L = 0.00003, 25000
+ ...: return k*y*(L-y)
+ ...:
+In []: t = linspace(0, 12, 60)
+In []: y0 = 250
+In []: y = odeint(f, y0, t)
+\end{lstlisting}
+
+Note: To solve a system of ODEs, we need to change the function to
+return the right hand side of all the equations and the system and the
+pass the required number of initial conditions to the
+\lstinline{odeint} function.
+
+\appendix
+
+\section{Plotting using Pylab}\label{mpl}
+
+The following piece of code, produces the plot in Figure \ref{fig:sin}
+using \texttt{pylab}\cite{pylab} in \texttt{ipython}\footnote{start
+ \texttt{ipython} with \texttt{-pylab} flag}\cite{ipy}
+
+\begin{lstlisting}
+In []: x = linspace(0, 2*pi, 50)
+In []: plot(x, sin(x))
+In []: title('Sine Curve between 0 and $\pi$')
+In []: legend(['sin(x)'])
+\end{lstlisting}
+
+\begin{figure}[h!]
+ \begin{center}
+ \includegraphics[scale=0.4]{sine}
+ \end{center}
+ \caption{Sine curve}
+ \label{fig:sin}
+\end{figure}
+
+
+
+\begin{thebibliography}{9}
+ \bibitem{scipy}
+ Eric Jones and Travis Oliphant and Pearu Peterson and others,
+ \emph{SciPy: Open source scientific tools for Python}, 2001 -- ,
+ \url{http://www.scipy.org/}
+
+ \bibitem{pylab}
+ John D. Hunter, ``Matplotlib: A 2D Graphics Environment,''
+ \emph{Computing in Science and Engineering}, vol. 9, no. 3,
+ pp. 90-95, May/June 2007, doi:10.1109/MCSE.2007.55
+
+ \bibitem{ipy}
+ Fernando Perez, Brian E. Granger, ``IPython: A System for
+ Interactive Scientific Computing,'' \emph{Computing in Science and
+ Engineering}, vol.~9, no.~3, pp.~21-29, May/June 2007,
+ doi:10.1109/MCSE.2007.53.
+
+\end{thebibliography}
+\end{document}
diff --git a/slides/latex/examples/sine.png b/slides/latex/examples/sine.png
new file mode 100644
index 0000000..c059105
--- /dev/null
+++ b/slides/latex/examples/sine.png
Binary files differ
diff --git a/slides/latex/lab-workbook.tex b/slides/latex/lab-workbook.tex
new file mode 100644
index 0000000..95f33ae
--- /dev/null
+++ b/slides/latex/lab-workbook.tex
@@ -0,0 +1,133 @@
+% Created 2010-08-31 Tue 20:40
+\documentclass[11pt]{article}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\providecommand{\alert}[1]{\textbf{#1}}
+
+\title{Lab Workbook --- \LaTeX}
+\author{FOSSEE}
+\date{August, 2010}
+
+\begin{document}
+
+\maketitle
+
+\setcounter{tocdepth}{3}
+\tableofcontents
+\vspace*{1cm}
+
+\section{Lab-1}
+\label{sec-1}
+
+
+\begin{enumerate}
+\item Compile and produce a pdf output of \texttt{example1.tex}.
+\item Modify \texttt{example1.tex} replacing \texttt{LaTeX} with \texttt{\textbackslash{}LaTeX}.
+\item Add a title, author and date to the document.
+\item What happens if \texttt{\textbackslash{}date} is replaced by \texttt{\textbackslash{}date\{IIT, Bombay\}} ?
+\item Debug and compile examples 2, 3, 4, 5
+\item Provide a document (pdf and source) with a TOC, but has been
+ compiled only once. Exercise for Debugging.
+\item What happens when you add the following \LaTeX{} code to the
+ document from the previous question?
+
+\begin{verbatim}
+ \renewcommand{\contentsname}{What is Here?}
+\end{verbatim}
+
+\item Experiment with setting the secnumdepth counter to 1, 0, -1.
+\item Debug and compile example 6.
+\item Experiment with the options of \texttt{\textbackslash{}documentclass}.
+
+\begin{itemize}
+\item 10pt, 11pt, 12pt sets the size of the text of the document.
+\item onecolumn, twocolumn
+\item draft --- makes \LaTeX{} highlight problems in typesetting to
+ be looked at by a human.
+\end{itemize}
+
+\end{enumerate}
+\section{Lab-2}
+\label{sec-2}
+
+
+\begin{enumerate}
+\item \texttt{\textbackslash{}newpage} command adds a page break. Add some page breaks to
+ example 6 and see how the command works.
+\item Try out the commands \texttt{\textbackslash{}pagestyle} and \texttt{\textbackslash{}thispagestyle} with the
+ following parameters and look at the outputs obtained.
+
+\begin{itemize}
+\item \texttt{empty},
+\item \texttt{plain},
+\item \texttt{heading}
+\end{itemize}
+
+\item Add the following description list describing the options to
+ \texttt{\textbackslash{}includegraphics} command to a document and look at the output.
+
+\begin{verbatim}
+\begin{description}
+\item[{\texttt{width=x}, \texttt{height=x}}]
+If only the height or width is specified, the image is scaled, maintaining the aspect ratio.
+
+\item[{\texttt{keepaspectratio}}]
+This parameter can either be set to true or false. When set to true, the image is scaled according to both width and height, without changing the aspect ratio, so that it does not exceed both the width and the height dimensions.
+
+\item[{\texttt{angle=x}}]
+This option can be used to rotate the image by \texttt{x} degrees, counter-clockwise.
+
+\end{description}
+\end{verbatim}
+\item \texttt{\textbackslash{}ldots} is used to get ellipsis in \LaTeX{} documents.
+\item Read the manual of listings package and learn how to include a
+ set of lines from a file into a \LaTeX{} document. Include a few
+ lines from your previous lab exercises of ULT.
+\item To change the line spacing of your document
+ \texttt{\textbackslash{}usepackage\{setspace\}} and then specify the line spacing of
+ your document, using \texttt{\textbackslash{}doublespace}, \texttt{\textbackslash{}onehalfspace}, etc.
+\item Debug and compile examples 9, 10
+\end{enumerate}
+\section{Lab-3}
+\label{sec-3}
+
+
+\begin{enumerate}
+\item Debug and compile example 7.
+\item BibTeX is another way of handling bibliography. Look at
+ bibtex.rst and change draft.tex to use BibTeX.
+\item As you would've already observed, \LaTeX{} compilation produces a
+ lot of other files along with the pdf output.
+
+\begin{itemize}
+\item .log --- gives a log of what happened during last
+ compilation.
+\item .toc --- stores section headers. Edit this file and observe
+ changes in this document to see how the compilation of \LaTeX{}
+ works and why two compilations are required for table of
+ contents to work.
+\item .aux --- used to share information between consecutive
+ compiler runs.
+\end{itemize}
+
+\item Prepare a presentation in beamer with solutions to any 10
+ problems from the Lab workbook.
+\item Debug and compile example 8.
+\item Finish the incomplete parts of the draft to obtain the complete
+ output of the sample document that we started out to prepare.
+\end{enumerate}
+
+\end{document}
diff --git a/slides/latex/slides.tex b/slides/latex/slides.tex
new file mode 100644
index 0000000..ea23cf4
--- /dev/null
+++ b/slides/latex/slides.tex
@@ -0,0 +1,694 @@
+\documentclass{beamer}
+\usepackage[latin1]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{
+ language=TeX,
+ basicstyle=\ttfamily\bfseries,
+ commentstyle=\ttfamily\color{blue},
+ stringstyle=\ttfamily\color{orange},
+ showstringspaces=false,
+ breaklines=true,
+ postbreak = \space\dots
+}
+
+\newcommand{\typ}[1]{\lstinline{#1}}
+
+\mode<presentation>
+{
+ \usetheme{Warsaw}
+ \useoutertheme{infolines}
+ \setbeamercovered{transparent}
+}
+
+
+\title{\LaTeX}
+\author[FOSSEE] {FOSSEE}
+\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT
+ Bombay}
+\date{}
+
+%% Delete this, if you do not want the table of contents to pop up at
+%% the beginning of each subsection:
+\AtBeginSubsection[]
+{
+ \begin{frame}<beamer>
+ \frametitle{Outline}
+ \tableofcontents[currentsection,currentsubsection]
+ \end{frame}
+}
+
+\AtBeginSection[]
+{
+ \begin{frame}<beamer>
+ \frametitle{Outline}
+ \tableofcontents[currentsection,currentsubsection]
+ \end{frame}
+}
+
+\begin{document}
+
+% Document title
+\begin{frame}
+ \maketitle
+\end{frame}
+
+\section{Introduction}
+
+\begin{frame}
+ \frametitle{{\LaTeX} - Introduction}
+ \begin{itemize}
+ \item Typesetting program
+ \begin{itemize}
+ \item What is typesetting?
+ \end{itemize}
+ \item Excellently Typeset Documents - specially Math
+ \item Anything from one page articles to huge books
+ \item Pronounced \emph{Lah-tech} or \emph{Lay-tech}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Why \LaTeX?}
+ \begin{itemize}
+ \item Excellent visual quality!
+ \item Handles the typesetting; Lets you focus on content
+ \item Makes writing math extremely simple
+ \item It is a standard -- widely used in Scientific community
+ \end{itemize}
+ \begin{block}{}
+ \[\tilde{N}_{\mathbf{x}}\times \mathbf{r}(\mathbf{x}) f_{1k}(\mathbf{x},t) - \frac{1}{2} \tilde{N} \tilde{N}:\mathbf{BB}^{T}P(\mathbf{x},t) = -m_{k}f_{1k}(\mathbf{x},t) + 2 \mathop{\mathbf{\aa}}_{j=1}^{K} f_{1j}(\mathbf{x},t)m_{j}P_{k|j} \]
+ \end{block}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Course Outline}
+ \begin{itemize}
+ \item Look at the sample document - \typ{sample.pdf}
+ \begin{itemize}
+ \item Title, Author, Date
+ \item Abstract
+ \item Sections \& Subsections
+ \item Appendix
+ \item References/Bibliography
+ \item Tables
+ \item Figures
+ \item Math
+ \end{itemize}
+ \item The document will be produced by the end of the course.
+ \item First Hour - Basic Structure
+ \item Second Hour - Text, Tables, Figures, References
+ \item Third Hour - Math, Bibliography, Presentations
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\LaTeX~ as a Mark-up}
+ \begin{itemize}
+ \item {\LaTeX} is a document based mark-up
+ \item Mark-up --- a system of annotating text, adding extra
+ information to specify structure and presentation of text
+ \item Document based markup $\rightarrow$ you don't have to worry
+ about each element individually
+ \item Allows you to focus on content, rather than appearance.
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Typesetting a minimal document}
+ \begin{itemize}
+ \item Write the sample code into the file \typ{draft.tex}\\
+ {\tiny See \typ{hg} rev0 of draft}
+ \item To compile, (in terminal) \\
+ \begin{lstlisting}[language=bash]
+ $ pdflatex draft.tex
+ \end{lstlisting} %%$
+ \item This produces the output file \typ{draft.pdf}
+ \item \alert{Note:} \typ{latex} vs. \typ{pdflatex}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Commands \& Environments}
+ \begin{itemize}
+ \item {\LaTeX} is case sensitive
+ \item Commands begin with a \typ{\\}
+ \item Environments have a \typ{\\begin} and \typ{\\end}
+ \item Any content after the \typ{\\end\{document\}} is ignored
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Comments \& Special Characters}
+ \begin{itemize}
+ \item Anything that follows a \typ{\%} symbol till end of the line
+ is a comment
+ \item Special characters (\typ{\~ \# \$ \^ \& \_ \{ \}}) are escaped by a
+ \typ{\\}
+ \item \typ{\\} symbol is inserted using \typ{\\textbackslash}
+ command
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Spacing}
+ \begin{itemize}
+ \item \typ{\\\\} inserts a new line in the output
+ \item An empty line marks the beginning of a new paragraph
+ \item Multiple spaces (or empty lines) are equivalent to a single
+ space (or empty line)
+ \end{itemize}
+\end{frame}
+
+\section{Adding Structure}
+
+\begin{frame}[fragile]
+ \frametitle{\typ{documentclass}}
+ \begin{itemize}
+ \item Used to select the \emph{class} of our document
+ \item Some available classes - \typ{article}, \typ{proc},
+ \typ{report}, \typ{book}, \typ{slides}, \typ{letter}.
+ \item For example:
+ \typ{\\documentclass\[12pt,a4paper,draft\]\{report\}}\\
+ The parameters within \typ{\[ \]} are optional.
+ \begin{itemize}
+ \item \typ{12pt} -- sets the font size of main font and others are
+ relatively, adjusted. \typ{10pt} is the default.
+ \item \typ{a4paper} -- specify paper size
+ \item \typ{draft} -- marks hyphenation and justification problems in
+ typesetting with a square in the margin
+ \end{itemize}
+
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Top Matter}
+ Let's add the title, author's name and the date.
+ \begin{itemize}
+ \item Add title, author and date.
+ \item Compile.
+ \item Nothing changes.
+ \end{itemize}
+ {\tiny See \typ{hg} rev1 of draft.}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Top Matter \ldots}
+ \begin{itemize}
+ \item \lstinline{\maketitle} command inserts the top-matter.
+ \item Add the command to the document \& compile again.
+ \item If no date is specified, today's date is automatically
+ inserted.
+ \end{itemize}
+ \tiny{See \typ{hg} rev2 of draft.}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{Abstract}
+ \begin{itemize}
+ \item \typ{abstract} environment inserts abstract.
+ \item Place it at the location where you want your abstract.
+ \end{itemize}
+ \tiny See rev3 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Sectioning}
+ \begin{itemize}
+ \item \lstinline{\section}, \lstinline{\subsection}
+ \lstinline{\subsubsection}
+ \item Auto numbered sections!
+ \item \typ{*} to prevent numbering of a section
+ \end{itemize}
+ \tiny See rev4 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Sectioning \ldots}
+ \begin{itemize}
+ \item Longer documents, use \lstinline{report} or \lstinline{book}
+ class
+ \item Chapter can be added using \lstinline{\chapter}
+ \end{itemize}
+ \begin{lstlisting}
+ \documentclass{report}
+
+ \chapter{One}
+ \end{lstlisting}
+ \begin{itemize}
+ \item subsections do not get numbering
+ \item Change \lstinline{secnumdepth}
+ \end{itemize}
+ \begin{lstlisting}
+ \setcounter{secnumdepth}{3}
+ \end{lstlisting}
+ \tiny See rev5 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Appendices}
+ \begin{itemize}
+ \item \lstinline{\appendix} command indicates the beginning of
+ Appendices.
+ \item Any content after \lstinline{\appendix}, will be added to the
+ appendix
+ \item Use sectioning commands to add sections
+ \end{itemize}
+ \tiny See rev7 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Table of Contents [TOC]}
+ \begin{itemize}
+ \item Our document is short, but let's learn to add a TOC
+ \item Add \lstinline{\tableofcontents} where you want TOC to
+ appear
+ \item Compile
+ \item Only headings appear. No page numbers
+ \item A \lstinline{.toc} file is generated
+ \item Re-compile
+ \item Any numbered section/block automatically appears
+ \end{itemize}
+ \tiny See rev8 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{TOC \ldots}
+ \begin{itemize}
+ \item Un-numbered sections are added to TOC using
+ \lstinline{\addcontentsline}
+ \item For instance, \lstinline+\addcontentsline{toc}{section}{Intro}+
+ \end{itemize}
+ \tiny See rev9 of \typ{hg}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Bibliography}
+ We shall look at Bibliographies, later in the course.
+\end{frame}
+
+\section{Typesetting Text}
+\begin{frame}[fragile]
+ \frametitle{Quotation Marks}
+ \begin{itemize}
+ \item Use \`~ (accent) for left quote
+ \item Use \'~ (apostrophe) for right quote
+ \item For double quotes, use them twice
+ \end{itemize}
+ \tiny See rev11 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Fonts - Emphasis, Fixed width, \ldots}
+ \begin{itemize}
+ \item \lstinline{\emph} gives emphasized or italic text
+ \item \typ{flushleft} to have text left aligned
+ \item \typ{flushright}, \typ{center}
+ \end{itemize}
+ \tiny See rev12 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Fonts - Emphasis, Fixed width, \ldots}
+ \begin{itemize}
+ \item \lstinline{\texttt} gives fixed width font
+ \item \lstinline{\textbf} bold face font
+ \item \lstinline{--} en dash (--); \lstinline{---} em dash (---).
+ \end{itemize}
+ \tiny See rev13 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Lists}
+ \begin{itemize}
+ \item \lstinline{enumerate} environment is used for numbered lists
+ \item \lstinline{itemize} environment gives un-numbered lists
+ \item Each item in the list is specified using \lstinline{\item}
+ \item Nested lists are also easily handled, as expected
+ \end{itemize}
+ \tiny See rev14 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Footnotes}
+ \begin{itemize}
+ \item \typ{\\footnote} command adds a footnote
+ \end{itemize}
+ \tiny See rev15 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Labels and References}
+ \begin{itemize}
+ \item \lstinline+\label{labelname}+ is used to label an element
+ \item \lstinline+\ref{labelname}+ is used to refer to that element
+ \item Compile twice
+ \end{itemize}
+ \tiny See rev15 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Including code}
+ \begin{itemize}
+ \item Instead of using \lstinline{\texttt} we could use
+ \lstinline{\verbatim}
+ \item \lstinline+listings+ is a powerful package
+ \item \lstinline+\usepackage{listings}+ needs to be added
+ \item Tell {\LaTeX} the language to be used, using \typ{\\lstset}
+ \end{itemize}
+ \tiny See rev16 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Including code}
+ \begin{itemize}
+ \item Use \lstinline+\lstlisting+ for a block of code
+ \item \typ{\\lstinline} for inline code
+ \end{itemize}
+ \tiny See rev16 of \typ{hg}
+\end{frame}
+
+\section{Figures, Tables \& Floats}
+\begin{frame}[fragile]
+ \frametitle{Figures}
+ \begin{itemize}
+ \item The \typ{graphicx} package allows us to insert graphics
+ \item \lstinline+\usepackage{graphicx}+
+ \item To add a graphic, use \lstinline{\includegraphics} command
+ \item Use relative path to the image
+ \end{itemize}
+ \tiny See rev17 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\lstinline{includgraphics}}
+ It takes following optional arguments
+ \begin{itemize}
+ \item \lstinline+scale+ --- specifies the factor by which to scale
+ the image
+ \item \lstinline+height+, \lstinline+width+ --- If only one of them
+ is specified, aspect ratio is maintained
+ \item \lstinline+keepaspectratio+ --- boolean value to keep aspect
+ ratio or not
+ \item \lstinline+angle+ --- specify by what angle the image should
+ be rotated
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Floats}
+ \begin{itemize}
+ \item Graphics (\& Tables) are special because they cannot be broken
+ across pages
+ \item They are ``floated'' to the next page, if they don't fit in
+ the current page
+ \item Enclose graphic within \lstinline+figure+ environment to make
+ it float
+ \item Figure environment takes additional parameter for location of
+ float
+ \end{itemize}
+ \begin{table}
+ \caption{Permission Specifiers}
+
+ \begin{tabular}{|c|c|}
+ Specifier & Permission\\\hline
+ t & Top of page\\
+ b & Bottom of page\\
+ p & Separate page for floats\\
+ h & here (the same place where command appears in source)\\
+ ! & override \LaTeX's internal parameters for good position
+ \end{tabular}
+ \end{table}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Captions and References}
+ \begin{itemize}
+ \item Figure environment allows us add a caption
+ \item To place the image in the center we enclose it in the
+ \lstinline+center+ environment
+ \item We can label images too
+ \item label should be added after the caption command
+ \item Figures are auto numbered
+ \end{itemize}
+ \tiny See rev17 of \typ{hg}
+\end{frame}
+
+\begin{frame}[frame]
+ \frametitle{Tables}
+ \begin{itemize}
+ \item \lstinline+tabular+ is used to typeset a table
+ \item It is enclosed in a \lstinline+table+ environment to make it a
+ float
+ \item \lstinline+table+ environment also gives captions, auto
+ numbering
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{\lstinline+tabular+}
+ \begin{itemize}
+ \item tabular takes formatting of each column as argument
+ \end{itemize}
+
+ \begin{table}
+ \caption{tabular environment}
+
+ \begin{tabular}{|l|l|}
+ \lstinline+l+ & left justified column content\\\hline
+ \lstinline+r+ & right justified column content\\\hline
+ \lstinline+c+ & centered column content\\\hline
+ \lstinline+|+ & produces a vertical line\\
+ \end{tabular}
+ \end{table}
+ \begin{itemize}
+ \item also takes an optional parameter for specifying position of
+ table
+ \item \lstinline+t+ for top, \lstinline+b+ for bottom, \lstinline+c+
+ for center
+ \item each column of table is separated by \&
+ \item each row is separated by newline \lstinline{\\}
+ \item \lstinline+\hline+ give a horizontal line between two rows
+ \end{itemize}
+ \tiny See rev18 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{List of Tables, Figures}
+ \begin{itemize}
+ \item \lstinline+\listoftables+ -- to add a list of tables
+ \item \lstinline+\listoffigures+ -- to add a list of figures
+ \end{itemize}
+\end{frame}
+
+
+\section{Typesetting Math}
+\begin{frame}[fragile]
+ \frametitle{Math in \LaTeX}
+ \begin{itemize}
+ \item Math is enclosed in a pair of \lstinline{$} signs or %%$
+ \lstinline+\( \)+
+ \item Used for typesetting inline Math.
+ \item \lstinline+\usepackage{amsmath}+
+ \item Let's now move on to matrices.
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Matrices}
+ \begin{itemize}
+ \item \lstinline+\bmatrix+ is used to typeset the matrix A
+ \item It works similar to the tabular environment
+ \item \lstinline+&+ for demarcating columns
+ \item \lstinline+\\+ for demarcating rows
+ \item Other matrix environments
+ \begin{table}
+ \center
+ \begin{tabular}{c|c}
+ \lstinline+matrix+ & none\\
+ \lstinline+pmatrix+ & \lstinline+(+\\
+ \lstinline+Bmatrix+ & \lstinline+{+\\
+ \lstinline+vmatrix+ & \lstinline+|+\\
+ \lstinline+Vmatrix+ & \lstinline+||+
+ \end{tabular}
+ \end{table}
+ \end{itemize}
+ \tiny See rev19 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Superscripts \& Subscripts}
+ \begin{itemize}
+ \item \lstinline+^+ for superscripts
+ \item \lstinline+_+ for subscripts
+ \item Enclose multiple characters in \lstinline+{ }+
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Summation \& integration}
+ \begin{itemize}
+ \item \lstinline+\sum+ command gives the summation symbol
+ \item The upper and lower limits are specified using the
+ \lstinline+^+ and \lstinline+_+ symbols.
+ \item Similarly the integral symbol is obtained using
+ \lstinline+\int+ command.
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\lstinline+displayed+ math}
+ \begin{itemize}
+ \item Display equations are the other type of displaying math
+ \item \LaTeX~ or \lstinline+amsmath+ has a number of environments
+ for ``displaying'' equations, with minor differences.
+ \item In general, enclose math in \lstinline+\[+ and \lstinline+\]+
+ to get displayed math.
+ \item \lstinline+\begin{equation*}+ is equivalent to this.
+ \item Use \lstinline+\begin{equation}+ to get numbered
+ equations. %%\end{equation}
+ \end{itemize}
+ \tiny See rev20 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Groups of equations}
+ \begin{itemize}
+ \item The \lstinline+equation+ environment allows typesetting of
+ just 1 equation.
+ \item \lstinline+eqnarray+ allows typesetting of multiple equations
+ \item It is similar to the \lstinline+table+ environment
+ \item The parts of the equation that need to be aligned are
+ indicated using \& symbol.
+ \item Each equation is separated by a \lstinline+\newline+ command
+ \end{itemize}
+ \tiny See rev21, 22 of \typ{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Fractions \& Surds}
+ \begin{itemize}
+ \item Fractions are typeset using \lstinline+\frac+ command
+ \item \lstinline+\frac{numerator}{denominator}+ is typeset as
+ $\frac{numerator}{denominator}$
+ \item Surds are typeset using \lstinline+\sqrt[n]+ command
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Greek characters \& Spacing}
+ \begin{itemize}
+ \item Typesetting Greek characters is simple
+ \item \lstinline+\alpha+, \lstinline+\beta+, \lstinline+\gamma+,
+ \ldots \lstinline+\Alpha+, \lstinline+\Beta+, \lstinline+\Gamma+
+ \ldots
+ \item To get additional spacing in Math environments ---
+\begin{center}
+\begin{tabular}{|l|l|l|}
+\hline
+ Abbrev. & Spelled out & Example \\
+\hline
+ \lstinline+\,+ & \lstinline+\thinspace+ & $A\,B$ \\
+\hline
+ \lstinline+\:+ & \lstinline+\medspace+ & $A\:B$ \\
+\hline
+ \lstinline+\;+ & \lstinline+\thickspace+ & $A\;B$ \\
+\hline
+ & \lstinline+\quad+ & $A \quad B$ \\
+\hline
+ & \lstinline+\qquad+ & $A \qquad B$ \\
+\hline
+ \lstinline+\!+ & \lstinline+\negthinspace+ & $A!B$ \\
+\hline
+ & \lstinline+\negmedspace+ & $A \negmedspace B$ \\
+\hline
+ & \lstinline+\negthickspace+ & $A \negthickspace B$ \\
+\hline
+
+\end{tabular}
+\end{center}
+ \end{itemize}
+\end{frame}
+
+\section{Bibliography}
+\begin{frame}[fragile]
+ \frametitle{Bibliography}
+ \begin{itemize}
+ \item \lstinline+thebibliography+ environment provides a clean and
+ simple way to add a bibliography to \LaTeX documents.
+ \item \lstinline+\begin{thebibliography}+ takes as argument the
+ maximum width of the label that references will have.
+ \item Each item of the Bibliography is similar to an item in a
+ list.
+ \item \lstinline+\bibitem[label]{name}+ followed by the actual
+ reference info.
+ \item label replaces auto enumeration numbers
+ \item \lstinline+\cite{name}+ is used to \lstinline+cite+ the
+ \lstinline+bibitem+
+ \item You will need to compile twice.
+ \end{itemize}
+ \tiny See rev23 of \typ{hg}
+\end{frame}
+
+\section{Presentations - Beamer}
+\begin{frame}[fragile]
+ \frametitle{Beamer}
+ \begin{itemize}
+ \item Use beamer since your report's \LaTeX~ would be re-usable.
+ \item It is recommended to start with one of the beamer templates.
+ \item Let's look at speaker introduction template.
+ \item \lstinline+\documentclass{beamer}+ tells \LaTeX~ to start a
+ beamer presentation.
+ \item A beamer document is very similar to any other \LaTeX~
+ document except that content is divided into slides.
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Beamer \ldots}
+ \begin{itemize}
+ \item \lstinline+\usetheme+ command is used to specify the theme of the
+ presentation.
+ \item \lstinline+\usecolortheme+ command is used to specify the color
+ theme.
+ \item The content of a slide is enclosed within
+ \lstinline+\begin{frame}{Title}{Subtitle}+ and
+ \lstinline+\end{frame}+
+ \item If the slide contains \lstinline+verbatim+
+ \lstinline+lstlisting+ environments, the \lstinline+\begin{frame}+
+ should be passed an additional argument \lstinline+[fragile]+
+ \item Overlays can be achieved using the \lstinline+\pause+
+ command.
+ \item To achieve more with beamer, it is highly recommended that you
+ look at the \texttt{beameruserguide}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{}
+ \begin{center}
+ \Huge{Thank You!}
+ \end{center}
+\end{frame}
+
+
+\end{document}
+
diff --git a/slides/latex/workbook/bibtex.rst b/slides/latex/workbook/bibtex.rst
new file mode 100644
index 0000000..dec3097
--- /dev/null
+++ b/slides/latex/workbook/bibtex.rst
@@ -0,0 +1,35 @@
+BibTeX
+~~~~~~
+
+The previous section explained the process of listing references at the end of a document and embedding cross references. In this section let us explore the BibTeX environment for keeping track of references.
+
+Using BibTeX is a very convenient method to use, when writing multiple documents in a single area or field. BibTeX allows you to create a database of all your references and use them as and when required.
+
+The BibTeX database is stored in a ``.bib`` file. The structure of the file is quite simple and an example is shown below.
+::
+
+ @book{Lamport94,
+ author = "Leslie Lamport",
+ title = "A Document Preparation System: User's Guide and Reference",
+ publisher = "Addison-Wesley Professional",
+ year = "1994",
+ edition = "second",
+ note = "illustrations by Duane Bibby"
+ }
+
+Each bibliography entry starts with a declaration of the type of the reference being mentioned. The reference is in the above example is of the book type. BibTeX has a wide range of reference types, for example, ``article, book, conference, manual, proceedings, unpublished``.
+
+The type of reference is followed by a left curly brace, and immediately followed by the citation key. The citation key, ``Lamport94`` in the example above is used to cite this reference using the command ``\cite{Lamport94}``.
+
+This is followed by the relevant fields and their values, listed one by one. Each entry must be followed by a comma to delimit one field from the other.
+
+To get your LaTeX document to use the bibliography database, you just add the following lines to your LaTeX document.
+::
+
+ \bibliographystyle{plain}
+ \bibliography{LaTeX}
+
+Bibliography styles are files that tell BibTeX how to format the information stored in the ``.bib`` database file. The style file for this example is ``plain.bst``. Note that you do not need to add the ``.bst`` extension to the filename. If you wish to achieve a particular style of listing the bibliography items and citing them, you should use an appropriate style file.
+
+The ``bibliography`` command specifies the file that should be used as the database for references. The file used in this example is ``LaTeX.bib``
+
diff --git a/slides/latex/workbook/example1.tex b/slides/latex/workbook/example1.tex
new file mode 100644
index 0000000..f2d8b7b
--- /dev/null
+++ b/slides/latex/workbook/example1.tex
@@ -0,0 +1,4 @@
+\documentclass{article}
+\begin{document}
+This is my first LaTeX document.
+\end{document}
diff --git a/slides/latex/workbook/example10.tex b/slides/latex/workbook/example10.tex
new file mode 100644
index 0000000..a521468
--- /dev/null
+++ b/slides/latex/workbook/example10.tex
@@ -0,0 +1,19 @@
+\documentclass{article}
+\begin{document}
+This is my simple document with nested lists.
+\begin{enumerate}
+\item First Enumerated Item.
+\item Second Enumerated Item.
+\item Third Enumerated Item.
+ \begin{itemize}
+ \item First Item.
+ \item Second Item.
+ \item Third Item.
+ \begin{itemize}
+ \item First Sub-Item.
+ \item Second Sub-Item.
+ \item Third Sub-Item.
+ \item Fourth Sub-Item.
+ \end{itemize}
+\end{enumerate}
+\end{document}
diff --git a/slides/latex/workbook/example2.tex b/slides/latex/workbook/example2.tex
new file mode 100644
index 0000000..1f760cd
--- /dev/null
+++ b/slides/latex/workbook/example2.tex
@@ -0,0 +1,26 @@
+\documentclass{article}
+\title{Python}
+\author{Wikipedia}
+\maketitle
+\begin{document}
+Python is a general-purpose high-level programming language whose
+design philosophy emphasizes code readability. Python aims to combine
+"remarkable power with very clear syntax", and its standard library is
+large and comprehensive. Its use of indentation for block delimiters
+is unusual among popular programming languages.
+
+Python supports multiple programming paradigms, primarily but not
+limited to object oriented, imperative and, to a lesser extent,
+functional programming styles. It features a fully dynamic type system
+and automatic memory management, similar to that of Scheme, Ruby,
+Perl, and Tcl. Like other dynamic languages, Python is often used as a
+scripting language, but is also used in a wide range of non-scripting
+contexts.
+
+The reference implementation of Python (CPython) is free and open
+source software and has a community-based development model, as do all
+or nearly all of its alternative implementations. CPython is managed
+by the non-profit Python Software Foundation.
+
+This content is from Wikipedia's Python page.
+\end{document}
diff --git a/slides/latex/workbook/example3.tex b/slides/latex/workbook/example3.tex
new file mode 100644
index 0000000..70cfdaa
--- /dev/null
+++ b/slides/latex/workbook/example3.tex
@@ -0,0 +1,23 @@
+\documentclass{article}
+\begin{document}
+Python is a general-purpose high-level programming language whose
+design philosophy emphasizes code readability.[3] Python aims to
+combine "remarkable power with very clear syntax",[4] and its standard
+library is large and comprehensive. Its use of indentation for block
+delimiters is unusual among popular programming languages.
+
+Python supports multiple programming paradigms, primarily but not
+limited to object oriented, imperative and, to a lesser extent,
+functional programming styles. It features a fully dynamic type system
+and automatic memory management, similar to that of Scheme, Ruby,
+Perl, and Tcl. Like other dynamic languages, Python is often used as a
+scripting language, but is also used in a wide range of non-scripting
+contexts.
+
+The reference implementation of Python (CPython) is free and open
+source software and has a community-based development model, as do all
+or nearly all of its alternative implementations. CPython is managed
+by the non-profit Python Software Foundation.
+
+This content is from Wikipedia's Python page.
+\end{docment}
diff --git a/slides/latex/workbook/example4.tex b/slides/latex/workbook/example4.tex
new file mode 100644
index 0000000..317d3f5
--- /dev/null
+++ b/slides/latex/workbook/example4.tex
@@ -0,0 +1,11 @@
+\documentclass{article}
+\title{A Glimpse at Scipy}
+\author{FOSSEE}
+date{2010}
+\begin{document}
+\maketitle
+SciPy is open-source software for mathematics, science, and
+engineering.
+\end{document}
+
+
diff --git a/slides/latex/workbook/example5.tex b/slides/latex/workbook/example5.tex
new file mode 100644
index 0000000..7600797
--- /dev/null
+++ b/slides/latex/workbook/example5.tex
@@ -0,0 +1,24 @@
+\documentclass{article}
+\begin{abstract}
+ This content is from Wikipedia page on Python.
+\end{abstract}
+\begin{document}
+Python is a general-purpose high-level programming language whose
+design philosophy emphasizes code readability. Python aims to combine
+``remarkable power with very clear syntax'', and its standard library is
+large and comprehensive. Its use of indentation for block delimiters
+is unusual among popular programming languages.
+
+Python supports multiple programming paradigms, primarily but not
+limited to object oriented, imperative and, to a lesser extent,
+functional programming styles. It features a fully dynamic type system
+and automatic memory management, similar to that of Scheme, Ruby,
+Perl, and Tcl. Like other dynamic languages, Python is often used as a
+scripting language, but is also used in a wide range of non-scripting
+contexts.
+
+The reference implementation of Python (CPython) is free and open
+source software and has a community-based development model, as do all
+or nearly all of its alternative implementations. CPython is managed
+by the non-profit Python Software Foundation.
+\end{document}
diff --git a/slides/latex/workbook/example6.tex b/slides/latex/workbook/example6.tex
new file mode 100644
index 0000000..828a188
--- /dev/null
+++ b/slides/latex/workbook/example6.tex
@@ -0,0 +1,31 @@
+%hello.tex - First LaTeX document
+\documentclass[12pt]{article}
+
+\title{LaTeX}
+\author{The FOSSEE Team}
+\date{August 2010}
+
+\begin{document}
+\maketitle
+\tableofcontents
+
+\begin{abstract}
+This is a sample document to be used in the STTP course for a quick introduction to \LaTeX
+\end{abstract}
+
+\section{Introduction}
+LaTeX is a typesetting program used to produce excellently typeset documents.
+
+\section{Structural Elements}
+Let us now look at giving a better structure to our document.
+
+\subsection{documentclass}
+The \verb+documentclass+ variable tells \LaTeX, the type of document we wish to prepare.
+
+\subsection{Sections, Chapters and Parts}
+We shall first look at how to divide the document into Sections, Chapters and Parts.
+
+\subsubsection{Appendices}
+I can't tell you how to add an appendix, in the main document.
+
+\end{document}
diff --git a/slides/latex/workbook/example7.tex b/slides/latex/workbook/example7.tex
new file mode 100644
index 0000000..6b7d14d
--- /dev/null
+++ b/slides/latex/workbook/example7.tex
@@ -0,0 +1,13 @@
+\documentclass{article}
+\begin{document}
+This is my first LaTeX document.
+\begin{equation}
+ a^2 + b^2 = c^2
+\end{equation}
+\[
+\begin{pmatrix}
+\alpha& \beta^{*}\\
+\gamma^{*}& \delta
+\end{pmatrix}
+\]
+\end{document}
diff --git a/slides/latex/workbook/example8.tex b/slides/latex/workbook/example8.tex
new file mode 100644
index 0000000..87267ae
--- /dev/null
+++ b/slides/latex/workbook/example8.tex
@@ -0,0 +1,176 @@
+\documentclass[english]{beamer}
+
+% generated by Docutils <http://docutils.sourceforge.net/>
+\usepackage{fixltx2e} % LaTeX patches, \textsubscript
+\usepackage{cmap} % fix search and cut-and-paste in PDF
+\usepackage{babel}
+\usepackage[T1]{fontenc}
+\usepackage[latin1]{inputenc}
+\usepackage{listings}
+\usepackage{amsmath}
+\lstset{
+ language=TeX,
+ basicstyle=\small\ttfamily,
+ commentstyle=\ttfamily\color{blue},
+ stringstyle=\ttfamily\color{orange},
+ showstringspaces=false,
+ breaklines=true,
+ postbreak = \space\dots
+}
+
+\usepackage{ifthen}
+\usepackage{longtable}
+\usepackage{array}
+\setlength{\extrarowheight}{2pt}
+\newlength{\DUtablewidth} % internal use in tables
+
+\mode<presentation>
+{
+ \usetheme{Warsaw}
+ \useoutertheme{infolines}
+ \setbeamercovered{transparent}
+}
+
+
+\title{\LaTeX}
+\author[FOSSEE] {FOSSEE}
+\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT
+ Bombay}
+\date{}
+
+%% Delete this, if you do not want the table of contents to pop up at
+%% the beginning of each subsection:
+\AtBeginSubsection[]
+{
+ \begin{frame}<beamer>
+ \frametitle{Outline}
+ \tableofcontents[currentsection,currentsubsection]
+ \end{frame}
+}
+
+\AtBeginSection[]
+{
+ \begin{frame}<beamer>
+ \frametitle{Outline}
+ \tableofcontents[currentsection,currentsubsection]
+ \end{frame}
+}
+
+\begin{document}
+
+% Document title
+\begin{frame}
+ \maketitle
+\end{frame}
+
+\section{Introduction}
+
+\begin{frame}
+ \frametitle{\LaTeX~- Introduction}
+ \begin{itemize}
+ \item Typesetting program
+ \item Excellently Typeset Documents - specially Math
+ \item Anything from one page articles to books.
+ \item Based on \TeX
+ \item Pronounced ``Lah-tech'' or ``Lay-tech''
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{This Course}
+ \begin{itemize}
+ \item Look at Sample document - \texttt{sample.pdf}
+ \item The document will be produced by the end of the course.
+ \item First Hour - Basic Structure
+ \item Second Hour - Text, Tables, Figures, References
+ \item Third Hour - Math, Bibliography, Presentations
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}
+ \frametitle{A Look at the Sample Document}
+ \begin{itemize}
+ \item Title, Author, Date
+ \item Abstract
+ \item Sections
+ \item Subsections
+ \item Appendix
+ \item References/Bibliography
+ \item Tables
+ \item Figures
+ \item Math
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{The source \& compilation}
+ Write the following code into the file \texttt{draft.tex}.
+ \begin{lstlisting}
+ \documentclass{article}
+ \begin{document}
+ SciPy is open-source software for mathematics,
+ science, and engineering.
+ \end{document}
+ \end{lstlisting}
+ To compile the document, do the following in your terminal:
+ \begin{lstlisting}[language=bash]
+ $ pdflatex draft.tex
+ \end{lstlisting}
+ This produces the output file \texttt{draft.pdf} %%$
+ Note: \texttt{latex} command is often used to get \texttt{dvi}
+ output. Throughout this course, we shall use \texttt{pdflatex} to
+ compile our documents to \texttt{pdf} output.
+\end{frame}
+
+\section{Structure of the Document}
+
+\begin{frame}[fragile]
+ \frametitle{\lstinline+documentclass+}
+ \begin{itemize}
+ \item \LaTeX~typesets based on \lstinline{documentclass}
+ \item Defines structure and formatting of a document
+ \item \LaTeX~is a document based mark-up
+ \item Mark-up --- a system of annotating text, adding extra
+ information to specify structure and presentation of text
+ \item Document based markup $\rightarrow$ you don't have to worry
+ about each element individually
+ \item Allows you to focus on content, rather than appearance.
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Environments and Commands}
+ \lstinline{document} is an environment, present in every document.
+ \begin{itemize}
+ \item Environments
+ \begin{itemize}
+ \item \lstinline{\begin} and \lstinline{\end} define the beginning
+ and end of an environment
+ \item All the content of the document is placed inside the
+ \lstinline{document} environment
+ \end{itemize}
+ \item Commands
+ \begin{itemize}
+ \item All commands begin with \textbackslash
+ \item They are case-sensitive
+ \item Only alpha caracthers; other characters terminate commands
+ \end{itemize}
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{Top Matter}
+ Let's add the Title, Author's name and the date to the document.
+ \begin{itemize}
+ \item Add title, author and date. Compile. Nothing changes.
+ \end{itemize}
+ \begin{lstlisting}
+ \title{A Glimpse at Scipy}
+ \author{FOSSEE}
+ \date{June 2010}
+ \end{lstlisting}
+ \tiny{See \texttt{hg} rev1 of draft.}
+\end{frame}
+\end{document}
diff --git a/slides/latex/workbook/example9.tex b/slides/latex/workbook/example9.tex
new file mode 100644
index 0000000..e066c1e
--- /dev/null
+++ b/slides/latex/workbook/example9.tex
@@ -0,0 +1,11 @@
+\documentclass{article}
+\begin{document}
+This document contains a figure.
+The figure \ref{fig:lion} is a drawing by Duane Bibby.
+\begin{figure}
+\centering
+\label{fig:lion}
+\caption[CTAN Lion]{CTAN lion drawing by Duane Bibby; thanks to www.ctan.org}
+\includegraphics[scale=0.8, angle=30]{lion_orig.png}
+\end{figure}
+\end{document}
diff --git a/slides/latex/workbook/lion_orig.png b/slides/latex/workbook/lion_orig.png
new file mode 100644
index 0000000..0026477
--- /dev/null
+++ b/slides/latex/workbook/lion_orig.png
Binary files differ
diff --git a/slides/tdd/tdd.tex b/slides/tdd/tdd.tex
new file mode 100644
index 0000000..1d64be2
--- /dev/null
+++ b/slides/tdd/tdd.tex
@@ -0,0 +1,514 @@
+\documentclass[12pt,presentation]{beamer}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{green},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
+
+\title{SEES: Test Driven Development}
+\author{FOSSEE}
+
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+
+\AtBeginSection[]
+{
+ \begin{frame}<beamer>
+ \frametitle{Outline}
+ \tableofcontents[currentsection]
+ \end{frame}
+}
+
+\begin{document}
+
+\maketitle
+
+\begin{frame}
+\frametitle{Outline}
+\setcounter{tocdepth}{3}
+\tableofcontents
+\end{frame}
+
+\section{Introduction}
+
+\begin{frame}
+ \frametitle{Objectives}
+ At the end of this section, you will be able to:
+ \begin{itemize}
+ \item Write your code using the TDD paradigm.
+ \item Use doctests to test your Python code.
+ \item Use unittests to test your Python code.
+ \item Use the nose module to test your code.
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{What is TDD?}
+ The basic steps of TDD are roughly as follows --
+ \begin{enumerate}
+ \item Decide upon the feature to implement and the methodology of
+ testing it.
+ \item Write the tests for the feature decided upon.
+ \item Just write enough code, so that the test can be run, but it fails.
+ \item Improve the code, to just pass the test and at the same time
+ passing all previous tests.
+ \item Run the tests to see, that all of them run successfully.
+ \item Refactor the code you've just written -- optimize the algorithm,
+ remove duplication, add documentation, etc.
+ \item Run the tests again, to see that all the tests still pass.
+ \item Go back to 1.
+ \end{enumerate}
+\end{frame}
+
+\section{First Test}
+
+\begin{frame}[fragile]
+ \frametitle{First Test -- GCD}
+ \begin{itemize}
+ \item simple program -- GCD of two numbers
+ \item What are our code units?
+ \begin{itemize}
+ \item Only one function \texttt{gcd}
+ \item Takes two numbers as arguments
+ \item Returns one number, which is their GCD
+ \end{itemize}
+\begin{lstlisting}
+c = gcd(44, 23)
+\end{lstlisting}
+ \item c will contain the GCD of the two numbers.
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Test Cases}
+ \begin{itemize}
+ \item Important to have test cases and expected outputs even before
+ writing the first test!
+ \item $a=48$, $b=48$, $GCD=48$
+ \item $a=44$, $b=19$, $GCD=1$
+ \item Tests are just a series of assertions
+ \item True or False, depending on expected and actual behavior
+ \end{itemize}
+
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Test Cases -- Code}
+\begin{lstlisting}
+tc1 = gcd(48, 64)
+if tc1 != 16:
+ print "Failed for a=48, b=64. Expected 16. \
+ Obtained %d instead." % tc1
+ exit(1)
+
+tc2 = gcd(44, 19)
+if tc2 != 1:
+ print "Failed for a=44, b=19. Expected 1. \
+ Obtained %d instead." % tc2
+ exit(1)
+
+print "All tests passed!"
+\end{lstlisting}
+\begin{itemize}
+\item The function \texttt{gcd} doesn't even exist!
+\end{itemize}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{Stubs}
+ \begin{itemize}
+ \item First write a very minimal definition of \texttt{gcd}
+ \begin{lstlisting}
+def gcd(a, b):
+ pass
+ \end{lstlisting}
+ \item Written just, so that the tests can run
+ \item Obviously, the tests are going to fail
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{gcd.py}}
+\begin{lstlisting}
+def gcd(a, b):
+ pass
+
+if __name__ == '__main__':
+ tc1 = gcd(48, 64)
+ if tc1 != 16:
+ print "Failed for a=48 and b=64. \
+ Expected 16. Obtained %d instead." % tc1
+ exit(1)
+ tc2 = gcd(44, 19)
+ if tc2 != 1:
+ print "Failed for a=44 and b=19. \
+ Expected 1. Obtained %d instead." % tc2
+ exit(1)
+ print "All tests passed!"
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{First run}
+\begin{lstlisting}
+$ python gcd.py
+Traceback (most recent call last):
+ File "gcd.py", line 7, in <module>
+ print "Failed for a=48 and b=64. Expected 16.
+ Obtained %d instead." % tc1
+TypeError: %d format:
+a number is required, not NoneType
+\end{lstlisting} %$
+
+ \begin{itemize}
+ \item We have our code unit stub, and a failing test.
+ \item The next step is to write code, so that the test just passes.
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Euclidean Algorithm}
+ \begin{itemize}
+ \item Modify the \texttt{gcd} stub function
+ \item Then, run the script to see if the tests pass.
+ \end{itemize}
+\begin{lstlisting}
+def gcd(a, b):
+ if a == 0:
+ return b
+ while b != 0:
+ if a > b:
+ a = a - b
+ else:
+ b = b - a
+ return a
+\end{lstlisting}
+\begin{lstlisting}
+$ python gcd.py
+All tests passed!
+\end{lstlisting} %$
+ \begin{itemize}
+ \item \alert{Success!}
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{Euclidean Algorithm -- Modulo}
+ \begin{itemize}
+ \item Repeated subtraction can be replaced by a modulo
+ \item modulo of \texttt{a\%b} is always less than b
+ \item when \texttt{a < b}, \texttt{a\%b} equals \texttt{a}
+ \item Combine these two observations, and modify the code
+\begin{lstlisting}
+def gcd(a, b):
+ while b != 0:
+ a, b = b, a % b
+ return a
+\end{lstlisting}
+ \item Check that the tests pass again
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Euclidean Algorithm -- Recursive}
+ \begin{itemize}
+ \item Final improvement -- make \texttt{gcd} recursive
+ \item More readable and easier to understand
+\begin{lstlisting}
+def gcd(a, b):
+ if b == 0:
+ return a
+ return gcd(b, a%b)
+\end{lstlisting}
+ \item Check that the tests pass again
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Document \texttt{gcd}}
+ \begin{itemize}
+ \item Undocumented function is as good as unusable
+ \item Let's add a docstring \& We have our first test!
+ \end{itemize}
+\begin{lstlisting}
+def gcd(a, b):
+ """Returns the Greatest Common Divisor of the
+ two integers passed as arguments.
+
+ Args:
+ a: an integer
+ b: another integer
+
+ Returns: Greatest Common Divisor of a and b
+ """
+ if b == 0:
+ return a
+ return gcd(b, a%b)
+\end{lstlisting}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{Persistent Test Cases}
+ \begin{itemize}
+ \item Tests should be pre-determined and written, before the code
+ \item Test Data is repeatedly used; Hence, saved in persistent
+ format
+ \item Let's save data for GCD tests in a text file.
+ \item The file shall have multiple lines of test data
+ \item Each line corresponds to a single test case
+ \item Each line consists of three comma separated values --
+ \begin{itemize}
+ \item First two coloumns are the integers for which the GCD has to be
+ computed
+ \item Third coloumn is the expected GCD to the preceding two
+ numbers.
+ \end{itemize}
+ \item Let us call our data file \texttt{gcd\_testcases.dat}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Modify \texttt{gcd.py}}
+\begin{lstlisting}
+if __name__ == '__main__':
+ for line in open('gcd_testcases.dat'):
+ values = line.split(', ')
+ a = int(values[0])
+ b = int(values[1])
+ g = int(values[2])
+
+ tc = gcd(a, b)
+ if tc != g:
+ print "Failed for a=%d and b=%d.\
+ Expected %d. Obtained %d instead."\
+ % (a, b, g, tc)
+ exit(1)
+
+ print "All tests passed!"
+\end{lstlisting}
+\end{frame}
+
+\section{Python Testing Frameworks}
+
+\begin{frame}[fragile]
+ \frametitle{Python Testing Frameworks}
+ \begin{itemize}
+ \item Testing frameworks essentially, ease the job of the user
+ \item Python provides two frameworks for testing code
+ \begin{itemize}
+ \item \texttt{unittest} framework
+ \item \texttt{doctest} module
+ \end{itemize}
+ \end{itemize}
+\end{frame}
+
+\subsection{\texttt{doctest} module}
+
+\begin{frame}[fragile]
+ \frametitle{doctest}
+ \begin{itemize}
+ \item Documentation always accompanies a well written piece of code
+ \item Use \texttt{docstring} to document functions or modules
+ \item Along with description and usage, examples can be added
+ \item Interactive interpreter session inputs and outputs are
+ copy-pasted
+ \item \texttt{doctest} module picks up all such interactive examples
+ \item Executes them and determines if the code runs, as documented
+ \end{itemize}
+ Let's use the \texttt{doctest} module for our \texttt{gcd} function
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{doctest for \texttt{gcd.py}}
+\begin{tiny}
+\begin{lstlisting}
+def gcd(a, b):
+ """Returns the Greatest Common Divisor of the two integers
+ passed as arguments.
+
+ Args:
+ a: an integer
+ b: another integer
+
+ Returns: Greatest Common Divisor of a and b
+
+ >>> gcd(48, 64)
+ 16
+ >>> gcd(44, 19)
+ 1
+ """
+ if b == 0:
+ return a
+ return gcd(b, a%b)
+\end{lstlisting}
+\end{tiny}
+\begin{itemize}
+\item We have added examples to the \texttt{docstring}
+\item Now we need to tell the \texttt{doctest} module to execute
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{doctest for \texttt{gcd.py} \ldots}
+\begin{lstlisting}
+if __name__ == "__main__":
+ import doctest
+ doctest.testmod()
+\end{lstlisting}
+\begin{itemize}
+\item \texttt{testmod} automatically picks all sample sessions
+\item Executes them and compares output with documented output
+\item It doesn't give any output, when all the results match
+\item Complains only when one or more tests fail.
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{doctest} -- Execution}
+ \begin{itemize}
+ \item Run the doctests by running \texttt{gcd.py}
+\begin{lstlisting}
+$ python gcd.py
+\end{lstlisting} %$
+ \item All the tests pass, and doctest gives no output
+ \item For a more detailed report we can run with -v argument
+\begin{lstlisting}
+$ python gcd.py -v
+\end{lstlisting} %$
+ \item If the output contains a blank line, use \texttt{<BLANKLINE>}
+ \item To see a failing test case, replace \texttt{return a} with \texttt{b}
+ \end{itemize}
+\end{frame}
+
+\subsection{\texttt{unittest} framework}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{unittest}}
+ \begin{itemize}
+ \item It won't be long, before we complain about the power of
+ \texttt{doctest}
+ \item \texttt{unittest} framework can efficiently automate tests
+ \item Easily initialize code and data for executing the specific
+ tests
+ \item Cleanly shut them down once the tests are executed
+ \item Easily aggregate tests into collections and improved reporting
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{unittest}}
+ \begin{itemize}
+ \item It won't be long, before we complain about the power of
+ \texttt{doctest}
+ \item \texttt{unittest} framework can efficiently automate tests
+ \item Easily initialize code and data for executing the specific
+ tests
+ \item Cleanly shut them down once the tests are executed
+ \item Easily aggregate tests into collections and improved reporting
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{unittest}ing \texttt{gcd.py}}
+ \begin{itemize}
+ \item Subclass the \texttt{TestCase} class in \texttt{unittest}
+ \item Place all the test code as methods of this class
+ \item Use the test cases present in \texttt{gcd\_testcases.dat}
+ \item Place the code in \texttt{test\_gcd.py}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile,allowframebreaks]
+ \frametitle{\texttt{test\_gcd.py}}
+\small
+\begin{lstlisting}
+import gcd
+import unittest
+
+class TestGcdFunction(unittest.TestCase):
+
+ def setUp(self):
+ self.test_file = open('gcd_testcases.dat')
+ self.test_cases = []
+ for line in self.test_file:
+ values = line.split(', ')
+ a = int(values[0])
+ b = int(values[1])
+ g = int(values[2])
+
+ self.test_cases.append([a, b, g])
+
+ def test_gcd(self):
+ for case in self.test_cases:
+ a = case[0]
+ b = case[1]
+ g = case[2]
+ self.assertEqual(gcd.gcd(a, b), g)
+
+ def tearDown(self):
+ self.test_file.close()
+ del self.test_cases
+
+if __name__ == '__main__':
+ unittest.main()
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{test\_gcd.py}}
+ \begin{itemize}
+ \item \texttt{setUp} -- we read all the test data and store it in a
+ list
+ \item \texttt{tearDown} -- delete the data to free up memory and
+ close open file
+ \item \texttt{test\_gcd} -- actual test code
+ \item \texttt{assertEqual} -- compare actual result with expected one
+ \item Write documentation for above code.
+ \end{itemize}
+\end{frame}
+
+\section{\texttt{nose}}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{nose} tests}
+ \begin{itemize}
+ \item It is not easy to organize, choose and run tests scattered
+ across multiple files.
+ \item \texttt{nose} module aggregate these tests automatically
+ \item Can aggregate \texttt{unittests} and \texttt{doctests}
+ \item Allows us to pick and choose which tests to run
+ \item Helps output the test-results and aggregate them in various
+ formats
+ \item Not part of the Python distribution itself
+\begin{lstlisting}
+$ easy_install nose
+\end{lstlisting} %$
+ \item Run the following command in the top level directory
+\begin{lstlisting}
+$ nosetests
+\end{lstlisting} %$
+ \end{itemize}
+\end{frame}
+
+\end{document}
diff --git a/slides/ult/ult.tex b/slides/ult/ult.tex
new file mode 100644
index 0000000..a94dc14
--- /dev/null
+++ b/slides/ult/ult.tex
@@ -0,0 +1,1721 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Using Linux Tools
+%
+% Author: FOSSEE
+% Copyright (c) 2009, FOSSEE, IIT Bombay
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\documentclass[12pt,compress]{beamer}
+
+\mode<presentation>
+{
+ \usetheme{Warsaw}
+ \useoutertheme{infolines}
+ \setbeamercovered{transparent}
+}
+
+\usepackage[english]{babel}
+\usepackage[latin1]{inputenc}
+%\usepackage{times}
+\usepackage[T1]{fontenc}
+
+% Taken from Fernando's slides.
+\usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler}
+\usepackage[scaled=.95]{helvet}
+
+\definecolor{darkgreen}{rgb}{0,0.5,0}
+
+\usepackage{listings}
+\lstset{language=sh,
+ basicstyle=\ttfamily\bfseries,
+ commentstyle=\color{red}\itshape,
+ stringstyle=\color{darkgreen},
+ showstringspaces=false,
+ keywordstyle=\color{blue}\bfseries}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Macros
+\setbeamercolor{emphbar}{bg=blue!20, fg=black}
+\newcommand{\emphbar}[1]
+{\begin{beamercolorbox}[rounded=true]{emphbar}
+ {#1}
+ \end{beamercolorbox}
+}
+\newcounter{time}
+\setcounter{time}{0}
+\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
+
+\newcommand{\typ}[1]{\lstinline{#1}}
+
+\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Title page
+\title[Using Linux Tools]{SEES: Using Linux Tools}
+
+\author[FOSSEE] {FOSSEE}
+
+\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\date[]{}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
+%\logo{\pgfuseimage{iitmlogo}}
+
+
+%% Delete this, if you do not want the table of contents to pop up at
+%% the beginning of each subsection:
+
+\AtBeginSection[]
+{
+ \begin{frame}<beamer>
+ \frametitle{Outline}
+ \tableofcontents[currentsection]
+ \end{frame}
+}
+
+% If you wish to uncover everything in a step-wise fashion, uncomment
+% the following command:
+%\beamerdefaultoverlayspecification{<+->}
+
+%%\includeonlyframes{current,current1,current2,current3,current4,current5,current6}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% DOCUMENT STARTS
+\begin{document}
+
+\begin{frame}
+ \maketitle
+\end{frame}
+
+% CREATING TOC
+\begin{frame}
+ \frametitle{Outline}
+ \tableofcontents
+ % You might wish to add the option [pausesections]
+\end{frame}
+
+
+\section{Introduction}
+\begin{frame}[fragile]
+ \begin{block}{What is the Linux OS?}
+ \begin{itemize}
+ \item Free Open Source Operating System
+ \begin{description}
+ \item[Free]
+ Free as in Free Speech, not Free Beer
+ \item[Open-Source]
+ Permit modifications and redistribution of source code
+ \end{description}
+ \item Unix-inspired
+ \item Linux Kernel + Application software
+ \item Runs on a variety of hardware
+ \item Also called GNU/Linux
+ \end{itemize}
+ \end{block}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Why Linux?}
+ \begin{itemize}
+ \item Free as in Free Beer
+ \item Secure \& versatile
+ \end{itemize}
+
+ \begin{block}{Why Linux for Scientific Computing?}
+ \begin{itemize}
+ \item Free as in Free Speech
+ \item Can run for \emph{ever}
+ \item Libraries
+ \item Parallel Computing
+ \end{itemize}
+ \end{block}
+\end{frame}
+
+\section{Getting Started}
+\begin{frame}[fragile]
+ \frametitle{Logging in}
+ \begin{itemize}
+ \item GNU/Linux does have a GUI
+ \item Command Line for this module
+ \item Hit \texttt{Ctrl + Alt + F1}
+ \item Login
+ \item \texttt{logout} command logs you out
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Where am I?}
+ \begin{itemize}
+ \item Logged in. Where are we?
+ \item \texttt{pwd} command gives the present working directory
+ \end{itemize}
+ \begin{lstlisting}
+ $ pwd
+ /home/user
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{What is in there?}
+ \begin{itemize}
+ \item \texttt{ls} command lists contents of \texttt{pwd}
+ \end{itemize}
+ \begin{lstlisting}
+ $ ls
+ jeeves.rst psmith.html blandings.html Music
+ \end{lstlisting} %$
+ \begin{itemize}
+ \item Can also pass directory as argument
+ \end{itemize}
+ \begin{lstlisting}
+ $ ls Music
+ one.mp3 two.mp3 three.mp3
+ \end{lstlisting} %$
+ \begin{itemize}
+ \item \alert{the Unix world is case sensitive}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{New folders}
+ \begin{itemize}
+ \item \texttt{mkdir} creates new directories
+ \end{itemize}
+ \begin{lstlisting}
+ $ mkdir sees
+ $ ls
+ \end{lstlisting}
+ \begin{itemize}
+ \item Special characters need to be escaped OR quoted
+ \end{itemize}
+ \begin{lstlisting}
+ $ mkdir software\ engineering
+ $ mkdir "software engg"
+ \end{lstlisting}
+ \begin{itemize}
+ \item Generally, use hyphens or underscores instead of spaces in names
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Moving around}
+ \begin{itemize}
+ \item \texttt{cd} command changes the \texttt{pwd}
+ \end{itemize}
+ \begin{lstlisting}
+ $ cd sees
+ $ pwd
+ /home/user/sees/
+ \end{lstlisting}
+ \begin{itemize}
+ \item Alternately written as \texttt{cd ./sees}
+ \item Specifying path relative to \texttt{pwd}
+ \item \texttt{..} takes one level up the directory structure
+ \end{itemize}
+ \begin{lstlisting}
+ $ cd ..
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item We could use absolute path instead of relative
+ \end{itemize}
+ \begin{lstlisting}
+ $ cd /home/user/sees/
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{New files}
+ \begin{itemize}
+ \item \texttt{touch} command creates a blank file
+ \end{itemize}
+ \begin{lstlisting}
+ $ pwd
+ /home/user
+ $ cd sees
+ $ touch first
+ $ ls
+ first
+ \end{lstlisting} % $
+\end{frame}
+
+\section{Getting Help}
+\begin{frame}[fragile]
+ \frametitle{What does a command do?}
+
+ \begin{itemize}
+ \item \texttt{whatis} gives a quick description of a command
+ \end{itemize}
+ \begin{lstlisting}
+ $ whatis touch
+ touch (1) - change file timestamps
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{man} command gives more detailed description
+ \end{itemize}
+ \begin{lstlisting}
+ $ man touch
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item Shows all tasks that the command can perform
+ \item Hit \texttt{q} to quit the \texttt{man} page
+ \item For more, see the \texttt{man} page of \texttt{man}
+ \end{itemize}
+ \begin{lstlisting}
+ $ man man
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Using additional options}
+
+ \begin{itemize}
+ \item \texttt{-h} or \texttt{--help} give summary of command usage
+ \end{itemize}
+ \begin{lstlisting}
+ $ ls --help
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item List out all files within a directory, recursively
+ \end{itemize}
+ \begin{lstlisting}
+ $ ls -R
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item Create a new directory along with parents, if required
+ \end{itemize}
+ \begin{lstlisting}
+ $ pwd
+ /home/user/
+ $ ls sees/
+ $ mkdir -p sees/linux-tools/scripts
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Searching for a command}
+
+ \begin{itemize}
+ \item \texttt{apropos} searches commands based on their descriptions
+ \end{itemize}
+
+ \begin{lstlisting}
+ $ apropos remove
+ \end{lstlisting} % $
+
+ \begin{itemize}
+ \item Returns a list of all commands that contain the search term
+ \item In this case, we are interested in \texttt{rm}, \texttt{rmdir}
+ \end{itemize}
+\end{frame}
+
+\section{Basic File Handling}
+\begin{frame}[fragile]
+ \frametitle{Removing files}
+
+ \begin{itemize}
+ \item \texttt{rm} is used to delete files
+ \end{itemize}
+
+ \begin{lstlisting}
+ $ rm foo
+ \end{lstlisting} % $
+
+ \begin{itemize}
+ \item \alert{\texttt{rm} works only for files; not directories}
+ \end{itemize}
+
+ \begin{itemize}
+ \item Additional arguments required to remove a directory
+ \item \texttt{-r} stands for recursive.
+ \item Removes directory and all of it's content
+ \end{itemize}
+
+ \begin{lstlisting}
+ $ rm -r bar
+ \end{lstlisting} % $
+
+ \begin{itemize}
+ \item \alert{\texttt{rmdir} can also be used; Explore}
+ \end{itemize}
+
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{Copying Files}
+
+ \begin{itemize}
+ \item \texttt{cp} copies files from one location to another
+ \end{itemize}
+
+ \begin{lstlisting}
+ $ cp linux-tools/scripts/foo linux-tools/
+ \end{lstlisting} % $
+
+ \begin{itemize}
+ \item New file-name can be used at target location
+ \item \texttt{foo} copied to new location with the name \texttt{bar}
+ \end{itemize}
+
+ \begin{lstlisting}
+ $ cp linux-tools/scripts/foo linux-tools/bar
+ \end{lstlisting} % $
+
+ \begin{itemize}
+ \item \texttt{cp} overwrites files, unless explicitly asked not to
+ \item To prevent this, use the \texttt{-i} flag
+ \end{itemize}
+
+ \begin{lstlisting}
+ $ cp -i linux-tools/scripts/foo linux-tools/bar
+ cp: overwrite `bar'?
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Copying Directories}
+
+ \begin{itemize}
+ \item \texttt{-r} is required to copy a directory and all it's
+ content
+ \item Copying directories is similar to copying files
+ \end{itemize}
+
+ \begin{lstlisting}
+ $ cd /home/user
+ $ cp -ir sees course
+ \end{lstlisting}
+\end{frame}
+
+
+
+\begin{frame}[fragile]
+ \frametitle{Moving Files}
+ \begin{itemize}
+ \item \texttt{cp} and \texttt{rm} would be one way
+ \item \texttt{mv} command does the job
+ \item Also takes \texttt{-i} option to prompt before overwriting
+ \end{itemize}
+
+ \begin{lstlisting}
+ $ cd /home/user
+ # Assume we have course directory already created
+ $ mv -i sees/ course/
+ \end{lstlisting}
+ \begin{itemize}
+ \item No prompt! Why?
+ \end{itemize}
+ \begin{lstlisting}
+ $ ls course
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{sees} became a sub-directory of \texttt{course}
+ \item \texttt{mv} command doesn't over-write directories
+ \item \texttt{-i} option is useful when moving files around
+ \item \texttt{mv} to rename --- move to same location with new name
+ \end{itemize}
+\end{frame}
+
+\section{Linux File Hierarchy, Permissions \& Ownership}
+\begin{frame}
+ \frametitle{Linux File Hierarchy}
+ \begin{itemize}
+ \item \texttt{/} is called the root directory
+ \item It is the topmost level of the hierarchy
+ \item For details \texttt{man hier}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Permissions and Access control}
+
+ \begin{itemize}
+ \item In a multi-user environment, access control is vital
+ \item Look at the output of \texttt{ls -l}
+ \end{itemize}
+
+ \begin{lstlisting}
+ drwxr-xr-x 5 root users 4096 Jan 21 20:07 home
+ \end{lstlisting} % $
+
+ \begin{itemize}
+ \item The first column shows the permission information
+ \item First character specifies type of the file
+ \item Files have \texttt{-}; Directories have \texttt{d}
+ \item 3 sets of 3 characters --- for user, group and others
+ \item \texttt{r}, \texttt{w}, \texttt{x} --- for read, write, execute
+ \item Either the corresponding character or \texttt{-} is present
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Changing the permissions}
+ \begin{itemize}
+ \item Permissions can be changed by owner of the file
+ \item \texttt{chmod} command is used
+ \item \texttt{-R} option to recursively change for all content of a
+ directory
+ \end{itemize}
+ \begin{itemize}
+ \item Change permissions of \texttt{foo.sh} from
+ \texttt{-rw-r-{}-r-{}-} to \texttt{-rwxr-xr-{}-}
+ \end{itemize}
+ \begin{lstlisting}
+ $ ls -l foo.sh
+ $ chmod ug+x foo.sh
+ $ ls -l foo.sh
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Symbolic modes}
+ \begin{small}
+ \begin{center}
+ \begin{tabular}{lll}
+ Reference & Class & Description \\
+ \hline
+ u & user & the owner of the file \\
+ g & group & users who are members of the file's group \\
+ o & others & users who are not hte owner of the file or members of the group \\
+ a & all & all three of the above; is the same as \emph{ugo} \\
+ \end{tabular}
+ \end{center}
+
+ \begin{center}
+ \begin{tabular}{ll}
+ Operator & Description \\
+ \hline
+ + & adds the specified modes to the specified classes \\
+ - & removes the specified modes from the specified classes \\
+ = & the modes specified are to be made the exact modes for the specified classes \\
+ \end{tabular}
+ \end{center}
+
+ \begin{center}
+ \begin{tabular}{lll}
+ Mode & Name & Description \\
+ \hline
+ r & read & read a file or list a directory's contents \\
+ w & write & write to a file or directory \\
+ x & execute & execute a file or recurse a directory tree \\
+ \end{tabular}
+ \end{center}
+ \end{small}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Changing Ownership of Files}
+ \begin{itemize}
+ \item \texttt{chown} changes the owner and group
+ \item By default, the user who creates file is the owner
+ \item The default group is set as the group of the file
+ \end{itemize}
+ \begin{lstlisting}
+ $ chown alice:users wonderland.txt
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item Did it work? \alert{Not every user can change ownership}
+ \item Super-user or \texttt{root} user alone is empowered
+ \end{itemize}
+\end{frame}
+
+\section{Looking at files}
+\begin{frame}[fragile]
+ \frametitle{\texttt{cat}}
+ \begin{itemize}
+ \item Displays the contents of files
+ \end{itemize}
+ \begin{lstlisting}
+ $ cat foo.txt
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item Concatenates the text of multiple files
+ \end{itemize}
+ \begin{lstlisting}
+ $ cat foo.txt bar.txt
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item Not-convenient to view long files
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{less}}
+ \begin{itemize}
+ \item View contents of a file one screen at a time
+ \end{itemize}
+
+ \begin{lstlisting}
+ $ less wonderland.txt
+ \end{lstlisting} % $
+
+ \begin{itemize}
+ \item q: Quit
+ \item Arrows/Page Up/Page Down/Home/End: Navigation
+ \item ng: Jump to line number n
+ \item /pattern: Search. Regular expressions can be used
+ \item h: Help
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{wc}}
+ \begin{itemize}
+ \item Statistical information about the file
+ \item the number of lines in the file
+ \item the number of words
+ \item the number of characters
+ \end{itemize}
+
+ \begin{lstlisting}
+ $ wc wonderland.txt
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{head} \& \texttt{tail}}
+ \begin{itemize}
+ \item let you see parts of files, instead of the whole file
+ \item \texttt{head} -- start of a file; \texttt{tail} -- end of a
+ file
+ \item show 10 lines by default
+ \end{itemize}
+ \begin{lstlisting}
+ $ head wonderland.txt
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{-n} option to change the number of lines
+ \end{itemize}
+ \begin{lstlisting}
+ $ head -n 1 wonderland.txt
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{tail} is commonly used to monitor files
+ \item \texttt{-f} option to monitor the file
+ \item \texttt{Ctrl-C} to interrupt
+ \end{itemize}
+ \begin{lstlisting}
+ $ tail -f /var/log/dmesg
+ \end{lstlisting} % $
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{cut}}
+ \begin{itemize}
+ \item Allows you to view only certain sections of lines
+ \item Let's take \texttt{/etc/passwd} as our example
+ \end{itemize}
+ \begin{lstlisting}
+ root:x:0:0:root:/root:/bin/bash
+ \end{lstlisting}
+ \begin{itemize}
+ \item View only user names of all the users (first column)
+ \end{itemize}
+ \begin{lstlisting}
+ $ cut -d : -f 1 /etc/passwd
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{-d} specifies delimiter between fields (default TAB)
+ \item \texttt{-f} specifies the field number
+ \item Multiple fields by separating field numbers with comma
+ \end{itemize}
+ \begin{lstlisting}
+ $ cut -d : -f 1,5,7 /etc/passwd
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{cut}}
+ \begin{itemize}
+ \item Allows choosing on the basis of characters or bytes
+ \item Example below gets first 4 characters of \texttt{/etc/passwd}
+ \end{itemize}
+ \begin{lstlisting}
+ $ cut -c 1-4 /etc/passwd
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item One of the limits of the range can be dropped
+ \item Sensible defaults are assumed in such cases
+ \end{itemize}
+ \begin{lstlisting}
+ $ cut -c -4 /etc/passwd
+ $ cut -c 10- /etc/passwd
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{paste}}
+ \begin{itemize}
+ \item Joins corresponding lines from two different files
+ \begin{center}
+ \begin{tabular}{l|l}
+ \verb~students.txt~ & \verb~marks.txt~ \\
+ Hussain & 89 92 85 \\
+ Dilbert & 98 47 67 \\
+ Anne & 67 82 76 \\
+ Raul & 78 97 60 \\
+ Sven & 67 68 69 \\
+ \end{tabular}
+ \end{center}
+ \end{itemize}
+ \begin{lstlisting}
+ $ paste students.txt marks.txt
+ $ paste -s students.txt marks.txt
+ \end{lstlisting}
+ \begin{itemize}
+ \item \texttt{-s} prints content, one below the other
+ \item If first column of marks file had roll numbers? How do we get
+ a combined file with the same output as above (i.e. without roll
+ numbers). We need to use \texttt{cut} \& \texttt{paste} together.
+ But how?
+ \end{itemize}
+\end{frame}
+
+\section{The Command Shell}
+
+\begin{frame}[fragile]
+ \frametitle{Redirection and Piping}
+ \begin{lstlisting}
+ $ cut -d " " -f 2- marks1.txt \
+ > /tmp/m_tmp.txt
+ $ paste -d " " students.txt m_tmp.txt
+ \end{lstlisting} % $
+
+ or
+
+ \begin{lstlisting}
+ $ cut -d " " -f 2- marks1.txt \
+ | paste -d " " students.txt -
+ \end{lstlisting} % $
+
+ \begin{itemize}
+ \item The first solution used Redirection
+ \item The second solution uses Piping
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Redirection}
+
+ \begin{itemize}
+ \item The standard output (stdout) stream goes to the display
+ \item Not always, what we need
+ \item First solution, redirects output to a file
+ \item \texttt{>} states that output is redirected; It is
+ followed by location to redirect
+ \end{itemize}
+ \begin{lstlisting}
+ $ command > file1
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{>} creates a new file at specified location
+ \item \texttt{>>} appends to a file at specified location
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Redirection \ldots}
+ \begin{itemize}
+ \item Similarly, the standard input (stdin) can be redirected
+ \end{itemize}
+ \begin{lstlisting}
+ $ command < file1
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item input and the output redirection could be combined
+ \end{itemize}
+ \begin{lstlisting}
+ $ command < infile > outfile
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item Standard error (stderr) is the third standard stream
+ \item All error messages come through this stream
+ \item \texttt{stderr} can also be redirected
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Redirection \ldots}
+ \begin{itemize}
+ \item Following example shows \texttt{stderr} redirection
+ \item Error is printed out in the first case
+ \item Error message is redirected, in the second case
+ \end{itemize}
+ \begin{lstlisting}
+ $ cut -d " " -c 2- marks1.txt \
+ > /tmp/m_tmp.txt
+
+ $ cut -d " " -f 2- marks1.txt 1> \
+ /tmp/m_tmp.txt 2> /tmp/m_err.txt
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{1>} redirects \texttt{stdout}; \texttt{2>} redirects
+ \texttt{stderr}
+ \end{itemize}
+ \begin{lstlisting}
+ $ paste -d " " students.txt m_tmp.txt
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Piping}
+ \begin{lstlisting}
+ $ cut -d " " -f 2- marks1.txt \
+ | paste -d " " students.txt -
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{-} instead of FILE asks \texttt{paste} to read from
+ \texttt{stdin}
+ \item \texttt{cut} command is a normal command
+ \item the \texttt{|} seems to be joining the two commands
+ \item Redirects output of first command to \texttt{stdin}, which
+ becomes input to the second command
+ \item This is called piping; \texttt{|} is called a pipe
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Piping}
+ \begin{itemize}
+ \item Roughly same as -- 2 redirects and a temporary file
+ \end{itemize}
+ \begin{lstlisting}
+ $ command1 > tempfile
+ $ command2 < tempfile
+ $ rm tempfile
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item Any number of commands can be piped together
+ \end{itemize}
+\end{frame}
+
+\subsection{Features of the Shell}
+
+\begin{frame}[fragile]
+ \frametitle{Tab-completion}
+ \begin{itemize}
+ \item Hit tab to complete an incompletely typed word
+ \item Tab twice to list all possibilities when ambiguous completion
+ \item Bash provides tab completion for the following.
+ \begin{enumerate}
+ \item File Names
+ \item Directory Names
+ \item Executable Names
+ \item User Names (when they are prefixed with a \~{})
+ \item Host Names (when they are prefixed with a @)
+ \item Variable Names (when they are prefixed with a \$)
+ \end{enumerate}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{History}
+ \begin{itemize}
+ \item Bash saves history of commands typed
+ \item Up and down arrow keys allow to navigate history
+ \item \texttt{Ctrl-r} searches for commands used
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Shell Meta Characters}
+ \begin{itemize}
+ \item ``meta characters'' are special command directives
+ \item File-names shouldn't have meta-characters
+ \item \verb+/<>!$%^&*|{}[]"'`~;+
+ \end{itemize}
+ \begin{lstlisting}
+ $ ls file.*
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item Lists \texttt{file.ext} files, where \texttt{ext} can be
+ anything
+ \end{itemize}
+ \begin{lstlisting}
+ $ ls file.?
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item Lists \texttt{file.ext} files, where \texttt{ext} is only one
+ character
+ \end{itemize}
+\end{frame}
+
+\section{More text processing}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{sort}}
+ \begin{itemize}
+ \item \texttt{sort} can be used to get sorted content
+ \item Command below prints student marks, sorted by name
+ \end{itemize}
+ \begin{lstlisting}
+ $ cut -d " " -f 2- marks1.txt \
+ | paste -d " " students.txt - \
+ | sort
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item The default is sort based on the whole line
+ \item \texttt{sort} can sort based on a particular field
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{sort} \ldots}
+ \begin{itemize}
+ \item The command below sorts based on marks in first subject
+ \end{itemize}
+ \begin{lstlisting}
+ $ cut -d " " -f 2- marks1.txt \
+ | paste -d " " students.txt -\
+ | sort -t " " -k 2 -rn
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{-t} specifies the delimiter between fields
+ \item \texttt{-k} specifies the field to use for sorting
+ \item \texttt{-n} to choose numerical sorting
+ \item \texttt{-r} for sorting in the reverse order
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{grep}}
+ \begin{itemize}
+ \item \texttt{grep} is a command line text search utility
+ \item Command below searches \& shows the marks of Anne alone
+ \end{itemize}
+ \begin{lstlisting}
+ $ cut -d " " -f 2- marks1.txt \
+ | paste -d " " students.txt -
+ | grep Anne
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{grep} is case-sensitive by default
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{grep} \ldots}
+ \begin{itemize}
+ \item \texttt{-i} for case-insensitive searches
+ \end{itemize}
+ \begin{lstlisting}
+ $ cut -d " " -f 2- marks1.txt \
+ | paste -d " " students.txt -
+ | grep -i Anne
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{-v} inverts the search
+ \item To see everyone's marks except Anne's
+ \end{itemize}
+ \begin{lstlisting}
+ $ cut -d " " -f 2- marks1.txt \
+ | paste -d " " students.txt -
+ | grep -iv Anne
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{tr}}
+ \begin{itemize}
+ \item \texttt{tr} translates or deletes characters
+ \item Reads from \texttt{stdin} and outputs to \texttt{stdout}
+ \item Given, two sets of characters, replaces one with other
+ \item The following, replaces all lower-case with upper-case
+ \end{itemize}
+ \begin{lstlisting}
+ $ cat students.txt | tr a-z A-Z
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{-s} compresses sequences of identical adjacent
+ characters in the output to a single one
+ \item Following command removes empty newlines
+ \end{itemize}
+ \begin{lstlisting}
+ $ tr -s '\n' '\n'
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{tr} \ldots}
+ \begin{itemize}
+ \item \texttt{-d} deletes all specified characters
+ \item Only a single character set argument is required
+ \item The following command removes carriage return characters
+ (converting file in DOS/Windows format to the Unix format)
+ \end{itemize}
+ \begin{lstlisting}
+ $ cat foo.txt | tr -d '\r' > bar.txt
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{-c} complements the first set of characters
+ \item The following command removes all non-alphanumeric characters
+ \end{itemize}
+ \begin{lstlisting}
+ $ tr -cd '[:alnum:]'
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{uniq}}
+ \begin{itemize}
+ \item \texttt{uniq} command removes duplicates from \alert{sorted} input
+ \end{itemize}
+ \begin{lstlisting}
+ $ sort items.txt | uniq
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{uniq -u} gives lines which do not have any duplicates
+ \item \texttt{uniq -d} outputs only those lines which have duplicates
+ \item \texttt{-c} displays the number of times each line occurs
+ \end{itemize}
+ \begin{lstlisting}
+ $ sort items.txt | uniq -u
+ $ sort items.txt | uniq -dc
+ \end{lstlisting} % $
+\end{frame}
+
+\section{Simple Shell Scripts}
+
+\begin{frame}[fragile]
+ \frametitle{Shell scripts}
+ \begin{itemize}
+ \item Simply a sequence of shell commands in a file
+ \item To save results of students in \texttt{results.txt} in
+ \texttt{marks} dir
+ \end{itemize}
+ \begin{lstlisting}
+ #!/bin/bash
+ mkdir ~/marks
+ cut -d " " -f 2- marks1.txt \
+ | paste -d " " students.txt - \
+ | sort > ~/marks/results.txt
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Shell scripts \ldots}
+ \begin{itemize}
+ \item Save the script as \texttt{results.sh}
+ \item Make file executable and then run
+ \end{itemize}
+ \begin{lstlisting}
+ $ chmod u+x results.sh
+ $ ./results.sh
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item What does the first line in the script do?
+ \item Specify the interpreter or shell which should be used to
+ execute the script; in this case \texttt{bash}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Variables \& Comments}
+ \begin{lstlisting}
+ $ name=FOSSEE
+ $ count=`wc -l wonderland.txt`
+ $ echo $count # Shows the value of count
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item It is possible to create variables in shell scripts
+ \item Variables can be assigned with the output of commands
+ \item \alert{NOTE:} There is no space around the \texttt{=} sign
+ \item All text following the \texttt{\#} is considered a comment
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{echo}}
+ \begin{itemize}
+ \item \texttt{echo} command prints out messages
+ \end{itemize}
+ \begin{lstlisting}
+ #!/bin/bash
+ mkdir ~/marks
+ cut -d " " -f 2- marks1.txt \
+ | paste -d " " students.txt - \
+ | sort > ~/marks/results.txt
+ echo "Results generated."
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Command line arguments}
+ \begin{itemize}
+ \item Shell scripts can be given command line arguments
+ \item Following code allows to specify the results file
+ \end{itemize}
+ \begin{lstlisting}
+ #!/bin/bash
+ mkdir ~/marks
+ cut -d " " -f 2- marks1.txt \
+ | paste -d " " students.txt - \
+ | sort > ~/marks/$1
+ echo "Results generated."
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{\$1} corresponds to first command line argument
+ \item \texttt{\$n} corresponds to $n{th}$ command line argument
+ \item It can be run as shown below
+ \end{itemize}
+ \begin{lstlisting}
+ $ ./results.sh grades.txt
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{PATH}}
+ \begin{itemize}
+ \item The shell searches in a set of locations, for the command
+ \item Locations are saved in ``environment'' variable called PATH
+ \item \texttt{echo} can show the value of variables
+ \end{itemize}
+ \begin{lstlisting}
+ $ echo $PATH
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item Put \texttt{results.sh} in one of these locations
+ \item It can then be run without \texttt{./}
+ \end{itemize}
+\end{frame}
+
+\section{Control structures and Operators}
+\begin{frame}[fragile]
+ \frametitle{Control Structures}
+ \begin{itemize}
+ \item \texttt{if-else}
+ \item \texttt{for} loops
+ \item \texttt{while} loops
+ \end{itemize}
+ \begin{itemize}
+ \item \texttt{test} command to test for conditions
+ \item A whole range of tests that can be performed
+ \begin{itemize}
+ \item \texttt{STRING1 = STRING2} -- string equality
+ \item \texttt{INTEGER1 -eq INTEGER2} -- integer equality
+ \item \texttt{-e FILE} -- existence of FILE
+ \end{itemize}
+ \item \texttt{man} page of \texttt{test} gives list of various tests
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{if}}
+ \begin{itemize}
+ \item Print message if directory exists in \texttt{pwd}
+ \end{itemize}
+ \begin{lstlisting}
+ #!/bin/bash
+ if test -d $1
+ then
+ echo "Yes, the directory" \
+ $1 "is present"
+ fi
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{if}-\texttt{else}}
+ \begin{itemize}
+ \item Checks whether argument is negative or not
+ \end{itemize}
+ \begin{lstlisting}
+ #!/bin/bash
+ if test $1 -lt 0
+ then
+ echo "number is negative"
+ else
+ echo "number is non-negative"
+ fi
+ \end{lstlisting} % $
+ \begin{lstlisting}
+ $ ./sign.sh -11
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{[ ]} - alias for \texttt{test}}
+ \begin{itemize}
+ \item Square brackets (\texttt{[]}) can be used instead of
+ \texttt{test}
+ \item
+ \end{itemize}
+ \begin{lstlisting}
+ #!/bin/bash
+ if [ $1 -lt 0 ]
+ then
+ echo "number is negative"
+ else
+ echo "number is non-negative"
+ fi
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \alert{spacing is important, when using the square brackets}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{if}-\texttt{else}}
+ \begin{itemize}
+ \item An example script to greet the user, based on the time
+ \end{itemize}
+ \begin{lstlisting}
+ #!/bin/sh
+ # Script to greet the user
+ # according to time of day
+ hour=`date | cut -c12-13`
+ now=`date +"%A, %d of %B, %Y (%r)"`
+ if [ $hour -lt 12 ]
+ then
+ mess="Good Morning \
+ $LOGNAME, Have a nice day!"
+ fi
+ \end{lstlisting} %$
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{if}-\texttt{else} \ldots}
+ \begin{lstlisting}
+ if [ $hour -gt 12 -a $hour -le 16 ]
+ then
+ mess="Good Afternoon $LOGNAME"
+ fi
+ if [ $hour -gt 16 -a $hour -le 18 ]
+ then
+ mess="Good Evening $LOGNAME"
+ fi
+ echo -e "$mess\nIt is $now"
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item \texttt{\$LOGNAME} has login name (env. variable)
+ \item backquotes store commands outputs into variables
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{for}}
+ \begin{block}{Problem}
+ Given a set of \texttt{.mp3} files, that have names beginning with
+ numbers followed by their names --- \texttt{08 - Society.mp3} ---
+ rename the files to have just the names. Also replace any spaces
+ in the name with hyphens.
+ \end{block}
+ \begin{itemize}
+ \item Loop over the list of files
+ \item Process the names, to get new names
+ \item Rename the files
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{for}}
+ \begin{itemize}
+ \item A simple example of the \texttt{for} loop
+ \end{itemize}
+ \begin{lstlisting}
+ for animal in rat cat dog man
+ do
+ echo $animal
+ done
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item List of animals, each animal's name separated by a space
+ \item Loop over the list; \texttt{animal} is a dummy variable
+ \item Echo value of \texttt{animal} --- each name in list
+ \end{itemize}
+ \begin{lstlisting}
+ for i in {10..20}
+ do
+ echo $i
+ done
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{for}}
+ \begin{itemize}
+ \item Let's start with echoing the names of the files
+ \end{itemize}
+ \begin{lstlisting}
+ for i in `ls *.mp3`
+ do
+ echo "$i"
+ done
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item Spaces in names cause trouble!
+ \item The following works better
+ \end{itemize}
+ \begin{lstlisting}
+ for i in *.mp3
+ do
+ echo "$i"
+ done
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{tr} \& \texttt{cut}}
+ \begin{itemize}
+ \item Replace all spaces with hyphens using \texttt{tr -s}
+ \item Use cut \& keep only the text after the first hyphen
+ \end{itemize}
+ \begin{lstlisting}
+ for i in *.mp3
+ do
+ echo $i|tr -s " " "-"|cut -d - -f 2-
+ done
+ \end{lstlisting} % $
+ Now \texttt{mv}, instead of just echoing
+ \begin{lstlisting}
+ for i in *.mp3
+ do
+ mv $i `echo $i|tr -s " " "-"\
+ |cut -d - -f 2-`
+ done
+ \end{lstlisting} % $
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{while}}
+ \begin{itemize}
+ \item Continuously execute a block of commands until condition
+ becomes false
+ \end{itemize}
+
+ \begin{itemize}
+ \item program that takes user input and prints it back, until the
+ input is \texttt{quit}
+ \end{itemize}
+
+ \begin{lstlisting}
+ while [ "$variable" != "quit" ]
+ do
+ read variable
+ echo "Input - $variable"
+ done
+ exit 0
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Environment Variables}
+ \begin{itemize}
+ \item Pass information from shell to programs running in it
+ \item Behavior of programs can change based on values of variables
+ \item Environment variables vs. Shell variables
+ \item Shell variables -- only current instance of the shell
+ \item Environment variables -- valid for the whole session
+ \item Convention -- environment variables are UPPER CASE
+ \end{itemize}
+ \begin{lstlisting}
+ $ echo $OSTYPE
+ linux-gnu
+ $ echo $HOME
+ /home/user
+ \end{lstlisting} % $
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Environment Variables \ldots}
+ \begin{itemize}
+ \item The following commands show values of all the environment
+ variables
+ \end{itemize}
+ \begin{lstlisting}
+ $ printenv | less
+ $ env
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item Use \texttt{export} to change Environment variables
+ \item The new value is available to all programs started from the shell
+ \end{itemize}
+ \begin{lstlisting}
+ $ export PATH=$PATH:$HOME/bin
+ \end{lstlisting} % $
+\end{frame}
+
+\section{Miscellaneous Tools}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{find}}
+ \begin{itemize}
+ \item Find files in a directory hierarchy
+ \item Offers a very complex feature set
+ \item Look at the \texttt{man} page!
+ \end{itemize}
+ \begin{itemize}
+ \item Find all \texttt{.pdf} files, in current dir and sub-dirs
+ \begin{lstlisting}
+ $ find . -name ``*.pdf''
+ \end{lstlisting} % $
+ \item List all the directory and sub-directory names
+ \begin{lstlisting}
+ $ find . -type d
+ \end{lstlisting} % $
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{cmp}}
+ \begin{itemize}
+ \item Compare two files
+ \end{itemize}
+ \begin{lstlisting}
+ $ find . -name quick.c
+ ./Desktop/programs/quick.c
+ ./c-folder/quick.c
+ $ cmp Desktop/programs/quick.c \
+ c-folder/quick.c
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item No output when the files are exactly the same
+ \item Else, gives location where the first difference occurs
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{diff}}
+ \begin{itemize}
+ \item We know the files are different, but want exact differences
+ \end{itemize}
+ \begin{lstlisting}
+ $ diff Desktop/programs/quick.c \
+ c-folder/quick.c
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item line by line difference between files
+ \item \texttt{>} indicates content only in second file
+ \item \texttt{<} indicates content only in first file
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{\texttt{tar}}
+\begin{itemize}
+\item \emph{tarball} -- essentially a collection of files
+\item May or may not be compressed
+\item Eases the job of storing, backing-up \& transporting files
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Extracting an archive}
+
+\begin{lstlisting}
+$ mkdir extract
+$ cp allfiles.tar extract/
+$ cd extract
+$ tar -xvf allfiles.tar
+\end{lstlisting} %$
+
+\begin{itemize}
+\item \texttt{-x} --- Extract files within the archive
+\item \texttt{-f} --- Specify the archive file
+\item \texttt{-v} --- Be verbose
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Creating an archive}
+\begin{lstlisting}
+$ tar -cvf newarchive.tar *.txt
+\end{lstlisting} % $
+\begin{itemize}
+\item \texttt{-c} --- Create archive
+\item Last argument is list of files to be added to archive
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Compressed archives}
+ \begin{itemize}
+ \item \texttt{tar} can create and extract compressed archives
+ \item Supports compressions like gzip, bzip2, lzma, etc.
+ \item Additional option to handle compressed archives
+ \begin{center}
+ \begin{tabular}{ll}
+ Compression & Option \\
+ gzip & \texttt{-z} \\
+ bzip2 & \texttt{-j} \\
+ lzma & \texttt{-{}-lzma} \\
+ \end{tabular}
+ \end{center}
+ \end{itemize}
+ \begin{lstlisting}
+ $ tar -cvzf newarchive.tar.gz *.txt
+ \end{lstlisting} % $
+\end{frame}
+
+
+\begin{frame}
+\frametitle{Customizing your shell}
+\begin{itemize}
+\item Bash reads \texttt{/etc/profile},
+ \texttt{\textasciitilde{}/.bash\_profile},
+ \texttt{\textasciitilde{}/.bash\_login}, and
+ \texttt{\textasciitilde{}/.profile} in that order, when starting
+ up as a login shell.
+\item \texttt{\textasciitilde{}/.bashrc} is read, when not a login
+ shell
+\item Put any commands that you want to run when bash starts, in this
+ file.
+\end{itemize}
+\end{frame}
+
+%% THE DOCUMENT ENDS HERE
+\end{document}
+%%%%%%%%%%%%%%%%%%%%
+
+\section{Basic editing and editors}
+\begin{frame}[fragile]
+\frametitle{vim}
+
+
+Vim is a very powerful editor. It has a lot of commands, and all of them
+cannot be explained here. We shall try and look at a few, so that you
+can find your way around in vim.
+
+To open a file in vim, we pass the filename as a parameter to the \texttt{vim}
+command. If a file with that filename does not exist, a new file is
+created.
+
+\begin{lstlisting}
+$ vim first.txt
+\end{lstlisting} % $
+
+To start inserting text into the new file that we have opened, we need
+to press the \texttt{i} key. This will take us into the \emph{insert} mode from the
+\emph{command} mode. Hitting the \texttt{esc} key, will bring us back to the
+\emph{command} mode. There is also another mode of vim, called the \emph{visual}
+mode which will be discussed later in the course.
+
+In general, it is good to spend as little time as possible in the insert
+mode and extensively use the command mode to achieve various tasks.
+
+To save the file, use \texttt{:w} in the command mode. From here on, it is
+understood that we are in the command mode, whenever we are issuing any
+command to vim.
+
+To save a file and continue editing, use \texttt{:w FILENAME} The file name is
+optional. If you do not specify a filename, it is saved in the same file
+that you opened. If a file name different from the one you opened is
+specified, the text is saved with the new name, but you continue editing
+the file that you opened. The next time you save it without specifying a
+name, it gets saved with the name of the file that you initially opened.
+
+To save file with a new name and continue editing the new file, use
+\texttt{:saveas FILENAME}
+
+To save and quit, use \texttt{:wq}
+
+To quit, use \texttt{:q}
+
+To quit without saving, use \texttt{:q!}
+\begin{itemize}
+
+\item Moving around\\
+While you are typing in a file, it is in-convenient to keep moving your
+fingers from the standard position for typing to the arrow keys. Vim,
+therefore, provides alternate keys for moving in the document. Note
+again that, you should be in the command mode, when issuing any commands
+to vim.
+
+The basic cursor movement can be achieved using the keys, \texttt{h} (left),
+\texttt{l} (right), \texttt{k} (up) and \texttt{j} (down).
+
+\begin{lstlisting}
+^
+k
+\end{lstlisting} % $
+
+\begin{quote}
+
+\begin{description}
+\item[< h l >] j v
+\end{description}
+
+\end{quote}
+
+Note: Most commands can be prefixed with a number, to repeat the
+command. For instance, \texttt{10j} will move the cursor down 10 lines.
+
+
+\item Moving within a line\\
+\begin{center}
+\begin{tabular}{ll}
+ Cursor Movement & Command \\
+\hline
+ Beginning of line & \texttt{0} \\
+ First non-space character of line & \texttt{\textasciicircum{}} \\
+ End of line & \texttt{\$} \\
+ Last non-space character of line & \texttt{g\_} \\
+\end{tabular}
+\end{center}
+
+
+
+
+\item Moving by words and sentences\\
+\begin{center}
+\begin{tabular}{ll}
+ Cursor Movement & Command \\
+\hline
+ Forward, word beginning & \texttt{w} \\
+ Backward, word beginning & \texttt{b} \\
+ Forward, word end & \texttt{e} \\
+ Backward, word end & \texttt{ge} \\
+ Forward, sentence beginning & \texttt{)} \\
+ Backward, sentence beginning & \texttt{(} \\
+ Forward, paragraph beginning & \texttt{\}} \\
+ Backward, paragraph beginning & \texttt{\{} \\
+\end{tabular}
+\end{center}
+
+
+
+
+\item More movement commands\\
+\begin{center}
+\begin{tabular}{ll}
+ Cursor Movement & Command \\
+\hline
+ Forward by a screenful of text & \texttt{C-f} \\
+ Backward by a screenful of text & \texttt{C-b} \\
+ Beginning of the screen & \texttt{H} \\
+ Middle of the screen & \texttt{M} \\
+ End of the screen & \texttt{L} \\
+ End of file & \texttt{G} \\
+ Line number \texttt{num} & \texttt{[num]G} \\
+ Beginning of file & \texttt{gg} \\
+ Next occurrence of the text under the cursor & \texttt{*} \\
+ Previous occurrence of the text under the cursor & \texttt{\#} \\
+\end{tabular}
+\end{center}
+
+
+
+Note: \texttt{C-x} is \texttt{Ctrl} + \texttt{x}
+
+
+\item The visual mode\\
+The visual mode is a special mode that is not present in the original vi
+editor. It allows us to highlight text and perform actions on it. All
+the movement commands that have been discussed till now work in the
+visual mode also. The editing commands that will be discussed in the
+future work on the visual blocks selected, too.
+
+
+\item Editing commands\\
+The editing commands usually take the movements as arguments. A movement
+is equivalent to a selection in the visual mode. The cursor is assumed
+to have moved over the text in between the initial and the final points
+of the movement. The motion or the visual block that's been highlighted
+can be passed as arguments to the editing commands.
+
+
+\begin{center}
+\begin{tabular}{ll}
+ Editing effect & Command \\
+\hline
+ Cutting text & \texttt{d} \\
+ Copying/Yanking text & \texttt{y} \\
+ Pasting copied/cut text & \texttt{p} \\
+\end{tabular}
+\end{center}
+
+
+
+The cut and copy commands take the motions or visual blocks as arguments
+and act on them. For instance, if you wish to delete the text from the
+current text position to the beginning of the next word, type \texttt{dw}. If
+you wish to copy the text from the current position to the end of this
+sentence, type \texttt{y)}.
+
+Apart from the above commands, that take any motion or visual block as
+an argument, there are additional special commands.
+
+
+\begin{center}
+\begin{tabular}{ll}
+ Editing effect & Command \\
+\hline
+ Cut the character under the cursor & \texttt{x} \\
+ Replace the character under the cursor with \texttt{a} & \texttt{ra} \\
+ Cut an entire line & \texttt{dd} \\
+ Copy/yank an entire line & \texttt{yy} \\
+\end{tabular}
+\end{center}
+
+
+
+Note: You can prefix numbers to any of the commands, to repeat them.
+
+
+\item Undo and Redo\\
+You can undo almost anything using \texttt{u}.
+
+To undo the undo command type \texttt{C-r}
+
+
+\item Searching and Replacing\\
+\begin{center}
+\begin{tabular}{ll}
+ Finding & Command \\
+\hline
+ Next occurrence of \texttt{text}, forward & \texttt{\textbackslash{}text} \\
+ Next occurrence of \texttt{text}, backward & \texttt{?text} \\
+ Search again in the same direction & \texttt{n} \\
+ Search again in the opposite direction & \texttt{N} \\
+ Next occurrence of \texttt{x} in the line & \texttt{fx} \\
+ Previous occurrence of \texttt{x} in the line & \texttt{Fx} \\
+\end{tabular}
+\end{center}
+
+
+
+
+\begin{center}
+\begin{tabular}{ll}
+ Finding and Replacing & Command \\
+\hline
+ Replace the first instance of \texttt{old} with \texttt{new} in the current line. & \texttt{:s/old/new} \\
+ Replace all instances of \texttt{old} with \texttt{new} in the current line. & \texttt{:s/old/new/g} \\
+ Replace all instances of \texttt{old} with \texttt{new} in the current line, but ask for confirmation each time. & \texttt{:s/old/new/gc} \\
+ Replace the first instance of \texttt{old} with \texttt{new} in the entire file. & \texttt{:\%s/old/new} \\
+ Replace all instances of \texttt{old} with \texttt{new} in the entire file. & \texttt{:\%s/old/new/g} \\
+ Replace all instances of \texttt{old} with \texttt{new} in the entire file but ask for confirmation each time. & \texttt{:\%s/old/new/gc} \\
+\end{tabular}
+\end{center}
+
+
+
+\end{itemize} % ends low level
+\end{frame}
+\begin{frame}
+\frametitle{SciTE}
+
+
+SciTE is a \emph{source code} editor, that has a feel similar to the commonly
+used GUI text editors. It has a wide range of features that are
+extremely useful for a programmer, editing code. Also it aims to keep
+configuration simple, and the user needs to edit a text file to
+configure SciTE to his/her liking.
+
+Opening, Saving, Editing files with SciTE is extremely simple and
+trivial. Knowledge of using a text editor will suffice.
+
+SciTE can syntax highlight code in various languages. It also has
+auto-indentation, code-folding and other such features which are useful
+when editing code.
+
+SciTE also gives you the option to (compile and) run your code, from
+within the editor.
+\end{frame}
+
+
+
diff --git a/slides/vcs/vcs.tex b/slides/vcs/vcs.tex
new file mode 100644
index 0000000..3b5e6ab
--- /dev/null
+++ b/slides/vcs/vcs.tex
@@ -0,0 +1,516 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Version Control Systems
+%
+% Author: FOSSEE
+% Copyright (c) 2009, FOSSEE, IIT Bombay
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\documentclass[14pt,compress]{beamer}
+
+\mode<presentation>
+{
+ \usetheme{Warsaw}
+ \useoutertheme{infolines}
+ \setbeamercovered{transparent}
+}
+
+\usepackage[english]{babel}
+\usepackage[latin1]{inputenc}
+%\usepackage{times}
+\usepackage[T1]{fontenc}
+
+% Taken from Fernando's slides.
+\usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler}
+\usepackage[scaled=.95]{helvet}
+
+\definecolor{darkgreen}{rgb}{0,0.5,0}
+
+\usepackage{listings}
+\lstset{language=bash,
+ basicstyle=\ttfamily\bfseries,
+ commentstyle=\color{red}\itshape,
+ stringstyle=\color{darkgreen},
+ showstringspaces=false,
+ keywordstyle=\color{blue}\bfseries}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Macros
+\setbeamercolor{emphbar}{bg=blue!20, fg=black}
+\newcommand{\emphbar}[1]
+{\begin{beamercolorbox}[rounded=true]{emphbar}
+ {#1}
+ \end{beamercolorbox}
+}
+\newcounter{time}
+\setcounter{time}{0}
+\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
+
+\newcommand{\typ}[1]{\lstinline{#1}}
+
+\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
+
+% Title page
+\title[Mercurial]{Version Control with \typ{hg}}
+
+\author[FOSSEE] {FOSSEE}
+
+\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\date[]{}
+
+\AtBeginSection[]
+{
+ \begin{frame}<beamer>
+ \frametitle{Outline}
+ \tableofcontents[currentsection,currentsubsection]
+ \end{frame}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% DOCUMENT STARTS
+\begin{document}
+
+\begin{frame}
+ \maketitle
+\end{frame}
+
+% CREATING TOC
+\begin{frame}
+ \frametitle{Outline}
+ \tableofcontents
+ % You might wish to add the option [pausesections]
+\end{frame}
+
+\begin{frame}
+ \frametitle{Objectives}
+ At the end of this session, you will be able to:
+ \begin{itemize}
+ \item Understand what is Version Control and the need for it
+ \item Create and use repository on a daily basis
+ \item Clone existing repositories, from the web
+ \item View the history of a repository
+ \item Make changes to a repository and commit them
+ \item Work collaboratively with a team
+ \end{itemize}
+\end{frame}
+
+%% There are some %$ used just to minimise the effect of $ sign used
+%% in lstlisting. In emacs it looks dirty.
+
+% Introduction to course-need of version control, history, options available.
+\section{Introduction}
+
+\begin{frame}
+ \frametitle{What is Version Control?}
+ \begin{block}{}
+ A way to track changes made to files over time, by keeping copies
+ of files as we change them.
+ \end{block}
+\end{frame}
+
+%% Home made version control system?
+\begin{frame}[fragile]
+ \frametitle{Home-brewed}
+ \begin{center}
+ An example of a \typ{home-brew} Version Control system
+ \includegraphics[height=1.8in,width=4.2in]{images/folder.png}
+ \end{center}
+ \begin{lstlisting}
+$ ls
+a.out id1.txt id2.txt identifier.cpp id.txt lex pda1.cpp pda2.cpp pda.cpp pda.txt string.txt
+ \end{lstlisting} %%$
+ %%a screen-shot of folder with all crazy names.
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Problems}
+ \begin{block}{}
+ \begin{itemize}
+ \item Name and changes made are not related or linked.
+ \item Can't track sequence of changes made to a file.
+ \item Does not scale.
+ \end{itemize}
+ \end{block}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{The need for Version Control}
+ \begin{itemize}
+ \item \alert{To err is Human} \ldots
+ \item Tracking the history and evolution of a project
+ \item To collaborate effectively on a project
+ \item To efficiently track down bugs and pin-point the changes that
+ caused it
+ \end{itemize}
+\end{frame}
+
+%% Introduction to how logs are managed in VCS.
+%% A analogy in logs and day-to-day life?
+\begin{frame}[fragile]
+ \frametitle{How does it work? --- Analogy}
+ It is, in some ways, similar to playing an Video game.
+ \begin{itemize}
+ \item We play games in stages
+ \item Once we finish a stage or a task -- \alert{we SAVE}
+ \item We continue playing
+ \item But, if necessary, we could choose from one of the saved
+ states and start from there
+ \item We could alter the course of the game
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}
+ \frametitle{Mercurial or \typ{hg}}
+ \begin{center}
+ \includegraphics[height=.75in,interpolate=true]{images/mercurial_logo}
+ \end{center}
+ \begin{itemize}
+ \item Easy to learn and use
+ \item Lightweight
+ \item Scales excellently
+ \item Written in Python
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Installation}
+ \begin{itemize}
+ \item \typ{sudo apt-get install mercurial}
+ \item TortoiseHg
+ \item \typ{\$ hg}
+ \item \typ{\$ hg version}
+ \end{itemize}
+\end{frame}
+
+\section{Let there be a Repo!}
+% init, status, commit, log, [ui]
+\begin{frame}
+ \frametitle{We need a repo!}
+ \begin{itemize}
+ \item A Repository (repo) is where all the action is!
+ \item Project files along with a special directory that stores all the
+ changes
+ \item We take snapshots of the whole repository; not individual
+ files.
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Initializing a repo}
+ \begin{itemize}
+ \item \typ{\$ hg init}
+ \item Creates a fresh repository
+ \item Adds a \typ{.hg} directory to our \emph{working directory}
+ \end{itemize}
+ \emphbar{\typ{.hg} directory keeps log of changes made henceforth}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Status report}
+ \begin{itemize}
+ \item \typ{hg status} gives the status of our repo
+ \item Use it often; at least as a beginner
+ \item \typ{hg help command} gives us help about \typ{command}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Status codes}
+ \begin{lstlisting}
+ M = modified
+ A = added
+ R = removed
+ C = clean
+ ! = missing
+ ? = not tracked
+ I = ignored
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Adding files}
+ \begin{itemize}
+ \item From \typ{hg status} we know, none of the files are being
+ tracked, yet.
+ \item \typ{hg add} --- asking \typ{hg} to track these files
+ \item As expected \typ{hg status} prepends an \typ{A} to the file
+ names.
+ \item \typ{? --> A}
+ \item \typ{! --> R} (\typ{hg remove})
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Taking Snapshots}
+ \begin{itemize}
+ \item \typ{hg commit}
+ \item Asking Mercurial to take a snapshot; remember the changes made
+ to the repository.
+ \item \typ{-u FirstName LastName <email>}
+ \item \typ{-m ``Commit message''} -- a description of changes committed.
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Thumbnail views}
+ \begin{itemize}
+ \item \typ{hg log}~ gives the log of the changes made
+ \item A \typ{changeset} is an atomic collection of changes to the
+ files (between successive commits)
+ \end{itemize}
+ \begin{block}{Log information}
+ \begin{itemize}
+ \item \alert{changeset}: Identifier for the changeset
+ \item \alert{user}: Details of user who created the changeset
+ \item \alert{date}: Date and time of creation
+ \item \alert{summary}: One line description
+ \end{itemize}
+ \end{block}
+\end{frame}
+
+\begin{frame}
+ \frametitle{User information}
+ \begin{itemize}
+ \item User information is set in the \typ{hgrc} file
+ \item It can be set globally or local to the project
+ \item Global \typ{hgrc}
+ \begin{itemize}
+ \item \typ{\$HOME/.hgrc} -- Unix like systems
+ \item \typ{\%HOME\%\\.hgrc} -- Windows
+ \end{itemize}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{\alert{Advice}: \typ{commits}, messages}
+ \begin{itemize}
+ \item Atomic changes; one change with one \typ{commit}
+ \item Single line summary --- 60 to 65 characters long
+ \item Followed by paragraphs of detailed description
+ \begin{itemize}
+ \item Why the change?
+ \item What does it effect?
+ \item Known bugs/issues?
+ \item etc.
+ \end{itemize}
+ \end{itemize}
+\end{frame}
+
+\section{But Why \typ{commit}~?}
+
+\begin{frame}
+ \frametitle{Operational overhead?}
+ \begin{itemize}
+ \item But why do we \typ{commit}?
+ \item Isn't all this just adding to operational costs?
+ \item Isn't all this a waste of time?
+ \end{itemize}
+ \begin{center}
+ \emphbar{No! You shall see the benefits, soon!}
+ \end{center}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Revert Changes}
+ \begin{itemize}
+ \item Undo all changes; the editor can only do so much.
+ \item \typ{hg revert --all}
+ \item \typ{hg revert filename}
+ \item Present file, with changes --- \typ{filename.orig}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Viewing Changes}
+ \begin{itemize}
+ \item \typ{hg diff} --- all changes since last commit
+ \end{itemize}
+ \begin{block}{}
+ \begin{lstlisting}
+ - this line was deleted
+ + this line was added
+ \end{lstlisting}
+ \end{block}
+\end{frame}
+
+
+\begin{frame}[fragile]
+ \frametitle{Revision numbering}
+ \begin{itemize}
+ \item \typ{changeset: n:cbf6e2a375b4}
+ \item \typ{n} is the revision number
+ \item The revision number is local to a repository
+ \item \typ{cbf6e2a375b4} is the unique identifier
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Using revision numbers}
+ \begin{itemize}
+ \item \typ{-r n} can be passed as arguments to commands to specify
+ the revision number
+ \item For instance, \typ{hg diff -r1 -r2}
+ \item \typ{m:n} specifies a range of revision numbers
+ \item For instance, \typ{hg log -r0:2}
+ \end{itemize}
+\end{frame}
+
+\section{Collaborating with Mercurial}
+\begin{frame}[fragile]
+ \frametitle{Cloning Repositories}
+ \begin{itemize}
+ \item \typ{hg clone SOURCE [DEST]}
+ \item All \typ{hg} repositories are self-contained
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Sharing Repositories}
+ \begin{itemize}
+ \item \typ{hg serve}
+ \item Can be cloned with \typ{hg clone http://my-ip-address:8000}
+ \item We share a central repository; work on our local copies.
+ \item Set write permissions in \typ{.hg/hgrc}
+ \end{itemize}
+ \begin{lstlisting}
+ [web]
+ push_ssl=False
+ allow_push=*
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Sharing Changes}
+ \begin{itemize}
+ \item Use \typ{hg push} to push your \typ{commits}
+ (\typ{changesets}) to the central repository
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}
+ \frametitle{Pulling Changes}
+ \begin{itemize}
+ \item \typ{hg incoming} shows new \typ{changesets} in the server
+ \item To get these \typ{changesets}, we use \typ{hg pull}
+ \item These changes do not affect our working directory
+ \item \typ{hg parent} shows the parents of the working directory
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Pulling Changes \ldots}
+ \begin{itemize}
+ \item \typ{hg update} will update the working directory
+ \begin{itemize}
+ \item Updates to the \typ{tip} if no revision is specified
+ \item \typ{tip} is the most recently added changeset
+ \item Can specify revision number to update to
+ \end{itemize}
+ \item \typ{hg tip} shows the \typ{tip} of the repository
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Simultaneous Changes}
+ \begin{itemize}
+ \item The logs of both repositories will be different
+ \item The repositories have diverged
+ \item \typ{hg push} fails, in such a scenario
+ \item \alert{Never, Never, Never, Ever} use \typ{hg push -f}
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Merging}
+ \begin{itemize}
+ \item Pull and merge, when \typ{abort: push creates new remote
+ heads!}
+ \item \typ{hg merge} will merge the two diverged heads
+ \item \typ{commit} after you have \typ{merged}!
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Simultaneous Changes \ldots}
+ \begin{itemize}
+ \item \typ{outgoing} shows the \typ{changesets} that will be pushed
+ \item \typ{hg push} works!
+ \item Look at the `Change graph'!
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Simultaneous Conflicting Changes}
+ \begin{itemize}
+ \item What if the changes conflict? -- overlapping edits
+ \item \typ{hg push} fails; \typ{hg pull}; \typ{hg merge}
+ \item You now get a diff view with 3 panes
+ \begin{itemize}
+ \item First --- current file
+ \item Second --- \typ{changesets} that you pulled
+ \item Third --- file before you made your changes
+ \end{itemize}
+ \item Resolve conflict and save
+ \item \typ{hg commit}; \typ{hg push}
+ \item Look at the `Change graph'!
+ \end{itemize}
+\end{frame}
+
+\section{Conclusion}
+
+\begin{frame}
+ \frametitle{\alert{Advice}: Work-flow}
+ General work-flow
+ \begin{itemize}
+ \item \typ{pull}; \typ{update}
+ \item Make changes
+ \item \typ{commit}
+ \item If changes on repo, \typ{pull} and \typ{merge}
+ \item \typ{push}
+ \end{itemize}
+ \emphbar{Commit Early, Commit Often}
+\end{frame}
+
+\begin{frame}[fragile,allowframebreaks]
+ \frametitle{Summary}
+ In this session, we have learnt to:
+ \begin{itemize}
+ \item initialize new repositories, using \typ{hg init}
+ \item check the status using \typ{hg status}
+ \item get help for any command using \typ{hg help}
+ \item commit changes or take snapshots using \typ{hg commit}
+ \item view the history of a repository using \typ{hg log}
+ \item set the user info in the global \typ{hgrc} file
+ \item undo changes using \typ{hg revert}
+ \item view changes using \typ{hg diff}
+ \item use revision numbers as arguments to various commands
+ \item clone repositories using \typ{hg clone}
+ \item server repositories using \typ{hg serve}
+ \item push changes using \typ{hg push}
+ \item pull changes using \typ{hg pull}
+ \item update working directory to latest revision using \typ{hg
+ update}
+ \item merge two heads using \typ{hg merge}
+ \item resolve merge conflicts using \typ{hg resolve}
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}
+ \frametitle{References}
+ \begin{itemize}
+ \item \href{http://betterexplained.com/articles/a-visual-guide-to-version-control/}{A Visual Guide to Version Control}
+ \item \href{http://karlagius.com/2009/01/09/version-control-for-the-masses/}{Version Control for the Masses}
+ \item \href{http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated/}{(Illustrated) Intro to Distributed Version Control}
+ \item \href{http://mercurial.selenic.com/wiki/UnderstandingMercurial}{Understanding Mercurial}
+ \item \href{http://mercurial.selenic.com/wiki/Tutorial}{A Tutorial on Using Mercurial}
+ \item \href{http://hginit.com/}{Hg Init: a Mercurial tutorial}
+ \item \href{http://mercurial.selenic.com/wiki/BeginnersGuides}{Beginners Guides}
+ \item \href{http://software-carpentry.org/4_0/vc/}{Software Carpentry}
+ \end{itemize}
+\end{frame}
+
+\end{document}
+