coding and such

I’ve been coding for the last few days, and it’s been fun.

A month or two back I wrote code that exported the HeavyInk product database to Google Products. That had rotted a bit, and I got it working again.

Then I ported the code over to SmartFlix and got it working to export our DVD inventory into Google Products. Then I realized that Google Base must have data tags to support customer reviews, and, yes, it does, so SmartFlix exports both products and reviews into the noosphere.

…then I brought that feature back over to HeavyInk. Of course, we’ve got a bifurcated database architecture, and customer reviews live in the website database, not the master database, so I extended the database bridge code to pull those as well, and extended the various OO models to connect the new reviews to customers, products, etc. There’s a certain kind of intellectual joy I get from tugging at a project and getting one loose string, then another, then a dozen, then two dozen…and then resolving one, then another, then another, and – after having a ton of balls in the air all at once (to mix metaphors), safely bringing each of them back to Earth.

I added some datamining code in so that in our SmartFlix newsletter tool we could see the average conversion rate, total revenue, etc. (our newsletter tool hacks all URLs that are embedded in outgoing newsletters to have click through codes, and we associate an initial URL with every shopping session, so by matching up click through codes from a newsletter to a shopping session, we can tell exactly what prompted someone to buy … and then we can compare the response rates to various newsletters to see what headlines, articles, etc., have the best pull).

I’m doing a long-term experiment with Google Ads where we run 50 variants of ad copy to see which pulls best (why 50 variants and not 100? Actually, I programmatically generated far more than 50 variants, but Google apparently expects marketing folks with browsers, not engineers with XML to upload variant ad copy). Based on reading marketing books, one bit of ad copy that I want to programmatically generate requires that video categories be expressed not as nouns or gerunds (e.g. “welding”, “oil painting”) but as verbs or infinitives (“to weld”, “paint with oils” or “oil paint”). (In case you’re curious, I want to run ads with copy like “learn to weld!”, etc.). We’ve got north of 200 categories, and as an experiment I wrote a bit of code that attempted to programmatically generate the verbs from maybe 25% of the category names, but we really need a mechanical turk, so I also wrote a new view into the data to allow our Jack-of-all-Trades guy at work to enter these in by hand.

We’ve had a bit of turnover last month (three folks left the company, three folks joined), and it was getting to be a hassle to change the recipient lists of various automated emails (e.g. “the following shipments from vendors are overdue”; “the following creditors need to be paid”; “we need to update the depreciation figures on the books using the following code-generated values”; etc.). Why was it a hassle? Because I had to edit the crontab files, svn commit them, ssh to a server, svn update the files, then feed them into cron.

…and we’ve got multiple not-actually-a-person accounts crossed with multiple servers, so there are lots of files, and it’s just a pain, and horrible.

…so I wrote a migration to add email recipient bits to every employee in our database, then changed the cron jobs to not expect email recipients on the command line, but to instead pull them from the database at run time, then I added a view to allow me to edit the recipient bits on each person.

It was satisfying.

I did a few other things (some coding, some non-coding) as well

All in all, it’s been a hectic two days since the week started.

Thank goodness there’s a burrito 13 hours in my future.

4 Responses to “coding and such”

  1. brian Says:

    changed the cron jobs to not expect email recipients on the command line, but to instead pull them from the database at run time,

    I’m trying, and failing, to see how you do that.

    I’ve got a shell script in crontab

    30 10 2 * * $HOME/bin/foo.sh

    The last line in foo.sh is

    uuencode $file $attach | mailx -s "foo report" $to

    $to is a variable declared earlier in the shell script – my Plexus email address. How do I tell foo.sh to grab a value from a database?

  2. tjic Says:

    I edit the scripts themselves.

    In the cron file I replace


    30 10 2 * * $HOME/bin/foo.sh -sendmailto tjic

    with


    30 10 2 * * $HOME/bin/foo.sh

    and in the script (Ruby), I replace


    puts "output" # write to stdout

    with something like


    ActionMailer.send_mail("fromaddr", Person.find(:all, :conditions => "email_bit_foobar = 1").join(","), "subject line", "body")

  3. brian Says:

    Dang – thought there was a clever bit of shell scriptery going on.

    On the other hand – I should save that for later.

  4. Max Lybbert Says:

    And this is why I won’t ever actually own a successful business. All of the tasks you listed seem to be obviously valuable after they’re explained, but starting at point A I doubt that I would have come up with any of them.

    Even after dealing with lots of cron jobs, I would have likely alleviated the problem with mailing lists. But that isn’t as elegant a solution.