Share
Embed
Text Tools
Reintroducing text tools you might have forgotten.
LaTeX, Ditaa, Gnuplot, the Graphviz Family (dot, neato...)
Sylvain Abélard
July 01, 2014
Transcript
16 slides
-
It’s all text! - Write it - Copy it -
Paste it - Store it - Upgrade it - Share it - Git it - Convert it - Standard it - Generate it Text is awesome because you can do all of this quickly, easily, and while singing to Daft Punk. -
Table Of Contents Text formatting Diagrams Plots Toolbox Here are
a few use cases I’d like to help with. -
Text formatting .txt .md .tex You know plain text and
probably know markdown. (@happynoff published mustdown and a talk about it) -
\LaTeX \documentclass{minimal} \begin{document} \[\sum_{n=1}^{+\infty}\frac{1}{n^2}= \frac{\pi^2}{6}.\] \end{document} LaTeX is like a
program by Don Knuth to produce docs. LaTeX loves science and math. Isn’t it beautiful? -
Ditaa If you generate docs, you might want to include
diagrams. It would be a pain to do it in HTML, but what if this... -
Ditaa +--------+ +-------+ +-------+ | | --+ ditaa +--> |
| | Text | +-------+ |diagram| |Document| |!magic!| | | | {d}| | | | | +---+----+ +-------+ +-------+ : ^ | Lots of work | +-------------------------+ Could be generated out of this? It’s DITAA magic! Super cool for the notes you took during the meeting. -
Gnuplot Same here. I know and used a lot of
JS graphs. What if you just want PNGs (or SVGs) for consistency? -
Gnuplot set multiplot layout 3, 1 title "Multiplot layout 3,
1" set tmargin 2 set title "Plot 1" unset key plot sin(x)/x # set title "Plot 2" unset key plot 'silver.dat' using 1:2 ti 'silver.dat' # set style histogram columns set style fill solid set key autotitle column set boxwidth 0.8 set format y " " set tics scale 0 set title "Plot 3" plot 'immigration.dat' using 2 with histograms, \ '' using 7 with histograms , \ '' using 8 with histograms , \ '' using 11 with histograms # unset multiplot Well here’s gnuplot: don’t be afraid, the syntax is simple. Here we got three graphs, and the magic is data loading. -
set multiplot layout 3, 1 title "Multiplot layout 3, 1"
set tmargin 2 set title "Plot 1" unset key plot sin(x)/x # set title "Plot 2" unset key plot 'silver.dat' using 1:2 ti 'silver.dat' # set style histogram columns set style fill solid set key autotitle column set boxwidth 0.8 set format y " " set tics scale 0 set title "Plot 3" plot 'immigration.dat' using 2 with histograms, \ '' using 7 with histograms , \ '' using 8 with histograms , \ '' using 11 with histograms # unset multiplot #2 options actual plot #1 options actual plot #3 options actual plot loading data So how does that compare to all the boilerplate you used to code just to use your super framework? -
Graphviz rg2->green2; yr2->safe1; yr2->red2; safe2->rg2; green2->gy2; yellow2->yr2; red2->rg2; gy1->yellow1; rg1->green1;
yr1->safe2; yr1->red1; safe1->rg1; green1->gy1; yellow1->yr1; red1->rg1; relations Here’s a state machine diagram. Automatic layout. All I did was just set up relations like nodeA -> nodeB -
Graphviz How would you make this class-like diagram? You’d generate
simple text files, run it, and ship the docs! -
Graphviz "node10" [ shape = "record" label = "<f0> (nil)|
<f1> | <f2> |-1" ]; "node11" [ shape = "record" label = "<f0> (nil)| <f1> | <f2> |-1" ]; "node0":f1 -> "node2":f0 [ id = 1 ]; "node1":f0 -> "node3":f0 [ id = 2 ]; define node content and options define node content and options define relations content and options It’s pretty easy to learn, and “just works”. Define nodes, define relations, you’re done! -
Queries sed awk find If you skipped on these, do
yourself a favor: learn them. They’re everywhere, and they’ll save your *** -
Queries http://stedolan.github.io/jq/tutorial/ https://github.com/ggreer/the_silver_searcher https://github.com/harelba/q gem list --local | ./q "select
c2 from -" If you got lazy and can only remember SQL syntax, wouldn’t it be nice to have this? Well you can! -
Questions? Thanks! @abelar_s // maitre-du-monde.fr Questions included “did you forget
cut, tr, grep?” Well if you know Ruby, you know these ones, right? ;)