More work on presentation + improves auto images

Added more slides

Auto graphics now work for xkcd and ansi shell output
master
Jonathan Hodgson 4 years ago
parent b128151e39
commit 2712cddb60
  1. 2
      .gitignore
  2. 19
      Makefile
  3. 82
      bin/ansi2svg
  4. 2
      bin/get-auto-graphics
  5. 189
      main.latex

2
.gitignore vendored

@ -5,5 +5,7 @@
*.nav
*.snm
*.pdf
*.vrb
with-notes.*
auto-images/
_minted-*/

@ -1,22 +1,29 @@
XKCD_FILES = $(shell bin/xkcd-filenames)
GRAPHICS_FILES = $(shell bin/get-auto-graphics)
main.pdf: main.latex $(XKCD_FILES)
pdflatex -output-directory="./" main.latex
main.pdf: main.latex $(GRAPHICS_FILES)
pdflatex -shell-escape -output-directory="./" main.latex
with-notes.pdf: with-notes.latex
pdflatex -output-directory="./" with-notes.latex
pdflatex -shell-escape -output-directory="./" with-notes.latex
with-notes.latex: main.latex $(XKCD_FILES)
with-notes.latex: main.latex $(GRAPHICS_FILES)
sed 's/\%showNotes\%//' main.latex > with-notes.latex
clean:
rm *.aux *.log *.out *.toc *.nav *.snm *.pdf
rm *.aux *.log *.out *.toc *.nav *.snm *.pdf *.vrb
rm with-notes.latex
auto-images/auto-xkcd-%.png:
mkdir -p auto-images
curl https://xkcd.com/$*/info.0.json 2> /dev/null | jq '.img' | sed 's/.png/_2x.png/g' | xargs curl -s -o $@
auto-images/auto-shell-%.pdf: auto-images/auto-shell-%.svg
inkscape auto-images/auto-shell-$*.svg --export-area-drawing --batch-process --export-type=pdf --export-filename=$@
auto-images/auto-shell-%.svg: shell-output/%.out
mkdir -p auto-images
cat shell-output/$*.out | bin/ansi2svg > $@
clean-images:
rm -rf auto-images/

@ -0,0 +1,82 @@
#!/usr/bin/env node
// Relies on this being installed: https://github.com/F1LT3R/ansi-to-svg
const {stdin} = process;
const ansiToSVG = require('ansi-to-svg')
getStdin = async () => {
let result = '';
if (stdin.isTTY) {
return result;
}
stdin.setEncoding('utf8');
for await (const chunk of stdin) {
result += chunk;
}
return result;
};
(async () => {
// Returns an SVG string
console.log(ansiToSVG(await getStdin(), {
// Defaults to 2x for Retina compatibility
scale: 2,
// Font settings
fontFace: 'Courier',
fontSize: 14,
lineHeight: 18,
// Padding
paddingTop: 5,
paddingLeft: 5,
paddingBottom: 5,
paddingRight: 5,
// Supply an iTerm2 Color file
colors: './base16-flat-dark-f1lt3r-256.itermcolors',
// Or override the default colors
// (all defaults shown here)
colors: {
black: '#000000',
red: '#B22222',
green: '#32CD32',
yellow: '#DAA520',
blue: '#4169E1',
magenta: '#9932CC',
cyan: '#008B8B',
white: '#D3D3D3',
gray: '#A9A9A9',
redBright: '#FF4500',
greenBright: '#ADFF2F',
yellowBright: '#FFFF00',
blueBright: '#87CEEB',
magentaBright: '#FF00FF',
cyanBright: '#00FFFF',
whiteBright: '#FFFFFF',
bgBlack: '#000000',
bgRed: '#B22222',
bgGreen: '#32CD32',
bgYellow: '#DAA520',
bgBlue: '#4169E1',
bgMagenta: '#9932CC',
bgCyan: '#008B8B',
bgWhite: '#D3D3D3',
bgGray: '#A9A9A9',
bgRedBright: '#FF0000',
bgGreenBright: '#ADFF2F',
bgYellowBright: '#FFFF00',
bgBlueBright: '#87CEEB',
bgMagentaBright: '#FF00FF',
bgCyanBright: '#00FFFF',
bgWhiteBright: '#FFFFFF',
backgroundColor: '#000000',
foregroundColor: '#D3D3D3'
}
}))
})();

