January 2013 Archives

Put a fancy CPU/RAM usage chart in tmux status bar

Prologue

So, once upon a time I had a crazy idea: to put an almost complete resource meter into the tmux status bar. You know, the clock is so boring. Let's add a battery indicator there. And the load numbers. And the memory usage...

Needless to say, this resulted in an unbearable user experience:

a:2.96G c:4.37G f:5.41G i:2.98G l:0.65/1.73/1.41 23:47

Actually, the data is OK, the "gauges" work fine on every Unix I tested them. If only it was a bit fancier...

Puke rainbows!

Then I discovered Battery. And then, Spark. I just couldn't resist myself, so I revamped my messy Perl usage data parser to output this gorgeous ANSI art scrolling chart:

Screenshot

It was tested on Mac OS X 10.8.2, Ubuntu 12.04, Ubuntu 11.10, Debian 6.0.6 and works fine with the default system Perl; there are no external dependencies at all.

Liked it? Go ahead, grab your copy and follow the installation instructions: https://github.com/creaktive/rainbarf

Web Scraping with Modern Perl (Part 1)

tl;dr

Grab the gist with the complete, working source code.

I often hear the question: "so, you're Perl guy, could you show me how to make a web crawler/spider/scraper, then?" I hope this post series will become my ultimate answer :)

First of all, I compiled a small list of features that people expect of crawlers nowadays:

  1. capability of concurrent, persistent connections;
  2. usage of CSS selectors to process HTML;
  3. easily modifiable source instead of a flexible OOP inheritance structure;
  4. LESS DEPENDENCIES!

About stas

user-pic Just another lazy, impatient and arrogant IT guy.