Tubesock

I was digging into Browserify’s source recently, and all the streams inspired me to read through substack’s excellent stream-handbook again. That sparked an idea: what if you could pipe stdin to a process and have it come out of a WebSocket?

So I made Tubesock. Since it just reads from stdin, it’s flexible. For example, it can report the size of a compiled CSS file:

$ fswatch main.css |
  xargs -n1 wc -c |
  awk '{print $1; fflush();}' |
  tubesock

Or just graph random numbers (to make an example GIF, perhaps?):

$ while true; do
  ruby -e "puts rand(30) + 50";
  sleep 1;
  done | tubesock

If you install Tubesock, run the command above, and visit http://bars.mkndrsn.com, you’ll see something like this:

bars.mkndrsn.com

Tubesock is only a few days old, but keeping an eye on the graphs has already helped me catch some things that I never would have without it. So far I’ve been using it to send numbers over the WebSocket and graph them, but you could pass text or JSON just as easily. The flexibility of piping makes it easy to set up all sorts of toolchains. I’m excited to find more uses for Tubesock, and to improve the capabilities of bars.

Check it out on Github or npm, and feel free to open issues and pull requests!