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

Don't use Ruby!

Marcin Kulik
November 17, 2012

Don't use Ruby!

My RuPy Brno 2012 conf talk about using the right tool for the right job.

On the examples of building blocks of http://ascii.io/ I show when to consider using other, well established technologies, getting out of the "Ruby tunnel vision".

Marcin Kulik

November 17, 2012
Tweet

More Decks by Marcin Kulik

Other Decks in Programming

Transcript

  1. YOU MAY KNOW ME FROM: racksh, ascii.io, git-dude, vim-pasta, bitpocket,

    coloration, stderred... All of them available at https://github.com/sickill/
  2. "Recording the work in your terminal with screen capture software

    and serving it as a video is like recording your text reply as an .mp3 file and sending it via email" - Me.
  3. # man script NAME script — make typescript of terminal

    session DESCRIPTION script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).
  4. # man scriptreplay NAME scriptreplay - play back typescripts, using

    timing information DESCRIPTION This program replays a typescript, using timing information to ensure that output happens at the same speed as it originally appeared when the script was recorded.
  5. "ASCII.IO is the simplest way to record your terminal and

    share the recordings with your fellow geeks. Simply record and upload your terminal session with single command, and ASCII.IO will play it back in your browser."
  6. it has its STDIN and STDOUT connected to the terminal

    app it forks and execs shell in child process it gets file descriptors for spawned process' STDIN and STDOUT it proxies STDIN and STDOUT and saves STDOUT to a file
  7. --XTerm--------------------------- | | | --outer bash---------------- | | | |

    | | | --script-------------- | | | | | | | | | | | --inner bash---- | | | | | | | | | | | | | | | $ | | | | | | | ---------------- | | | | | | | | | | | ---------------------- | | | | | | | ---------------------------- | | | ----------------------------------
  8. works on both Linux and OSX has minimum dependencies has

    simplest possible installation is targetted not only at Rubyists
  9. script.py then! ~400 LOC no dependencies records STDOUT + timing

    info saves env info ($TERM, $SHELL...) uploads
  10. Renderers 2 AVAILABLE NOW: <pre> , with "copy & paste"

    <canvas> , faster, no "copy & paste" TODO: WebGL based one
  11. thumbnail is just a text generation happens in background after

    uploading takes terminal snapshot at 10 sec mark
  12. "tmux is a terminal multiplexer: it enables a number of

    terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached."
  13. $ man tmux capture-pane [-b buffer-index] [-E end-line] [-S start-line]

    [-t target-pane] Capture the contents of a pane to the specified buffer, or a new buffer if none is specified.
  14. $ man tmux save-buffer [-a] [-b buffer-index] path Save the

    contents of the specified paste buffer to path. The -a option appends to rather than overwriting the file.
  15. BACKGROUND JOB THAT: creates new, detached tmux session runs `scriptreplay`

    in it waits for 10 sec runs `tmux capture-pane` runs `tmux save-buffer`
  16. // app/jobs/capture_job.rb class CaptureJob def self.perform(...) ... system "tmux new

    -s $SESS_ID -d -x $X -y $Y 'scriptreplay ....'" sleep 10 system "tmux capture-pane -t $SESS_ID" text = `tmux save-buffer -` system "tmux kill-session -t $SESS_ID &>/dev/null" ... end end
  17. // script/capture.sh #!/bin/bash ... tmux new -s $SESS_ID -d -x

    $COLS -y $LINES "scriptreplay ...." sleep 10 tmux capture-pane -t $SESS_ID tmux save-buffer - tmux kill-session -t $SESS_ID &>/dev/null
  18. # end of .bashrc if [ -z "$RECORDING" ]; then

    export RECORDING=1 ASCII_IO_API_URL=http://localhost:3000 exec asciiio -y fi Thx @roy & @_solnic_ !