From 4555491b5fdb3f38c731e409c2f98b46ac675efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 17 Oct 2017 07:59:09 +0200 Subject: Some directory movements --- 2017-installfest/face_cry.svg | 1 + 2017-installfest/face_happy.svg | 1 + 2017-installfest/face_sad.svg | 1 + 2017-installfest/git.eps | Bin 0 -> 284506 bytes 2017-installfest/makefile | 10 + 2017-installfest/pres.pdf | Bin 0 -> 344798 bytes 2017-installfest/pres.tex | 304 +++++ 2017-installfest/scheme.svg | 1170 ++++++++++++++++++++ 2017-installfest/scheme/Gorilla-server.svg | 90 ++ 2017-installfest/scheme/Laptop_font_awesome.svg | 59 + .../desktop-computer-with-screen-vector-icon.eps | Bin 0 -> 655462 bytes 2017-installfest/scheme/smartphone-call.svg | 43 + 2017-installfest/scheme/turris_omnia.png | Bin 0 -> 32458 bytes 2017-installfest/syncthing.png | Bin 0 -> 113879 bytes 2017-linuxdays/Makefile | 10 + 2017-linuxdays/pres.pdf | Bin 0 -> 261771 bytes 2017-linuxdays/pres.tex | 475 ++++++++ 2017-linuxdays/theme/cznic-cz.pdf | Bin 0 -> 6109 bytes 2017-linuxdays/theme/cznic-en.pdf | Bin 0 -> 6060 bytes 2017-linuxdays/theme/nicbottom.pdf | Bin 0 -> 7132 bytes 2017-linuxdays/theme/nictop.pdf | Bin 0 -> 12767 bytes 2017-linuxdays/theme/theme.tex | 42 + 2017-linuxdays/theme/title.tex | 14 + README.md | 4 +- installfest2017/face_cry.svg | 1 - installfest2017/face_happy.svg | 1 - installfest2017/face_sad.svg | 1 - installfest2017/git.eps | Bin 284506 -> 0 bytes installfest2017/makefile | 10 - installfest2017/pres.pdf | Bin 344798 -> 0 bytes installfest2017/pres.tex | 304 ----- installfest2017/scheme.svg | 1170 -------------------- installfest2017/scheme/Gorilla-server.svg | 90 -- installfest2017/scheme/Laptop_font_awesome.svg | 59 - .../desktop-computer-with-screen-vector-icon.eps | Bin 655462 -> 0 bytes installfest2017/scheme/smartphone-call.svg | 43 - installfest2017/scheme/turris_omnia.png | Bin 32458 -> 0 bytes installfest2017/syncthing.png | Bin 113879 -> 0 bytes linuxdays2017/Makefile | 10 - linuxdays2017/pres.pdf | Bin 261771 -> 0 bytes linuxdays2017/pres.tex | 475 -------- linuxdays2017/theme/cznic-cz.pdf | Bin 6109 -> 0 bytes linuxdays2017/theme/cznic-en.pdf | Bin 6060 -> 0 bytes linuxdays2017/theme/nicbottom.pdf | Bin 7132 -> 0 bytes linuxdays2017/theme/nictop.pdf | Bin 12767 -> 0 bytes linuxdays2017/theme/theme.tex | 42 - linuxdays2017/theme/title.tex | 14 - 47 files changed, 2222 insertions(+), 2222 deletions(-) create mode 100644 2017-installfest/face_cry.svg create mode 100644 2017-installfest/face_happy.svg create mode 100644 2017-installfest/face_sad.svg create mode 100644 2017-installfest/git.eps create mode 100644 2017-installfest/makefile create mode 100644 2017-installfest/pres.pdf create mode 100644 2017-installfest/pres.tex create mode 100644 2017-installfest/scheme.svg create mode 100644 2017-installfest/scheme/Gorilla-server.svg create mode 100644 2017-installfest/scheme/Laptop_font_awesome.svg create mode 100644 2017-installfest/scheme/desktop-computer-with-screen-vector-icon.eps create mode 100644 2017-installfest/scheme/smartphone-call.svg create mode 100644 2017-installfest/scheme/turris_omnia.png create mode 100644 2017-installfest/syncthing.png create mode 100644 2017-linuxdays/Makefile create mode 100644 2017-linuxdays/pres.pdf create mode 100644 2017-linuxdays/pres.tex create mode 100644 2017-linuxdays/theme/cznic-cz.pdf create mode 100644 2017-linuxdays/theme/cznic-en.pdf create mode 100644 2017-linuxdays/theme/nicbottom.pdf create mode 100644 2017-linuxdays/theme/nictop.pdf create mode 100644 2017-linuxdays/theme/theme.tex create mode 100644 2017-linuxdays/theme/title.tex delete mode 100644 installfest2017/face_cry.svg delete mode 100644 installfest2017/face_happy.svg delete mode 100644 installfest2017/face_sad.svg delete mode 100644 installfest2017/git.eps delete mode 100644 installfest2017/makefile delete mode 100644 installfest2017/pres.pdf delete mode 100644 installfest2017/pres.tex delete mode 100644 installfest2017/scheme.svg delete mode 100644 installfest2017/scheme/Gorilla-server.svg delete mode 100644 installfest2017/scheme/Laptop_font_awesome.svg delete mode 100644 installfest2017/scheme/desktop-computer-with-screen-vector-icon.eps delete mode 100644 installfest2017/scheme/smartphone-call.svg delete mode 100644 installfest2017/scheme/turris_omnia.png delete mode 100644 installfest2017/syncthing.png delete mode 100644 linuxdays2017/Makefile delete mode 100644 linuxdays2017/pres.pdf delete mode 100644 linuxdays2017/pres.tex delete mode 100644 linuxdays2017/theme/cznic-cz.pdf delete mode 100644 linuxdays2017/theme/cznic-en.pdf delete mode 100644 linuxdays2017/theme/nicbottom.pdf delete mode 100644 linuxdays2017/theme/nictop.pdf delete mode 100644 linuxdays2017/theme/theme.tex delete mode 100644 linuxdays2017/theme/title.tex diff --git a/2017-installfest/face_cry.svg b/2017-installfest/face_cry.svg new file mode 100644 index 0000000..9e8837f --- /dev/null +++ b/2017-installfest/face_cry.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/2017-installfest/face_happy.svg b/2017-installfest/face_happy.svg new file mode 100644 index 0000000..6bc7f73 --- /dev/null +++ b/2017-installfest/face_happy.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/2017-installfest/face_sad.svg b/2017-installfest/face_sad.svg new file mode 100644 index 0000000..8c4a4c1 --- /dev/null +++ b/2017-installfest/face_sad.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/2017-installfest/git.eps b/2017-installfest/git.eps new file mode 100644 index 0000000..47500ce Binary files /dev/null and b/2017-installfest/git.eps differ diff --git a/2017-installfest/makefile b/2017-installfest/makefile new file mode 100644 index 0000000..9ab8f60 --- /dev/null +++ b/2017-installfest/makefile @@ -0,0 +1,10 @@ +FILE=pres + +$(FILE).pdf: $(FILE).tex $(patsubst %.svg,%.pdf,$(wildcard *.svg)) + pdflatex -shell-escape $< + +%.pdf: %.svg + inkscape -D -z --file=$< --export-pdf=$@ --export-latex + +clean: + ls | grep -v -E "($(FILE).tex|makefile|scheme|svg|png|eps)$$" | xargs rm -rf diff --git a/2017-installfest/pres.pdf b/2017-installfest/pres.pdf new file mode 100644 index 0000000..af41431 Binary files /dev/null and b/2017-installfest/pres.pdf differ diff --git a/2017-installfest/pres.tex b/2017-installfest/pres.tex new file mode 100644 index 0000000..1c36c4c --- /dev/null +++ b/2017-installfest/pres.tex @@ -0,0 +1,304 @@ +\documentclass{beamer} +\usetheme{metropolis} +\usepackage{lmodern} +\usepackage[czech]{babel} +\usepackage[utf8x]{inputenc} +%\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{graphicx} +\usepackage{wrapfig} +\usepackage{color} +\usepackage{mathtools} +\usepackage{hyperref} +\usepackage{epstopdf} +\usepackage{svg} +\usepackage{amsmath} +\usepackage{minted} +\hypersetup{ + colorlinks, + citecolor=black, + filecolor=black, + linkcolor=black, + urlcolor=black +} +\usepackage{pdflscape} + +\title{3 problémy při práci na 3 počítačích} +\author{Karel Kočí} +\date{4.3.2017} + +\begin{document} + +\frame{\titlepage} + +\begin{frame} + \begin{block}{\huge Napiš si skript!} + Přednášené skripty a více naleznete na: + \url{https://github.com/Cynerd/myconfigs} + \end{block} +\end{frame} + +\begin{frame} + \frametitle{3 problémy} + \begin{itemize} + \item Synchronizace souborů + \item Synchronizace a správa konfigurací + \item Správa systému + \end{itemize} +\end{frame} + +\begin{frame} + \frametitle{Synchronizace souborů} + \def\svgwidth{1cm} + \input{face_sad.pdf_tex} + \begin{itemize} + \item Dropbox + \item Mega + \item Google drive + \item \ldots + \end{itemize} + + \def\svgwidth{1cm} + \input{face_cry.pdf_tex} + \begin{itemize} + \item Owncloud/Nextcloud + \end{itemize} + + \def\svgwidth{1cm} + \input{face_happy.pdf_tex} + \begin{itemize} + \item Syncthing + \end{itemize} +\end{frame} + +\begin{frame} + \frametitle{``Easy to use'' říkají} + \includegraphics[width=11cm]{syncthing.png} +\end{frame} + +\begin{frame} + \frametitle{Matematický problém} + Přidání zařízení mezi N synchronizujících M složek. + + \begin{itemize} + \item Nastav nové zařízení + \item $N$-krát přidej zařízení + \item $N$-krát spáruj s novým zařízením + \item $N \times M$ přidej k synchronizovaným složkám + \item $M$-krát přidej složku na novém zařízení + \end{itemize} + + \vspace{0.4cm} + \[ + 1+\left(M+2\right)N+M + \] +\end{frame} + +\begin{frame} + \frametitle{Moje zařízení} + \def\svgwidth{27cm} + \input{scheme.pdf_tex} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Syncthing konfigurace hodně zjednodušeně} + \small + \begin{minted}{xml} + + + + + + + + + + +
dynamic
+
+ +
tcp://cynerd.cz
+
+
+\end{minted} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Napiš si skript, vstupní data} + \begin{minted}{bash} +# Syncthing PC id +ID="0000000-0000000-0000000-0000000-.." +# Name of machine +NAME="cynerd-pc" +# Address to machine, can be tcp://address.com or dynamic +ADDRESS="dynamic" + +# Directoris to be synchronized +# Format is ID:PATH +DIRS="Sync:/home/user/Sync +Sync2:/home/user/SyncIt" + +# REST api key +APIKEY="bT6dCxEds9JPwiXMXavGNsXsz7ZFpSC5" +\end{minted} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Napiš si skript, generuj zařízení do XML} + \begin{minted}{bash} +# ... +for h in syncthing/*; do + +. "$h" # Source host +# Set to configuration +echo "" >>$TMPCNF +echo "
$ADDRESS
" >>$TMPCNF +echo "
" >>$TMPCNF +# Parse DIRS of this host +eval `echo "$DIRS" | sed -ne \ +'s/^\([^:]*\):.*$/ST_DIR_HOSTS_\1="$ST_DIR_HOSTS_\1 $ID"/p'` + +done +# ... +\end{minted} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Napiš si skript, generuj složky do XML} + \begin{minted}{bash} +# ... +. syncthing/"$HOST" +while read -r d; do +NM="$(echo "$d" | sed 's/:.*$//')" # Directory name +PTH="$(echo "$d" | sed 's/^[^:]*://')" # Get target path +# Write folder init +echo "" >>$TMPCNF +# Specify every all devices +for dev in eval `echo \$ST_DIR_HOSTS_$NM`; do + echo "" >>$TMPCNF +done +# ... +done <<<"$DIRS" +# ... +\end{minted} +\end{frame} + +\begin{frame} + \frametitle{Moje řešení} + + \begin{itemize} + \item Nastav nové zařízení + \item Přidej do sdílené konfigurace + \item N-krát deploy konfigurace + \end{itemize} + + \vspace{0.4cm} + \[ + 2+N < 1+\left(M+2\right)N+M + \] +\end{frame} + +\begin{frame} + \frametitle{Synchronizace konfigurace} + \includegraphics[width=3cm]{git.eps} + + \vspace{1cm} + \begin{block}{\$HOME dot soubory} + 3 zařízení 3 různé požadavky + \begin{itemize} + \item Laptop, OpenRC, Bumblebee, 2 disky + \item Laptop, OpenRC + \item Desktop, Systemd + \end{itemize} + \end{block} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Skriptujeme jednoduše} + \begin{minted}{bash} +# install.sh +cd `dirname $0` +rsync -rlpt bashrc ~/.bashrc +rsync -rlpt profile ~/.profile + + +# get.sh +cd `dirname $0` +rsync -rlpt ~/.bashrc bashrc +rsync -rlpt ~/.profile profile +\end{minted} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Skriptujeme s vimdiff} + \begin{minted}{bash} +cd `dirname $0` +checkdiff() { + for f in `find "$1" -type f`; do + if ! cmp "$1" "$f" >/dev/null; then + F="${f#$1}" + vimdiff "$1/$F" "$2/$F" + fi + done +} +inst() { + [ -e "$2" ] && checkdiff "$1" "$2" \ + || rsync -rlpt "$1" "$2" +} +inst bashrc ~/.bashrc +\end{minted} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Skriptujeme skupinky} + \begin{minted}{bash} +# ... + +read -p "Install bashrc? (Y/n) " +if [[ $REPLY =~ ^[Yy]?$ ]]; then + inst bashrc ~/.bashrc + inst profile ~/.profile +fi + +read -p "Install VIM scripts? (Y/n) " +if [[ $REPLY =~ ^[Yy]?$ ]]; then + inst vimrc ~/.vimrc + inst vim ~/.vim +fi + +\end{minted} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Balíčky jako konfigurace} + Pro Archlinux: + \begin{minted}{bash} +sudo pacman -D --asdeps pkg +sudo pacman -D --asexplicit pkg +\end{minted} + + \begin{minted}{bash} +m4 archlinux.pkgs | sort | uniq > /tmp/file1 +pacaur -Qqe | sort > /tmp/file2 +diff --supppress-common-lines -ay /tmp/file1 /tmp/file2 +\end{minted} +\end{frame} + +\begin{frame} + \frametitle{Závěrem} + \begin{itemize} + \item Jeden git repositář s konfigurací + \item Skript pro přesun změn v konfiguračních souborech z a do repositáře + \item Skript porotnání explicitně nainstalovaných balíčků + \item Skript pro generování Syncthing konfigurace + \end{itemize} +\end{frame} + +\begin{frame} + \begin{block}{\large Děkuji za pozornost} + \end{block} + \url{https://github.com/Cynerd/myconfigs} + % TODO +\end{frame} + +\end{document} diff --git a/2017-installfest/scheme.svg b/2017-installfest/scheme.svg new file mode 100644 index 0000000..d0ab1c8 --- /dev/null +++ b/2017-installfest/scheme.svg @@ -0,0 +1,1170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/2017-installfest/scheme/Gorilla-server.svg b/2017-installfest/scheme/Gorilla-server.svg new file mode 100644 index 0000000..7fab2d9 --- /dev/null +++ b/2017-installfest/scheme/Gorilla-server.svg @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/2017-installfest/scheme/Laptop_font_awesome.svg b/2017-installfest/scheme/Laptop_font_awesome.svg new file mode 100644 index 0000000..edd1dea --- /dev/null +++ b/2017-installfest/scheme/Laptop_font_awesome.svg @@ -0,0 +1,59 @@ + + + + + + image/svg+xml + + + + + + + + + + diff --git a/2017-installfest/scheme/desktop-computer-with-screen-vector-icon.eps b/2017-installfest/scheme/desktop-computer-with-screen-vector-icon.eps new file mode 100644 index 0000000..7b7d251 Binary files /dev/null and b/2017-installfest/scheme/desktop-computer-with-screen-vector-icon.eps differ diff --git a/2017-installfest/scheme/smartphone-call.svg b/2017-installfest/scheme/smartphone-call.svg new file mode 100644 index 0000000..a9b0186 --- /dev/null +++ b/2017-installfest/scheme/smartphone-call.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/2017-installfest/scheme/turris_omnia.png b/2017-installfest/scheme/turris_omnia.png new file mode 100644 index 0000000..d89d93c Binary files /dev/null and b/2017-installfest/scheme/turris_omnia.png differ diff --git a/2017-installfest/syncthing.png b/2017-installfest/syncthing.png new file mode 100644 index 0000000..d644c4a Binary files /dev/null and b/2017-installfest/syncthing.png differ diff --git a/2017-linuxdays/Makefile b/2017-linuxdays/Makefile new file mode 100644 index 0000000..0c3c782 --- /dev/null +++ b/2017-linuxdays/Makefile @@ -0,0 +1,10 @@ +FILE=pres + +$(FILE).pdf: $(FILE).tex $(patsubst %.svg,%.pdf,$(wildcard *.svg)) + pdflatex -shell-escape $< + +%.pdf: %.svg + inkscape -D -z --file=$< --export-pdf=$@ --export-latex + +clean: + ls | grep -v -E "($(FILE).tex|Makefile|theme|svg|png|eps)$$" | xargs rm -rf diff --git a/2017-linuxdays/pres.pdf b/2017-linuxdays/pres.pdf new file mode 100644 index 0000000..c937487 Binary files /dev/null and b/2017-linuxdays/pres.pdf differ diff --git a/2017-linuxdays/pres.tex b/2017-linuxdays/pres.tex new file mode 100644 index 0000000..a2f5f87 --- /dev/null +++ b/2017-linuxdays/pres.tex @@ -0,0 +1,475 @@ +\documentclass{beamer} +\usepackage{lmodern} +\usepackage[czech]{babel} +\usepackage[utf8x]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{textpos} +\usepackage{tikz,calc} +\usepackage{graphicx} +\usepackage{wrapfig} +\usepackage{color} +\usepackage{mathtools} +\usepackage{hyperref} +\usepackage{epstopdf} +\usepackage{amsmath} +\usepackage{minted} +\hypersetup{ + colorlinks, + citecolor=black, + filecolor=black, + linkcolor=black, + urlcolor=black +} +\usepackage{pdflscape} + +\input{theme/theme.tex} + +\title{Tipy a triky nejenom v shellu nejenom pro programátory} +\author{Karel Kočí} +\date{8.10.2017} + +\AtBeginSection[]{ + \begin{frame} + \tableofcontents[currentsection] + \end{frame} +} + +\begin{document} + +\input{theme/title.tex} + +\begin{frame}[fragile]{O čem to bude?} + \begin{minted}[frame=lines]{shell} +sed 's/[^\;]*\;//' hist | tr ' ' '\n' | \ + grep -vE '^(-|\||$)' | sort | uniq -c | \ + sort -nr > notes/tatnppvl.result + \end{minted} + \begin{tabular}{r|l|r|l|r|l} \hline + 3004 & ls & 2391 & cd & 2225 & git \\ \hline + 1350 & v & 911 & sudo & 608 & tig \\ \hline + 458 & emerge & 410 & push & 405 & ssh \\ \hline + 393 & .. & 381 & gst & 372 & ci \\ \hline + 320 & add & 303 & vim & 285 & make \\ \hline + 285 & grep & 282 & rm & 247 & man \\ \hline + 203 & . & 191 & co & 189 & sed \\ \hline + 172 & @world & 159 & ./build\_repo.sh & 156 & omnia \\ \hline + 150 & updater & 148 & mpv & 140 & turris/openwrt \\ \hline + 138 & mount & 124 & cp & 120 & test \\ \hline + 119 & pull & 112 & ip & 109 & turtetris/Makefile \\ \hline + \end{tabular} +\end{frame} + +\section[Section]{Jen shell} + +\begin{frame}[fragile]{MAN MAN MAN MAN MAN} + \begin{minted}[frame=lines]{shell} +man man +man exit +man 3 exit + \end{minted} + Z man man: + \begin{enumerate} + \item Spustitelný program nebo shell příkaz + \item Volání systému (funkce z kernelu) + \item Knihovní volání (funkce poskytované knihovnami) + \item Speciální soubory (obvykle soubory z /dev) + \item Souborové formáty a konvence (například /etc/passwd) + \item Hry + \item Různorodé (Konvence, makra a pod.) + \item Příkazy pro systémovou administraci (obvykle sbin) + \end{enumerate} +\end{frame} + +\begin{frame}[fragile]{Náhled na soubory} + \begin{block}{ll} + Pro přístupová práva, vlastníky i velikost. + \begin{minted}[frame=lines]{shell} +alias ll='ls -lh' + \end{minted} + \end{block} + \begin{block}{tree} + Pro stromovou strukturu. + \end{block} +\end{frame} + +\begin{frame}[fragile]{Připisované soubory} + \begin{block}{tail -f} + \begin{minted}[frame=lines]{shell} +sudo tail -f /var/log/messages + \end{minted} + \end{block} +\end{frame} + +\begin{frame}[fragile]{Opakované spuštění} + \begin{block}{while true; do sleep 1; \emph{command}; done} + Pro sledování a pod. Například ip address. + \end{block} + \begin{block}{dorepeat} + \begin{minted}[frame=lines]{shell} +dorepeat() { + while true; do + "$@" + sleep 1 + echo + done +} + \end{minted} + \end{block} +\end{frame} + +\begin{frame}[fragile]{Hledání souborů} + \begin{block}{find -name -delete} + \begin{minted}[frame=lines]{shell} +find -name *elf* +find -name *.orig -delete + \end{minted} + \end{block} +\end{frame} + +\begin{frame}[fragile]{Hledání souborů podle obsahu} + \begin{block}{grep -Rn PATTERN} + \begin{minted}[frame=lines]{shell} +grep -Rn elfutils +grep -RnE 'elf-?utils' + \end{minted} + \end{block} +\end{frame} + +\begin{frame}[fragile]{Hledání podle obsahu ve specifických souborech} + \begin{minted}[frame=lines]{shell} +find -name Makefile | xargs grep -Rn elfutils + \end{minted} +\end{frame} + +\begin{frame}[fragile]{Náhodné heslo} + \begin{block}{genpasswd} + \begin{minted}[frame=lines]{shell} +genpasswd() { + local l=$1 + [ -n "$l" ] || l=16 + tr -dc A-Za-z0-9_ < /dev/urandom \ + | head -c "$l" | xargs +} + \end{minted} + \end{block} +\end{frame} + +\section[Section]{X server} + +\begin{frame}[fragile]{Clipboard} + \begin{block}{xclip -selection clipboard} + \begin{minted}[frame=lines]{shell} +cat .ssh/id_rsa.pub | xclip -selection clipboard + \end{minted} + \end{block} + \begin{block}{clip} + \begin{minted}[frame=lines]{shell} +clip() { + # Note: printf is magic to remove trailing new lines + printf %s "$(cat)" | xclip -selection clipboard +} + \end{minted} + \end{block} +\end{frame} + +\begin{frame}[fragile]{Screenshot} + \begin{block}{xshot} + \begin{minted}[frame=lines]{shell} +xshot() { + import -window "$(xdotool selectwindow)" \ + ~/xshot_$(date +%F_%H%M%S_%N).png +} + \end{minted} + \end{block} +\end{frame} + +\section[Section]{Git} + +\begin{frame}[fragile]{Git aliases} + \begin{block}{git co ci br wt} + \textasciitilde/.gitconfig + \begin{minted}[frame=lines]{ini} +[alias] + co = checkout + ci = commit + st = status + br = branch + wt = worktree + \end{minted} + \end{block} + \begin{block}{gst} + \begin{minted}[frame=lines]{shell} +alias gst='git status' + \end{minted} + \end{block} +\end{frame} + +\begin{frame}[fragile]{Verbose commits} + \textasciitilde/.gitconfig + \begin{minted}[frame=lines]{ini} +[commit] + verbose = true + \end{minted} + \begin{verbatim} +# Changes to be committed: +# modified: utils/localrepo +# ------------------------ >8 ------------------------ +diff --git a/utils/localrepo b/utils/localrepo + HELP_DESCRIPTION = """ +- Local opkg repository management script. ++ Local opkg repository management tool. + """ + \end{verbatim} +\end{frame} + +\begin{frame}[fragile]{git worktree} + \begin{block}{git worktree add} + \begin{minted}[frame=lines]{shell} +git branch work-todo +git worktree add ../project-work-todo work-todo + \end{minted} + \end{block} + \begin{block}{git worktree prune} + \begin{minted}[frame=lines]{shell} +rm -rf ../project-work-done +git worktree prune + \end{minted} + \end{block} +\end{frame} + +\begin{frame}[fragile]{Git hash $\to$ clipboard} + \begin{block}{gitclip} + \begin{minted}[frame=lines]{shell} +gitclip() { + [ -n "$1" ] && local CMT="$1" || local CMT=HEAD + git rev-parse "$CMT"| clip +} + \end{minted} + \end{block} + \begin{block}{gitmclip} + \begin{minted}[frame=lines]{shell} +gitmclip() { + [ -n "$1" ] && local CMT="$1" || local CMT=HEAD + git log --format=%B -n 1 "$CMT" | clip +} + \end{minted} + \end{block} +\end{frame} + +\begin{frame}[fragile]{gitbmerge} + \begin{minted}[frame=lines]{shell} +gitbmerge() { + ( + set -e + local WT="$(git worktree list \ + | sed -nE "/\[$1\]/{s/([^ ]+) .*/\1/p}")" + if [ -n "$WT" ]; then + rm -r "$WT" + git worktree prune + fi + git merge --ff-only "$1" && \ + git push && git branch -d "$1" \ + && git push origin :"$1" + ) +} + \end{minted} +\end{frame} + +\section[Section]{Stahování} + +\begin{frame}[fragile]{Zpracování obsahu pomocí shellu} + \begin{block}{curl HREF | tar -xzf -} + \begin{minted}[frame=lines]{shell} +curl http://repo.turris.cz/turris/OpenWrt-SDK.tar.bz2 \ + | tar -xzf - + \end{minted} + \end{block} + \begin{block}{curl -s HREF | grep -n} + \begin{minted}[frame=lines]{shell} +curl -s http://repo.turris.cz/turris/lists/base.lua \ + | grep -n updater-ng + \end{minted} + \end{block} + Nikdy! \begin{verbatim}curl HREF | sh -s\end{verbatim} +\end{frame} + +\begin{frame}[fragile]{Stažení všeho ze serveru} + \begin{block}{wget -r --no-parent (-l1)} + \begin{minted}[frame=lines]{shell} +wget -r --no-parent \ + http://repo.turris.cz/turris/packages/ + \end{minted} + \end{block} +\end{frame} + +\section[Section]{SSH} + +\begin{frame}[fragile]{Spuštění příkazu na několika hostech} + \begin{minted}[frame=lines]{shell} +ROUTERS="1 159 189 156 104 199 135 171 244 172" +I=0 +for R in $ROUTERS; do + echo "=== Runnining on 192.168.1.$R ===" + + ssh -i ~/router root@192.168.1.$R -- $@ + + #scp -i ~/router user.lua \ + # root@192.168.1.$R:/etc/updater/user.lua + + #ssh -i ~/router root@192.168.1.$R \ + # -- uci set turtetris.line=$I + #I=$(expr $I + 1) +done + \end{minted} +\end{frame} + +\begin{frame}[fragile]{Port forward} + \begin{minted}[frame=lines]{shell} +ssh host -L 8484:localhost:8384 + \end{minted} +\end{frame} + +\begin{frame}[fragile]{SOCKS proxy} + \begin{minted}[frame=lines]{shell} +ssh host -D 8123 + \end{minted} +\end{frame} + +\begin{frame}[fragile]{Trvalé připojení} + \begin{block}{cmd} + \begin{minted}[frame=lines]{shell} +ssh host -o ControlMaster=auto \ + -o ControlPath=$MCNF_DIR/.ssh_access/%r@%h:%p \ + -o ControlPersist=600 + \end{minted} + \end{block} + \begin{block}{ssh config} + \begin{minted}[frame=lines]{shell} +Host * + ControlMaster auto + ControlPath .cache/ssh/%r@%h:%p + ControlPersist 600 + \end{minted} + \end{block} +\end{frame} + +\section[Section]{Bash (Zsh) a emulátor terminálu} + +\begin{frame}[fragile]{Prompt a exit code} + \begin{minted}[frame=lines]{shell} +PROMPT_COMMAND=' +EC=$? +if [[ $EC < 0 ]]; then + echo -e "\e[1;31m"EXIT: $EC"\e[0m" +elif [[ $EC > 0 ]]; then + echo -e "\e[1;33m"EXIT: $EC"\e[0m" +fi' + \end{minted} +\end{frame} + +\begin{frame}[fragile]{Xterm (urxvt) title} + \begin{minted}[frame=lines]{shell} +function settitle { + echo -ne "\033]0;`whoami`@`hostname`:`pwd`\007" +} +case "$TERM" in + xterm*|*rxvt*) + trap 'settitle' DEBUG + ;; +esac + \end{minted} +\end{frame} + +\begin{frame}[fragile]{Zsh upozornění od dlouho-běžícího procesu} + \tiny + \begin{minted}[frame=lines]{shell} +lrbell_duration=15 +lrbell_timestamp=$EPOCHSECONDS +lrbell_window_id=0x0 +lrbell_active_window_id() { + xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2 +} +lrbell_begin() { + lrbell_timestamp=$EPOCHSECONDS + lrbell_message="`pwd`: $1" + if [ -n "$DISPLAY" ]; then + lrbell_window_id=$(lrbell_active_window_id) + fi +} +lrbell_end() { + (( $EPOCHSECONDS - $lrbell_timestamp < $lrbell_duration )) && return 0 + print -n '\a' + if [ -n "$DISPLAY" ] && [ -n "$lrbell_window_id" ]; then + if [ "$(lrbell_active_window_id)" != "$lrbell_window_id" ]; then + notify-send "Command finished" "$lrbell_message" + fi + fi +} +add-zsh-hook preexec lrbell_begin +add-zsh-hook precmd lrbell_end + \end{minted} + \url{https://github.com/rcaloras/bash-preexec} +\end{frame} + +\section[Section]{Bash doplňování} + +\begin{frame}[fragile]{Jednoduchý příklad} + \scriptsize + \begin{minted}[frame=lines]{shell} +_sterm() { + local cur prev + _init_completion || return + COMPREPLY=() + local ops="-h --help -c -d -e -n -r -s -v" + case "$prev" in + -d|-r) + ;; + -s) + local speeds="2400 4800 9600 19200 38400 57600 115200 230400" + COMPREPLY+=($(compgen -W "${speeds}" -- ${cur})) + ;; + *) + COMPREPLY+=($(compgen -W "${ops}" -- ${cur})) + ;; + esac +} +complete -o default -F _sterm sterm + \end{minted} +\end{frame} + +\begin{frame}[fragile]{gitbmerge doplňování} + \scriptsize + \begin{minted}[frame=lines]{shell} +_gitbmerge() { + local cur prev + _init_completion || return + [ $COMP_CWORD -gt 1 ] && return # Complete only single dependency + COMPREPLY=() + local GDIR="$(pwd)" + while [ ! -d "$GDIR/.git" ]; do + [ -z "$GDIR" ] && return + GDIR="${GDIR%/*}" + done + GDIR="$GDIR/.git" + [ -f "$GDIR" ] && GDIR="$(cat "$GDIR")" + [ -d "$GDIR/refs/heads" ] || return + local ops="" + for B in "$GDIR"/refs/heads/*; do + ops="$ops ${B#$GDIR/refs/heads/}" + done + COMPREPLY+=($(compgen -W "${ops}" -- ${cur})) +} +complete -F _gitbmerge gitbmerge + \end{minted} +\end{frame} + + +\begin{frame} + \Huge A jaké tipy máte vy? + + \Large Děkuji za pozornost. + + % Poznamka ze vse je take pro zsh v mem gitu +\end{frame} + +\end{document} diff --git a/2017-linuxdays/theme/cznic-cz.pdf b/2017-linuxdays/theme/cznic-cz.pdf new file mode 100644 index 0000000..8434d23 Binary files /dev/null and b/2017-linuxdays/theme/cznic-cz.pdf differ diff --git a/2017-linuxdays/theme/cznic-en.pdf b/2017-linuxdays/theme/cznic-en.pdf new file mode 100644 index 0000000..6208787 Binary files /dev/null and b/2017-linuxdays/theme/cznic-en.pdf differ diff --git a/2017-linuxdays/theme/nicbottom.pdf b/2017-linuxdays/theme/nicbottom.pdf new file mode 100644 index 0000000..2bc41c7 Binary files /dev/null and b/2017-linuxdays/theme/nicbottom.pdf differ diff --git a/2017-linuxdays/theme/nictop.pdf b/2017-linuxdays/theme/nictop.pdf new file mode 100644 index 0000000..153c065 Binary files /dev/null and b/2017-linuxdays/theme/nictop.pdf differ diff --git a/2017-linuxdays/theme/theme.tex b/2017-linuxdays/theme/theme.tex new file mode 100644 index 0000000..12bb169 --- /dev/null +++ b/2017-linuxdays/theme/theme.tex @@ -0,0 +1,42 @@ +% vim: ft=tex + +\definecolor{cznicblue}{RGB}{0,56,145} +\definecolor{cznicred}{RGB}{204,18,38} + +\setbeamertemplate{frametitle}{ + \begin{textblock}{100}[0,0](0.0,1.1) + \insertframetitle + \end{textblock} +} + +\defbeamertemplate*{footline}{CZ.NIC}{ + \begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.125ex, + leftskip=.3cm,rightskip=.3cm plus1fil]{bottom} + + \parbox{\linewidth}{\vspace*{-8pt}\hfill\insertpagenumber/\inserttotalframenumber} + + \includegraphics[width=8cm,keepaspectratio]{theme/nicbottom.pdf} + \hspace{0.5cm} + \includegraphics[width=3.5cm,keepaspectratio]{theme/cznic-cz.pdf} + \end{beamercolorbox} +} + +\defbeamertemplate*{title page}{CZ.NIC}[1][]{ + \usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle\par + \usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par + \bigskip + \usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor\par + \usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute\par + % Commenting out following lines hides date from first slide + \usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate\par + \usebeamercolor[fg]{titlegraphic}\inserttitlegraphic +} + +\setbeamercolor{structure}{fg=cznicred} +\setbeamercolor{title}{fg=cznicblue} +\setbeamercolor{subtitle}{fg=cznicred} +\setbeamercolor{frametitle}{fg=cznicblue} +\setbeamercolor{author}{fg=cznicblue} +\setbeamercolor{date}{fg=cznicblue} + +\beamertemplatenavigationsymbolsempty diff --git a/2017-linuxdays/theme/title.tex b/2017-linuxdays/theme/title.tex new file mode 100644 index 0000000..d4de9f5 --- /dev/null +++ b/2017-linuxdays/theme/title.tex @@ -0,0 +1,14 @@ +% vim: ft=tex + +\begingroup +\setbeamertemplate{headline} +{ + \begin{beamercolorbox}[wd=\paperwidth,ht=1.5cm,dp=1.125ex, + leftskip=.3cm,rightskip=.3cm plus1fil]{top} + \includegraphics[width=12cm,keepaspectratio]{theme/nictop.pdf} + \end{beamercolorbox} +} + +\frame{\titlepage} + +\endgroup diff --git a/README.md b/README.md index 91a8afd..2eb8892 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ My talks Tipy a triky nejenom v shellu nejenom pro programátory (2017 Linuxday) ----------------------------------------------------------------------- [Video](https://www.youtube.com/watch?v=ePb4WfQayaA) -[pdf](http://git.cynerd.cz/presentations/plain/installfest2017/pres.pdf) +[pdf](http://git.cynerd.cz/presentations/plain/2017-linuxdays/pres.pdf) 3 problémy při práci na 3 počítačích (2017 Installfest) ------------------------------------------------------- [Video](https://www.youtube.com/watch?v=Ta8ntjCVmvQ&t=1s) -[pdf](http://git.cynerd.cz/presentations/plain/linuxdays2017/pres.pdf) +[pdf](http://git.cynerd.cz/presentations/plain/2017-installfest/pres.pdf) diff --git a/installfest2017/face_cry.svg b/installfest2017/face_cry.svg deleted file mode 100644 index 9e8837f..0000000 --- a/installfest2017/face_cry.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/installfest2017/face_happy.svg b/installfest2017/face_happy.svg deleted file mode 100644 index 6bc7f73..0000000 --- a/installfest2017/face_happy.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/installfest2017/face_sad.svg b/installfest2017/face_sad.svg deleted file mode 100644 index 8c4a4c1..0000000 --- a/installfest2017/face_sad.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/installfest2017/git.eps b/installfest2017/git.eps deleted file mode 100644 index 47500ce..0000000 Binary files a/installfest2017/git.eps and /dev/null differ diff --git a/installfest2017/makefile b/installfest2017/makefile deleted file mode 100644 index 9ab8f60..0000000 --- a/installfest2017/makefile +++ /dev/null @@ -1,10 +0,0 @@ -FILE=pres - -$(FILE).pdf: $(FILE).tex $(patsubst %.svg,%.pdf,$(wildcard *.svg)) - pdflatex -shell-escape $< - -%.pdf: %.svg - inkscape -D -z --file=$< --export-pdf=$@ --export-latex - -clean: - ls | grep -v -E "($(FILE).tex|makefile|scheme|svg|png|eps)$$" | xargs rm -rf diff --git a/installfest2017/pres.pdf b/installfest2017/pres.pdf deleted file mode 100644 index af41431..0000000 Binary files a/installfest2017/pres.pdf and /dev/null differ diff --git a/installfest2017/pres.tex b/installfest2017/pres.tex deleted file mode 100644 index 1c36c4c..0000000 --- a/installfest2017/pres.tex +++ /dev/null @@ -1,304 +0,0 @@ -\documentclass{beamer} -\usetheme{metropolis} -\usepackage{lmodern} -\usepackage[czech]{babel} -\usepackage[utf8x]{inputenc} -%\usepackage[utf8]{inputenc} -\usepackage[T1]{fontenc} -\usepackage{graphicx} -\usepackage{wrapfig} -\usepackage{color} -\usepackage{mathtools} -\usepackage{hyperref} -\usepackage{epstopdf} -\usepackage{svg} -\usepackage{amsmath} -\usepackage{minted} -\hypersetup{ - colorlinks, - citecolor=black, - filecolor=black, - linkcolor=black, - urlcolor=black -} -\usepackage{pdflscape} - -\title{3 problémy při práci na 3 počítačích} -\author{Karel Kočí} -\date{4.3.2017} - -\begin{document} - -\frame{\titlepage} - -\begin{frame} - \begin{block}{\huge Napiš si skript!} - Přednášené skripty a více naleznete na: - \url{https://github.com/Cynerd/myconfigs} - \end{block} -\end{frame} - -\begin{frame} - \frametitle{3 problémy} - \begin{itemize} - \item Synchronizace souborů - \item Synchronizace a správa konfigurací - \item Správa systému - \end{itemize} -\end{frame} - -\begin{frame} - \frametitle{Synchronizace souborů} - \def\svgwidth{1cm} - \input{face_sad.pdf_tex} - \begin{itemize} - \item Dropbox - \item Mega - \item Google drive - \item \ldots - \end{itemize} - - \def\svgwidth{1cm} - \input{face_cry.pdf_tex} - \begin{itemize} - \item Owncloud/Nextcloud - \end{itemize} - - \def\svgwidth{1cm} - \input{face_happy.pdf_tex} - \begin{itemize} - \item Syncthing - \end{itemize} -\end{frame} - -\begin{frame} - \frametitle{``Easy to use'' říkají} - \includegraphics[width=11cm]{syncthing.png} -\end{frame} - -\begin{frame} - \frametitle{Matematický problém} - Přidání zařízení mezi N synchronizujících M složek. - - \begin{itemize} - \item Nastav nové zařízení - \item $N$-krát přidej zařízení - \item $N$-krát spáruj s novým zařízením - \item $N \times M$ přidej k synchronizovaným složkám - \item $M$-krát přidej složku na novém zařízení - \end{itemize} - - \vspace{0.4cm} - \[ - 1+\left(M+2\right)N+M - \] -\end{frame} - -\begin{frame} - \frametitle{Moje zařízení} - \def\svgwidth{27cm} - \input{scheme.pdf_tex} -\end{frame} - -\begin{frame}[fragile] - \frametitle{Syncthing konfigurace hodně zjednodušeně} - \small - \begin{minted}{xml} - - - - - - - - - - -
dynamic
-
- -
tcp://cynerd.cz
-
-
-\end{minted} -\end{frame} - -\begin{frame}[fragile] - \frametitle{Napiš si skript, vstupní data} - \begin{minted}{bash} -# Syncthing PC id -ID="0000000-0000000-0000000-0000000-.." -# Name of machine -NAME="cynerd-pc" -# Address to machine, can be tcp://address.com or dynamic -ADDRESS="dynamic" - -# Directoris to be synchronized -# Format is ID:PATH -DIRS="Sync:/home/user/Sync -Sync2:/home/user/SyncIt" - -# REST api key -APIKEY="bT6dCxEds9JPwiXMXavGNsXsz7ZFpSC5" -\end{minted} -\end{frame} - -\begin{frame}[fragile] - \frametitle{Napiš si skript, generuj zařízení do XML} - \begin{minted}{bash} -# ... -for h in syncthing/*; do - -. "$h" # Source host -# Set to configuration -echo "" >>$TMPCNF -echo "
$ADDRESS
" >>$TMPCNF -echo "
" >>$TMPCNF -# Parse DIRS of this host -eval `echo "$DIRS" | sed -ne \ -'s/^\([^:]*\):.*$/ST_DIR_HOSTS_\1="$ST_DIR_HOSTS_\1 $ID"/p'` - -done -# ... -\end{minted} -\end{frame} - -\begin{frame}[fragile] - \frametitle{Napiš si skript, generuj složky do XML} - \begin{minted}{bash} -# ... -. syncthing/"$HOST" -while read -r d; do -NM="$(echo "$d" | sed 's/:.*$//')" # Directory name -PTH="$(echo "$d" | sed 's/^[^:]*://')" # Get target path -# Write folder init -echo "" >>$TMPCNF -# Specify every all devices -for dev in eval `echo \$ST_DIR_HOSTS_$NM`; do - echo "" >>$TMPCNF -done -# ... -done <<<"$DIRS" -# ... -\end{minted} -\end{frame} - -\begin{frame} - \frametitle{Moje řešení} - - \begin{itemize} - \item Nastav nové zařízení - \item Přidej do sdílené konfigurace - \item N-krát deploy konfigurace - \end{itemize} - - \vspace{0.4cm} - \[ - 2+N < 1+\left(M+2\right)N+M - \] -\end{frame} - -\begin{frame} - \frametitle{Synchronizace konfigurace} - \includegraphics[width=3cm]{git.eps} - - \vspace{1cm} - \begin{block}{\$HOME dot soubory} - 3 zařízení 3 různé požadavky - \begin{itemize} - \item Laptop, OpenRC, Bumblebee, 2 disky - \item Laptop, OpenRC - \item Desktop, Systemd - \end{itemize} - \end{block} -\end{frame} - -\begin{frame}[fragile] - \frametitle{Skriptujeme jednoduše} - \begin{minted}{bash} -# install.sh -cd `dirname $0` -rsync -rlpt bashrc ~/.bashrc -rsync -rlpt profile ~/.profile - - -# get.sh -cd `dirname $0` -rsync -rlpt ~/.bashrc bashrc -rsync -rlpt ~/.profile profile -\end{minted} -\end{frame} - -\begin{frame}[fragile] - \frametitle{Skriptujeme s vimdiff} - \begin{minted}{bash} -cd `dirname $0` -checkdiff() { - for f in `find "$1" -type f`; do - if ! cmp "$1" "$f" >/dev/null; then - F="${f#$1}" - vimdiff "$1/$F" "$2/$F" - fi - done -} -inst() { - [ -e "$2" ] && checkdiff "$1" "$2" \ - || rsync -rlpt "$1" "$2" -} -inst bashrc ~/.bashrc -\end{minted} -\end{frame} - -\begin{frame}[fragile] - \frametitle{Skriptujeme skupinky} - \begin{minted}{bash} -# ... - -read -p "Install bashrc? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then - inst bashrc ~/.bashrc - inst profile ~/.profile -fi - -read -p "Install VIM scripts? (Y/n) " -if [[ $REPLY =~ ^[Yy]?$ ]]; then - inst vimrc ~/.vimrc - inst vim ~/.vim -fi - -\end{minted} -\end{frame} - -\begin{frame}[fragile] - \frametitle{Balíčky jako konfigurace} - Pro Archlinux: - \begin{minted}{bash} -sudo pacman -D --asdeps pkg -sudo pacman -D --asexplicit pkg -\end{minted} - - \begin{minted}{bash} -m4 archlinux.pkgs | sort | uniq > /tmp/file1 -pacaur -Qqe | sort > /tmp/file2 -diff --supppress-common-lines -ay /tmp/file1 /tmp/file2 -\end{minted} -\end{frame} - -\begin{frame} - \frametitle{Závěrem} - \begin{itemize} - \item Jeden git repositář s konfigurací - \item Skript pro přesun změn v konfiguračních souborech z a do repositáře - \item Skript porotnání explicitně nainstalovaných balíčků - \item Skript pro generování Syncthing konfigurace - \end{itemize} -\end{frame} - -\begin{frame} - \begin{block}{\large Děkuji za pozornost} - \end{block} - \url{https://github.com/Cynerd/myconfigs} - % TODO -\end{frame} - -\end{document} diff --git a/installfest2017/scheme.svg b/installfest2017/scheme.svg deleted file mode 100644 index d0ab1c8..0000000 --- a/installfest2017/scheme.svg +++ /dev/null @@ -1,1170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/installfest2017/scheme/Gorilla-server.svg b/installfest2017/scheme/Gorilla-server.svg deleted file mode 100644 index 7fab2d9..0000000 --- a/installfest2017/scheme/Gorilla-server.svg +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/installfest2017/scheme/Laptop_font_awesome.svg b/installfest2017/scheme/Laptop_font_awesome.svg deleted file mode 100644 index edd1dea..0000000 --- a/installfest2017/scheme/Laptop_font_awesome.svg +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - diff --git a/installfest2017/scheme/desktop-computer-with-screen-vector-icon.eps b/installfest2017/scheme/desktop-computer-with-screen-vector-icon.eps deleted file mode 100644 index 7b7d251..0000000 Binary files a/installfest2017/scheme/desktop-computer-with-screen-vector-icon.eps and /dev/null differ diff --git a/installfest2017/scheme/smartphone-call.svg b/installfest2017/scheme/smartphone-call.svg deleted file mode 100644 index a9b0186..0000000 --- a/installfest2017/scheme/smartphone-call.svg +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/installfest2017/scheme/turris_omnia.png b/installfest2017/scheme/turris_omnia.png deleted file mode 100644 index d89d93c..0000000 Binary files a/installfest2017/scheme/turris_omnia.png and /dev/null differ diff --git a/installfest2017/syncthing.png b/installfest2017/syncthing.png deleted file mode 100644 index d644c4a..0000000 Binary files a/installfest2017/syncthing.png and /dev/null differ diff --git a/linuxdays2017/Makefile b/linuxdays2017/Makefile deleted file mode 100644 index 0c3c782..0000000 --- a/linuxdays2017/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -FILE=pres - -$(FILE).pdf: $(FILE).tex $(patsubst %.svg,%.pdf,$(wildcard *.svg)) - pdflatex -shell-escape $< - -%.pdf: %.svg - inkscape -D -z --file=$< --export-pdf=$@ --export-latex - -clean: - ls | grep -v -E "($(FILE).tex|Makefile|theme|svg|png|eps)$$" | xargs rm -rf diff --git a/linuxdays2017/pres.pdf b/linuxdays2017/pres.pdf deleted file mode 100644 index c937487..0000000 Binary files a/linuxdays2017/pres.pdf and /dev/null differ diff --git a/linuxdays2017/pres.tex b/linuxdays2017/pres.tex deleted file mode 100644 index a2f5f87..0000000 --- a/linuxdays2017/pres.tex +++ /dev/null @@ -1,475 +0,0 @@ -\documentclass{beamer} -\usepackage{lmodern} -\usepackage[czech]{babel} -\usepackage[utf8x]{inputenc} -\usepackage[T1]{fontenc} -\usepackage{textpos} -\usepackage{tikz,calc} -\usepackage{graphicx} -\usepackage{wrapfig} -\usepackage{color} -\usepackage{mathtools} -\usepackage{hyperref} -\usepackage{epstopdf} -\usepackage{amsmath} -\usepackage{minted} -\hypersetup{ - colorlinks, - citecolor=black, - filecolor=black, - linkcolor=black, - urlcolor=black -} -\usepackage{pdflscape} - -\input{theme/theme.tex} - -\title{Tipy a triky nejenom v shellu nejenom pro programátory} -\author{Karel Kočí} -\date{8.10.2017} - -\AtBeginSection[]{ - \begin{frame} - \tableofcontents[currentsection] - \end{frame} -} - -\begin{document} - -\input{theme/title.tex} - -\begin{frame}[fragile]{O čem to bude?} - \begin{minted}[frame=lines]{shell} -sed 's/[^\;]*\;//' hist | tr ' ' '\n' | \ - grep -vE '^(-|\||$)' | sort | uniq -c | \ - sort -nr > notes/tatnppvl.result - \end{minted} - \begin{tabular}{r|l|r|l|r|l} \hline - 3004 & ls & 2391 & cd & 2225 & git \\ \hline - 1350 & v & 911 & sudo & 608 & tig \\ \hline - 458 & emerge & 410 & push & 405 & ssh \\ \hline - 393 & .. & 381 & gst & 372 & ci \\ \hline - 320 & add & 303 & vim & 285 & make \\ \hline - 285 & grep & 282 & rm & 247 & man \\ \hline - 203 & . & 191 & co & 189 & sed \\ \hline - 172 & @world & 159 & ./build\_repo.sh & 156 & omnia \\ \hline - 150 & updater & 148 & mpv & 140 & turris/openwrt \\ \hline - 138 & mount & 124 & cp & 120 & test \\ \hline - 119 & pull & 112 & ip & 109 & turtetris/Makefile \\ \hline - \end{tabular} -\end{frame} - -\section[Section]{Jen shell} - -\begin{frame}[fragile]{MAN MAN MAN MAN MAN} - \begin{minted}[frame=lines]{shell} -man man -man exit -man 3 exit - \end{minted} - Z man man: - \begin{enumerate} - \item Spustitelný program nebo shell příkaz - \item Volání systému (funkce z kernelu) - \item Knihovní volání (funkce poskytované knihovnami) - \item Speciální soubory (obvykle soubory z /dev) - \item Souborové formáty a konvence (například /etc/passwd) - \item Hry - \item Různorodé (Konvence, makra a pod.) - \item Příkazy pro systémovou administraci (obvykle sbin) - \end{enumerate} -\end{frame} - -\begin{frame}[fragile]{Náhled na soubory} - \begin{block}{ll} - Pro přístupová práva, vlastníky i velikost. - \begin{minted}[frame=lines]{shell} -alias ll='ls -lh' - \end{minted} - \end{block} - \begin{block}{tree} - Pro stromovou strukturu. - \end{block} -\end{frame} - -\begin{frame}[fragile]{Připisované soubory} - \begin{block}{tail -f} - \begin{minted}[frame=lines]{shell} -sudo tail -f /var/log/messages - \end{minted} - \end{block} -\end{frame} - -\begin{frame}[fragile]{Opakované spuštění} - \begin{block}{while true; do sleep 1; \emph{command}; done} - Pro sledování a pod. Například ip address. - \end{block} - \begin{block}{dorepeat} - \begin{minted}[frame=lines]{shell} -dorepeat() { - while true; do - "$@" - sleep 1 - echo - done -} - \end{minted} - \end{block} -\end{frame} - -\begin{frame}[fragile]{Hledání souborů} - \begin{block}{find -name -delete} - \begin{minted}[frame=lines]{shell} -find -name *elf* -find -name *.orig -delete - \end{minted} - \end{block} -\end{frame} - -\begin{frame}[fragile]{Hledání souborů podle obsahu} - \begin{block}{grep -Rn PATTERN} - \begin{minted}[frame=lines]{shell} -grep -Rn elfutils -grep -RnE 'elf-?utils' - \end{minted} - \end{block} -\end{frame} - -\begin{frame}[fragile]{Hledání podle obsahu ve specifických souborech} - \begin{minted}[frame=lines]{shell} -find -name Makefile | xargs grep -Rn elfutils - \end{minted} -\end{frame} - -\begin{frame}[fragile]{Náhodné heslo} - \begin{block}{genpasswd} - \begin{minted}[frame=lines]{shell} -genpasswd() { - local l=$1 - [ -n "$l" ] || l=16 - tr -dc A-Za-z0-9_ < /dev/urandom \ - | head -c "$l" | xargs -} - \end{minted} - \end{block} -\end{frame} - -\section[Section]{X server} - -\begin{frame}[fragile]{Clipboard} - \begin{block}{xclip -selection clipboard} - \begin{minted}[frame=lines]{shell} -cat .ssh/id_rsa.pub | xclip -selection clipboard - \end{minted} - \end{block} - \begin{block}{clip} - \begin{minted}[frame=lines]{shell} -clip() { - # Note: printf is magic to remove trailing new lines - printf %s "$(cat)" | xclip -selection clipboard -} - \end{minted} - \end{block} -\end{frame} - -\begin{frame}[fragile]{Screenshot} - \begin{block}{xshot} - \begin{minted}[frame=lines]{shell} -xshot() { - import -window "$(xdotool selectwindow)" \ - ~/xshot_$(date +%F_%H%M%S_%N).png -} - \end{minted} - \end{block} -\end{frame} - -\section[Section]{Git} - -\begin{frame}[fragile]{Git aliases} - \begin{block}{git co ci br wt} - \textasciitilde/.gitconfig - \begin{minted}[frame=lines]{ini} -[alias] - co = checkout - ci = commit - st = status - br = branch - wt = worktree - \end{minted} - \end{block} - \begin{block}{gst} - \begin{minted}[frame=lines]{shell} -alias gst='git status' - \end{minted} - \end{block} -\end{frame} - -\begin{frame}[fragile]{Verbose commits} - \textasciitilde/.gitconfig - \begin{minted}[frame=lines]{ini} -[commit] - verbose = true - \end{minted} - \begin{verbatim} -# Changes to be committed: -# modified: utils/localrepo -# ------------------------ >8 ------------------------ -diff --git a/utils/localrepo b/utils/localrepo - HELP_DESCRIPTION = """ -- Local opkg repository management script. -+ Local opkg repository management tool. - """ - \end{verbatim} -\end{frame} - -\begin{frame}[fragile]{git worktree} - \begin{block}{git worktree add} - \begin{minted}[frame=lines]{shell} -git branch work-todo -git worktree add ../project-work-todo work-todo - \end{minted} - \end{block} - \begin{block}{git worktree prune} - \begin{minted}[frame=lines]{shell} -rm -rf ../project-work-done -git worktree prune - \end{minted} - \end{block} -\end{frame} - -\begin{frame}[fragile]{Git hash $\to$ clipboard} - \begin{block}{gitclip} - \begin{minted}[frame=lines]{shell} -gitclip() { - [ -n "$1" ] && local CMT="$1" || local CMT=HEAD - git rev-parse "$CMT"| clip -} - \end{minted} - \end{block} - \begin{block}{gitmclip} - \begin{minted}[frame=lines]{shell} -gitmclip() { - [ -n "$1" ] && local CMT="$1" || local CMT=HEAD - git log --format=%B -n 1 "$CMT" | clip -} - \end{minted} - \end{block} -\end{frame} - -\begin{frame}[fragile]{gitbmerge} - \begin{minted}[frame=lines]{shell} -gitbmerge() { - ( - set -e - local WT="$(git worktree list \ - | sed -nE "/\[$1\]/{s/([^ ]+) .*/\1/p}")" - if [ -n "$WT" ]; then - rm -r "$WT" - git worktree prune - fi - git merge --ff-only "$1" && \ - git push && git branch -d "$1" \ - && git push origin :"$1" - ) -} - \end{minted} -\end{frame} - -\section[Section]{Stahování} - -\begin{frame}[fragile]{Zpracování obsahu pomocí shellu} - \begin{block}{curl HREF | tar -xzf -} - \begin{minted}[frame=lines]{shell} -curl http://repo.turris.cz/turris/OpenWrt-SDK.tar.bz2 \ - | tar -xzf - - \end{minted} - \end{block} - \begin{block}{curl -s HREF | grep -n} - \begin{minted}[frame=lines]{shell} -curl -s http://repo.turris.cz/turris/lists/base.lua \ - | grep -n updater-ng - \end{minted} - \end{block} - Nikdy! \begin{verbatim}curl HREF | sh -s\end{verbatim} -\end{frame} - -\begin{frame}[fragile]{Stažení všeho ze serveru} - \begin{block}{wget -r --no-parent (-l1)} - \begin{minted}[frame=lines]{shell} -wget -r --no-parent \ - http://repo.turris.cz/turris/packages/ - \end{minted} - \end{block} -\end{frame} - -\section[Section]{SSH} - -\begin{frame}[fragile]{Spuštění příkazu na několika hostech} - \begin{minted}[frame=lines]{shell} -ROUTERS="1 159 189 156 104 199 135 171 244 172" -I=0 -for R in $ROUTERS; do - echo "=== Runnining on 192.168.1.$R ===" - - ssh -i ~/router root@192.168.1.$R -- $@ - - #scp -i ~/router user.lua \ - # root@192.168.1.$R:/etc/updater/user.lua - - #ssh -i ~/router root@192.168.1.$R \ - # -- uci set turtetris.line=$I - #I=$(expr $I + 1) -done - \end{minted} -\end{frame} - -\begin{frame}[fragile]{Port forward} - \begin{minted}[frame=lines]{shell} -ssh host -L 8484:localhost:8384 - \end{minted} -\end{frame} - -\begin{frame}[fragile]{SOCKS proxy} - \begin{minted}[frame=lines]{shell} -ssh host -D 8123 - \end{minted} -\end{frame} - -\begin{frame}[fragile]{Trvalé připojení} - \begin{block}{cmd} - \begin{minted}[frame=lines]{shell} -ssh host -o ControlMaster=auto \ - -o ControlPath=$MCNF_DIR/.ssh_access/%r@%h:%p \ - -o ControlPersist=600 - \end{minted} - \end{block} - \begin{block}{ssh config} - \begin{minted}[frame=lines]{shell} -Host * - ControlMaster auto - ControlPath .cache/ssh/%r@%h:%p - ControlPersist 600 - \end{minted} - \end{block} -\end{frame} - -\section[Section]{Bash (Zsh) a emulátor terminálu} - -\begin{frame}[fragile]{Prompt a exit code} - \begin{minted}[frame=lines]{shell} -PROMPT_COMMAND=' -EC=$? -if [[ $EC < 0 ]]; then - echo -e "\e[1;31m"EXIT: $EC"\e[0m" -elif [[ $EC > 0 ]]; then - echo -e "\e[1;33m"EXIT: $EC"\e[0m" -fi' - \end{minted} -\end{frame} - -\begin{frame}[fragile]{Xterm (urxvt) title} - \begin{minted}[frame=lines]{shell} -function settitle { - echo -ne "\033]0;`whoami`@`hostname`:`pwd`\007" -} -case "$TERM" in - xterm*|*rxvt*) - trap 'settitle' DEBUG - ;; -esac - \end{minted} -\end{frame} - -\begin{frame}[fragile]{Zsh upozornění od dlouho-běžícího procesu} - \tiny - \begin{minted}[frame=lines]{shell} -lrbell_duration=15 -lrbell_timestamp=$EPOCHSECONDS -lrbell_window_id=0x0 -lrbell_active_window_id() { - xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2 -} -lrbell_begin() { - lrbell_timestamp=$EPOCHSECONDS - lrbell_message="`pwd`: $1" - if [ -n "$DISPLAY" ]; then - lrbell_window_id=$(lrbell_active_window_id) - fi -} -lrbell_end() { - (( $EPOCHSECONDS - $lrbell_timestamp < $lrbell_duration )) && return 0 - print -n '\a' - if [ -n "$DISPLAY" ] && [ -n "$lrbell_window_id" ]; then - if [ "$(lrbell_active_window_id)" != "$lrbell_window_id" ]; then - notify-send "Command finished" "$lrbell_message" - fi - fi -} -add-zsh-hook preexec lrbell_begin -add-zsh-hook precmd lrbell_end - \end{minted} - \url{https://github.com/rcaloras/bash-preexec} -\end{frame} - -\section[Section]{Bash doplňování} - -\begin{frame}[fragile]{Jednoduchý příklad} - \scriptsize - \begin{minted}[frame=lines]{shell} -_sterm() { - local cur prev - _init_completion || return - COMPREPLY=() - local ops="-h --help -c -d -e -n -r -s -v" - case "$prev" in - -d|-r) - ;; - -s) - local speeds="2400 4800 9600 19200 38400 57600 115200 230400" - COMPREPLY+=($(compgen -W "${speeds}" -- ${cur})) - ;; - *) - COMPREPLY+=($(compgen -W "${ops}" -- ${cur})) - ;; - esac -} -complete -o default -F _sterm sterm - \end{minted} -\end{frame} - -\begin{frame}[fragile]{gitbmerge doplňování} - \scriptsize - \begin{minted}[frame=lines]{shell} -_gitbmerge() { - local cur prev - _init_completion || return - [ $COMP_CWORD -gt 1 ] && return # Complete only single dependency - COMPREPLY=() - local GDIR="$(pwd)" - while [ ! -d "$GDIR/.git" ]; do - [ -z "$GDIR" ] && return - GDIR="${GDIR%/*}" - done - GDIR="$GDIR/.git" - [ -f "$GDIR" ] && GDIR="$(cat "$GDIR")" - [ -d "$GDIR/refs/heads" ] || return - local ops="" - for B in "$GDIR"/refs/heads/*; do - ops="$ops ${B#$GDIR/refs/heads/}" - done - COMPREPLY+=($(compgen -W "${ops}" -- ${cur})) -} -complete -F _gitbmerge gitbmerge - \end{minted} -\end{frame} - - -\begin{frame} - \Huge A jaké tipy máte vy? - - \Large Děkuji za pozornost. - - % Poznamka ze vse je take pro zsh v mem gitu -\end{frame} - -\end{document} diff --git a/linuxdays2017/theme/cznic-cz.pdf b/linuxdays2017/theme/cznic-cz.pdf deleted file mode 100644 index 8434d23..0000000 Binary files a/linuxdays2017/theme/cznic-cz.pdf and /dev/null differ diff --git a/linuxdays2017/theme/cznic-en.pdf b/linuxdays2017/theme/cznic-en.pdf deleted file mode 100644 index 6208787..0000000 Binary files a/linuxdays2017/theme/cznic-en.pdf and /dev/null differ diff --git a/linuxdays2017/theme/nicbottom.pdf b/linuxdays2017/theme/nicbottom.pdf deleted file mode 100644 index 2bc41c7..0000000 Binary files a/linuxdays2017/theme/nicbottom.pdf and /dev/null differ diff --git a/linuxdays2017/theme/nictop.pdf b/linuxdays2017/theme/nictop.pdf deleted file mode 100644 index 153c065..0000000 Binary files a/linuxdays2017/theme/nictop.pdf and /dev/null differ diff --git a/linuxdays2017/theme/theme.tex b/linuxdays2017/theme/theme.tex deleted file mode 100644 index 12bb169..0000000 --- a/linuxdays2017/theme/theme.tex +++ /dev/null @@ -1,42 +0,0 @@ -% vim: ft=tex - -\definecolor{cznicblue}{RGB}{0,56,145} -\definecolor{cznicred}{RGB}{204,18,38} - -\setbeamertemplate{frametitle}{ - \begin{textblock}{100}[0,0](0.0,1.1) - \insertframetitle - \end{textblock} -} - -\defbeamertemplate*{footline}{CZ.NIC}{ - \begin{beamercolorbox}[wd=\paperwidth,ht=2.5ex,dp=1.125ex, - leftskip=.3cm,rightskip=.3cm plus1fil]{bottom} - - \parbox{\linewidth}{\vspace*{-8pt}\hfill\insertpagenumber/\inserttotalframenumber} - - \includegraphics[width=8cm,keepaspectratio]{theme/nicbottom.pdf} - \hspace{0.5cm} - \includegraphics[width=3.5cm,keepaspectratio]{theme/cznic-cz.pdf} - \end{beamercolorbox} -} - -\defbeamertemplate*{title page}{CZ.NIC}[1][]{ - \usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle\par - \usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par - \bigskip - \usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor\par - \usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute\par - % Commenting out following lines hides date from first slide - \usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate\par - \usebeamercolor[fg]{titlegraphic}\inserttitlegraphic -} - -\setbeamercolor{structure}{fg=cznicred} -\setbeamercolor{title}{fg=cznicblue} -\setbeamercolor{subtitle}{fg=cznicred} -\setbeamercolor{frametitle}{fg=cznicblue} -\setbeamercolor{author}{fg=cznicblue} -\setbeamercolor{date}{fg=cznicblue} - -\beamertemplatenavigationsymbolsempty diff --git a/linuxdays2017/theme/title.tex b/linuxdays2017/theme/title.tex deleted file mode 100644 index d4de9f5..0000000 --- a/linuxdays2017/theme/title.tex +++ /dev/null @@ -1,14 +0,0 @@ -% vim: ft=tex - -\begingroup -\setbeamertemplate{headline} -{ - \begin{beamercolorbox}[wd=\paperwidth,ht=1.5cm,dp=1.125ex, - leftskip=.3cm,rightskip=.3cm plus1fil]{top} - \includegraphics[width=12cm,keepaspectratio]{theme/nictop.pdf} - \end{beamercolorbox} -} - -\frame{\titlepage} - -\endgroup -- cgit v1.2.3