@ -3,4 +3,4 @@ grep -o '\\includegraphics.*\}' main.latex |
cut -d'{' -f2 |
cut -d'}' -f 1 |
grep '^auto-' |
awk '{print "./auto-images/" $1 ".png"}'
awk '{print "./auto-images/" $1}'

@ -5,16 +5,40 @@
%showNotes%\setbeameroption{show notes on second screen=right}
%\setbeamertemplate{note page}{\pagecolor{yellow!5}\insertnote}
\setbeamertemplate{note page}{\setlength{\parskip}{12pt}\pagecolor{yellow!5}\vfill\insertnote\vfill}
\setlength{\parskip}{12pt}
\usepackage{palatino}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{pdfpages}
\usepackage{dirtree}
\usepackage{csquotes}
%\usepackage{gitdags}
\usepackage{minted}
\setminted{%
autogobble,
fontsize=\footnotesize,
breaklines
}
\usetheme{default}
\beamertemplatenavigationsymbolsempty
\hypersetup{pdfpagemode=UseNone} % don't show bookmarks on initial view
%\lstset{%
% breaklines=true,
% postbreak=\mbox{$\hookrightarrow$\space},
% basicstyle=\footnotesize,
% %keywordstyle=\color{blue},
% morekeywords=git
%}
\usepackage{graphicx}
\graphicspath{ {./auto-images/} }
\makeatletter
\def\input@path{{auto-images/}}
%or: \def\input@path{{/path/to/folder/}{/path/to/other/folder/}}
\makeatother
%Information to be included in the title page:
\title{Git}
\author{Jonathan Hodgson (Archie)}
@ -37,10 +61,18 @@
\begin{frame}
\frametitle{Obligitary XKCD Comic}
\begin{center}
\includegraphics[width=\textwidth,height=0.8\textheight,keepaspectratio]{auto-xkcd-1597}
\includegraphics[width=\textwidth,height=0.8\textheight,keepaspectratio]{auto-xkcd-1597.png}
\end{center}
\note{%
Git's interface can seem weird, mainly because it is. I think that understanding a bit about how Git works under the hood helps with understanding why some of the commands do what they do.
I have done this
Git has a reputation for being hard.
It's interface abstracts away a lot of the work, meaning it's commands can feel like magic. When it works, this is fine but unfortunately when things go wrong, you can be left - like in this comic - with no idea how to proceed.
I think that understanding a bit about how Git works under the hood will help de-mistily it.
Git's data model is actually quite simple. Understanding the basics of this can really help.
}
\end{frame}
@ -58,30 +90,171 @@
It's useful even if you're working on things by your self. This presentation is version controlled.
You can use it to find out when something broke. I won't be covering it today but there is a tool called git bisect that can take a unit test (or script) to analyse when something broke using a binary search.
I think with a lot of tools that we use, having a deeper understanding of how they work means that we can use them better.
}
\end{frame}
\begin{frame}
\frametitle{A bit of theory - Blob}
\frametitle{Let's avoid this}
\dirtree{%
.1 Project.
.2 draft.
.3 some.
.3 files.
.2 final-draft.
.3 some.
.3 files.
.2 final.
.3 some.
.3 files.
.2 real-final.
.3 some.
.3 files.
.2 actual-real-final.
.3 some.
.3 files.
}
\note{%
I think, being honest, we have all done this. This sort of works, if you're working on something by yourself. Once you start collaborating on software, you are going to have a bad time.
However, this is a simple approach and not a million miles from what Git does internally.
I want this to be quite interactive so first things first, let's get Git setup.
}
\end{frame}
\begin{frame}[fragile]
\frametitle{Install}
\begin{minted}{bash}
# Ubuntu / Debian / Kali
sudo apt install git
# Centos / Fedora / Red Hat
sudo dnf install git
# Arch / Antergos / Manjaro
sudo pacman -S git
# Mac
brew install git
\end{minted}
\href{https://gitforwindows.org/}{Git for Windows: https://gitforwindows.org/}
\note{%
Git is probably already installed if you are on a Linux system. However, if not, it will definitely be in your standard repositories.
There is a version of Git provided with xcode, but it is old. Most of the stuff we cover today should still work but (for example) some things need to be run from the root directory in old versions of git that don't in newer versions.
If you have the misfortune to be using windows, I've heard good things about Git for Windows but have not used it personally. It includes Bash emulation.
}
\end{frame}
\begin{frame}[fragile]
\frametitle{Setting It Up}
\framesubtitle{User}
\begin{minted}{bash}
git config --global user.name "Jonathan Hodgson"
git config --global user.email "git@jonathanh.co.uk"
\end{minted}
\note{%
Hopefully you have Git installed. I will be running it on Linux although the commands should all be the same for Windows and Mac.
Note that I am not using my primary email address. The email address you provide here will be available to anyone with access to repositories you work on.
These settings are stored in \mintinline{bash}{~/.gitconfig}.
}
\end{frame}
\begin{frame}[fragile]
\frametitle{Setting It Up}
\framesubtitle{Editor}
\textbf{Pick One}
\begin{minted}{bash}
# Set editor to nano
git config --global core.editor "nano"
In Git, a file is called a blob.
# Set editor to VS Code
git config --global core.editor "code -w"
# Set editor to Sublime
git config --global core.editor "subl -w"
\end{minted}
\note{%
There are several times that Git will need to open a text editor. By default, it will use \mintinline{bash}{EDITOR}. If neither is set, it will use VI.
Note that if you are using a GUI editor, you might have to set the wait flag. This makes it so the executable doesn't return until you close it.
}
\end{frame}
\begin{frame}[fragile]
\frametitle{Create a repository}
\begin{minted}{bash}
mkdir Project
cd Project
git init
\end{minted}
\note{%
This bit is a bit boring but I really think it will help with grasping what git does.
Do this in a live terminal. MAKE SURE YOU MAKE YOUR FONT BIGGER
I think with a lot of tools that we use, having a deep understand of how they work means that we can use them better.
Show that the \mintinline{bash}{.git} folder has been created and do a tree to show what is in it.
}
\end{frame}
\begin{frame}[fragile]
\frametitle{Git status}
\begin{minted}{bash}
git status
\end{minted}
\begin{center}
\includegraphics[width=\textwidth,height=0.8\textheight,keepaspectratio]{auto-shell-git-status.pdf}
\end{center}
\end{frame}
\begin{frame}
\frametitle{Terminology}
\textbf{Blob} In Git, a file is called a blob.
\textbf{Tree} In Git, a directory is called a tree.
\textbf{Root} The top level directory is called the root.
\note{%
Pretty simple stuff.
Because we don't have enough roots in Linux. :/
Now we can start doing stuff
}
\end{frame}
\begin{frame}
\frametitle{Commits}
\begin{center}
\includegraphics[width=\textwidth,height=0.8\textheight,keepaspectratio]{auto-xkcd-1296}
\includegraphics[width=\textwidth,height=0.8\textheight,keepaspectratio]{auto-xkcd-1296.png}
\end{center}
\end{frame}
\begin{frame}
\frametitle{Commit Messages}
\begin{center}
\includegraphics[width=\textwidth,height=0.8\textheight,keepaspectratio]{auto-xkcd-1296.png}
\end{center}
\end{frame}
\begin{frame}
\frametitle{When should you commit?}
\end{frame}
\end{document}

Loading…
Cancel
Save