Posts Tagged ‘gmail’

Perl Python and … cigars?

Saturday, February 20th, 2010

I just don’t have the heart to post this to my cigar blog. It just seems wrong.

Cigar Monster is a website that has hourly deals.  Great hourly deals.  But I don’t want to spend my days checking it, peeking over at five minutes after every hour.

What I want is to enter in to “something” a list of cigar brands and names I’m interested then have that something keep track for me and send me an email if I get a hit.  Then I can go look and see if the deal is worth hitting.

This is going to be a particularly important feature after my job starts next Wednesday (w00t!)

For about a month I was running Ubuntu on this box as it just seemed the right thing to keep my chops up, etc.

So I banged the script out in perl.  Took a couple more hours than I thought since my perl chops had atrophied a bit.  The code won’t win any awards, but it’s about 150 lines of relatively tight (yet still comprehensible) perl source.

Along the way I hit a snag.  Sending email through smtp on gmail is problematic because they use a TLS layer underneath smtp.  But between CPAN and linux, this error went away quickly.  Net::SMTP::TLS FTW!

And it was all happy nice nice.  The script just ran, checked every once in a while, sent me a message if there was a deal on PH 681s, Ashtons, and a couple other things. (The other interesting side effect is that it’s been accruing all the Cigar Monster deals for a few weeks which is actually an interesting table of data to look at.)

There are just too many things linux is a righteous pain in the ass about.  Filenames, music and media, etc.  So once I got the job offer I switched back, unplugging one SATA drive and plugging in the vista one.

That’s all fine and good since cygwin offers a “linux enough” environment for running my scripts generally.

The nice thing about the script was that it dumped data to a network repository (fancy way of csv file on a network attached drive) so when I switched back it ran in place.

Except, apparently, for the way perl library management works.  I just couldn’t get the TLS library to install under cygwin, so I tried going to ActiveState (the happy nice-nice native windows perl distro.)  Still… no go.

So I ended up rewriting the thing in python this morning (mostly.  Still have repository de-duping management to deal with.  Not exactly computer science, I just needed a break.)

I was hoping to use it as an inital ruby project, but I couldn’t find a clear answer on whether TLS was supported on an out of the box ruby install, so I bailed on it.  I may yet reconvert the thing.

SO yeah, there’s that.

Between screen-scraping the internet, watching for patterns, sending personal alerts (and having an engine for people to submit things they may be interested in) the resulting code is actually something I’ve found myself doing over and over again, so it’s time to start distilling it down to something consistent.  I’m not quite sure what will come out of it, but if I keep the refactoring clean and manage the code base such that it’s all in the same place, I should start seeing some interesting emerging libraries pretty quickly.

The trick for me is to not attempt to anticipate what form those things are going to take then try and over-engineer it.

It’s nice to be excited about software development again.