Posts Tagged ‘Perl’

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.

Scripting Language IDEs?

Tuesday, October 28th, 2008

Lately I’m finding myself doing an awful lot of large scripting projects lately in a variety of languages. PHP, Perl, Python and a smidge of Ruby as I try to figure out WTF the deal is.

I’m generally an XEmacs based programmer but I’ve got to say, I’m becoming spoiled by a lot of the advanced integrated features in modern compiled-language IDEs. The funky searching, code folding, refactoring, plug-in …err… ’stuff’ that’s in Eclipse, Visual Studio, Borland’s IDEs, IntelliJ, etc.

Any ideas? I might try and re-evaluate the Komodo IDE.

But maybe there are enough Eclipse plugins to make that worth trying. I don’t know though, eclipse is a bit big to wrap my head around casually.

date.8601 XMLRPC::Lite perl MetaWeblog

Friday, April 18th, 2008

Good christ this stuff is a headache. Perl has this wonderful module that allows you to build simple xmlrpc clients and servers very easily.

It looks at the structure of your request and figures out by the data type how to map it in to xml by playing data type guessing games.

Unless you pass it a date, which it treats as a string.

Now, xmlrpc has an explicit date type. So if you’re using XMLRPC::Lite to call an api method (for instance metaweblog.newPost) and pass it a date in the request structure (say, in the ‘dateCreated’ or ‘date_created_gmt’ fields), what the server gets isn’t the date field, it’s a string field, even though the contents are the same.

How to force it to call the thing a date I have no idea.
Currently I’m looking at rewriting the damn client in python.

But my eyes keep sliding over to my old (but pretty damn robust) c++ xmlrpc libraries. I could use that to generate a request and, if I was feeling lazy, just pipe the thing into curl or wget.