Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Text Tools

Text Tools

Reintroducing text tools you might have forgotten.
LaTeX, Ditaa, Gnuplot, the Graphviz Family (dot, neato...)

Sylvain Abélard

July 01, 2014
Tweet

More Decks by Sylvain Abélard

Other Decks in Programming

Transcript

  1. 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.
  2. Text formatting .txt .md .tex You know plain text and

    probably know markdown. (@happynoff published mustdown and a talk about it)
  3. \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?
  4. 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...
  5. 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.
  6. Gnuplot Same here. I know and used a lot of

    JS graphs. What if you just want PNGs (or SVGs) for consistency?
  7. 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.
  8. 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?
  9. 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
  10. Graphviz How would you make this class-like diagram? You’d generate

    simple text files, run it, and ship the docs!
  11. 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!
  12. Queries sed awk find If you skipped on these, do

    yourself a favor: learn them. They’re everywhere, and they’ll save your ***
  13. 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!
  14. 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? ;)