More permanent stuff at http://www.dusbabek.org/~garyd

13 December 2009

Christmas Mix 2009

I've been making  Christmas mixes for my family the last couple years.  It's not your typical Bing Crosby stuff, and requires some digging on my part.  I finally started blogging about it last year and think I'm going to make it a tradition.  So here goes... Christmas with an indie slant.  And I did a better job checking on the lyrics this year for family appropriateness.

The links this year are coming at you from Lala by way of Google.  Message me if things stop working.  (This blog post has turned out much like my Christmas shopping: it gets sloppy towards the end.)

1.  "Holiday Road" by Matt Pond PA.  This is the only repeat from last years list.  I love this song because the vacation movies still connect with me at a level I am entirely uncomfortable with. 

2.  "Blue Christmas" by Dread Zeppelin.  Believe it or not, there is a nice smattering of Christmas to choose from with these guys. Where else can you get Elvis, Led Zeppelin, Reggae and Christmas in one track?

3.  "Christmas is Going to the Dogs" by Eels.  Hard choice between this and "Everything's Gonna Be Cool This Christmas".

4.  "I Wish It Was Christmas Today"  by Julian Casablancas.  This one is for the kids.  I wish that I could still feel the way I did when I was a young boy after Thanksgiving.  Christmas, although only four weeks away, seemed like it sat on the other side of eternity.  As an adult, it comes and goes so fast I barely have time to enjoy it.  Message to kids: enjoy it while you can.  Responsibility steals the fun from Christmas!

5.  "Christmas Time is Here Again (Bring Out the Joy!)" by My Morning Jacket.  Peaceful.  I'll let you google for this one.  It's a live take from a radio broadcast.

6.  "Listening to Otis Redding at Home During Christmas" by Okkervil River.  Not a traditional Christmas tune, but a good one to follow MMJ, if only for the indie vibe.  This song reminds me of "New Slang" by The Shins, but with less jade and desperation.  Slightly more hopeful. :)

7.  "X-Mas Card" by MU330.  Not my normal thing, but the instrumental intro with the horns is fun.

8.  "Yule Shoot Your Eye Out" by Fall Out Boy.  If you haven't checked out "Can You See Santa From the Southside," now is the time to skedaddle over to Amazon and do so.

9.  "Baby, It's Cold Outside (Mulato Beat Remix)" by Louis Armstrong and Velma Middleton.  Shopko gave away a Christmas sampler in 2004 and this was on it.  This is, by far, the Christmas album that gets play in our house (not the one this song links to).  It comes on while we're preparing meals and we find ourselves breaking frequently to get our grooves on.  No kidding.  Six people from 2 to 35 shaking a leg in the kitchen.

10. "O Come All Ye Faithful" by Weezer.  Traditional Christmas tune done right by a modern band.

And some bonus songs from last years mix:

Bonus 1:  "Fairytale of New York" by the Pogues.  This one is definitely not for the kids and is a guilty pleasure of mine.  Who can resist: "You're a bum, you're a punk / You're an old slut on junk."  Ahh, the holidays.

Bonus 2:  "Frosty the Snowman" by the Cocteau Twins.  Year after year, my favorite Frosty rendition.

02 November 2009

Building Cassandra Thrift Bindings on OS X

A few weeks ago, I came to Rackspace to work full-time on Cassandra in their cloud division.  So far, I'm having fun and learning new things.  Apart from Cassandra, one of the projects I get to figure out is Thrift.  Thrift is a tool that allows you to define a service interface and then generate stubbed service bindings in different programming languages.  A programmer then takes the generated code and makes it do the things it is supposed to.  In an ideal world, this simplifies the process of, say, stubbing in a PHP client that can speak to a server stubbed in Java.

Right now, I'm the lone wolf in the office doing development on OS X.  The glitches so far have been minor, but I was forewarned that I might want to reconsider [using linux] when it came time to work with Thrift.  Well, that time started today.  I've been a faithful linux user for about 10 years, but I've been a faithful Mac user even longer.  I'm not ready to make the switch to full-time linux yet; I like my Mac.

Fortunately, Google was my friend when it came to figuring out the secrets of building Thrift on OS X.  Credit goes to Nathan Ostgard and his blog post for getting me going in the right direction.

1.  You definitely want to install macports.
2.  Install boost and log4j
sudo port install boost
sudo port install jakarta-log4j

3.  Download and install thrift
curl -o thrift.tgz "http://gitweb.thrift-rpc.org/?p=thrift.git;a=snapshot;h=HEAD;sf=tgz"
tar -xvf thrift.tgz
cd thrift
echo "thrift.extra.cpath = /opt/local/share/java/jakarta-log4j.jar" > ~/.thrift-build.properties
./bootstrap.sh
./configure --prefix=/opt/local

4.  You're going to get an error during configure:
./configure: line 16440: syntax error near unexpected token `MONO,'
./configure: line 16440: `  PKG_CHECK_MODULES(MONO, mono >= 2.0.0, net_3_5=yes, net_3_5=no)'

I couldn't figure out how to tell configure "no csharp, please" through the command line, so I just commented out lines 16439-16442 and ran configure again:

./configure --prefix=/opt/local

5.  You know the drill:
make
sudo make install

That's it for Thrift.  The next step is to generate the Cassandra client.  The Cassandra wiki has steps to generate a python client.  This works fine except that the thrift python module was installed to a place where the OS X python can't see it. You'll get the following error if you try to run Cassandra-remote:

Traceback (most recent call last):
  File "./Cassandra-remote", line 11, in
    from thrift.transport import TTransport
ImportError: No module named thrift.transport

There is probably a right way to fix this problem, a way that is right for OS X, but I had no patience.  I added the the following line to my ~/.profile:

export PYTHONPATH=/usr/lib/python2.6/site-packages

Restart terminal, navigate back to the directory where the python client was generated and try again.  Cassandra-remote should spew out a verbose usage directive.

That's it; you're done.

If you found this useful, or have feedback, please let me know.  I use gmail (gdusbabek).  I also emit the occasional tweet; just follow gdusbabek. 

If you're interested in learning more about Cassandra, there is an active and helpful IRC channel (#cassandra) on freenode and mailing lists as well.  The wiki also contains useful information for beginners.

14 September 2009

id3 for Python

I've been meaning to package up some python code I wrote earlier this year and release it for free as open source software.  Several things held me back from doing this.  The biggest reason, by far, is that I'm still not proficient at python, and feel like I'm exposing myself by putting this code out for the world to see.

But then I remembered that my blog doesn't have a lot of readers anyway.  So no worries there.  And besides, maybe I can garner some constructive criticism to make my python code better.  :)


http://www.dusbabek.org/~garyd/id3_python/

This library is capable of reading most any correct Id3v2.3 or 2.4 tag, some incorrect ones, and then fails gracefully when things get hopeless.  (I run smoke tests on my mp3 collection, which has a lot of nasty debris from the Napster years.) 

It supports unicode, and does a good job handing PIC/APIC tags.  I should also mention it is in production at Tagfriendly.

For those that do come across this, I'm still trying to figure something out.  All the documentation I've come across says that I should structure my directories as such:

MyModule/
    id3/
        __init__.py
        stuff.py
    setup.py
    tests.py

I include id3.py inside the id3/ directory because that's where I think it should go.  But then when I build and test the module, the only way I can access the code is if I import id3.id3, but I wish I only had to import id3.  Clearly, I'm not doing something right.

My solution, and I know this isn't right, is to do away with the id3/ directory altogether and just have id3.py rubbing elbows with setup.py and test.py.  Anyone know what gives?

Well, enough of all that... id3 for Python is available at http://www.dusbabek.org/~garyd/id3_python/.

P.S.  Thanks to my friends on IRC for reminding me about this.

31 August 2009

My New Workout

I have been attending the gym regularly, religiously even, for the last 10 years for early morning workouts.  What started out as short 20 minute workouts for an out-of-shape 25 year old have turned into 45 minute cardio sessions where I routinely burn 900 calories.  It's been a very good thing for me; I wouldn't trade it for the world.

When I started, I would bring headphones and watch the morning news.  Then began a succession of portable music players that started with a Diamond Rio 500, which I cherished, and culminated with the two iPods I currently use.  Over the last several years, gradually, the monotony of a daily workout began combining with my music against me, hampering my motivation.  Maybe I can chalk it up to age, or plateauing, but regardless of the cause: I needed to find something else.

I thought that an iPod video (30 GB) would help, but it turns out the screen is much to small to watch while the rest of my body is moving on a treadmill or elliptical machine.  (It is still great on an airplane though.)  I've been using an iPod shuffle for the last two years, alternating between general conference sessions and music.  I tried podcasts for a while, but the iPod has such a crappy podcast interface--you can't queue them up in a playlist, and I don't want to fiddle with buttons in the middle of my workout.

Total frustration.

Then something happened.  My gym began installing televisions on all the cardio equipment.  I thought my problem was solved--I'd be able to go back to just bringing a pair of headphones again.  That joy was short lived, as I realized that most of what's on television in the early morning is generally crap (informercials) and sometimes downright crude (infomercials for porn--no kidding!).  And the news is, well, frankly: not worth watching anymore.  Back to square one...

I don't know why it took so long for the idea to sink in, but I realized that I could connect my iPod video directly to the televisions on the cardio machines using a $5 composite cable I already owned (thank you, Sony), and watch my iPod videos on the TVs.  I finally gave it a try this morning.  I watched two TED talks, and an APM Marketplace podcast about high-frequency trading.  The best part is that when it was all over, my 45 minute workout felt like only 15 minutes had gone by! 

Undeniable WIN!

My next task is to find more podcasts that don't suck.  I've already found a decent language training podcast, but what would be really nice is to get a hold of some of the Google tech talks, as they are usually excellent and I don't mind watching them over (indeed, some of them ought to be watched multiple times to absorb the information).  I couldn't find them through the iTunes store, but maybe some kind soul has been kind enough to make them available on the outside.  Google, ironically, has not.  In fact, the Google tech talks are strewn across video.google.com and youtube.com now that Youtube is part of Google.  The older video.google videos are easily downloadable, but the Youtube ones are not.  At least, not without some real work.

Then again, there are enough [free] things at iTunes U to keep my mornings occupied for a long time.  They have a special section just for computer science educational content.  Double plus woot!

Anyway, all this is a long way of saying something short: iPod + cardio TV == excellent workout.

22 July 2009

Adventures in Javascript

Note: Blogger doesn't give me a good way to preview the image before it goes live.  If it is too small, my apologies.  I'll try to get that fixed before your news reader pulls the feed.

The Question
Sometimes I think programmers tend to accept things the way they are without really questioning them, especially when it comes to language quirks.  This is something I remember coming across when I was first learning Javascript.  I was reminded of it recently while reading a Javascript book.

Javascript pros will probably quickly recognize what's going on here.



At first I thought the third definition of MyFunc would wipe out the others.  And just to verify that declaring a function in that manner normally makes it into the assumed contexts, I did it with YourFunc.

What gives?

Go ahead, take a guess... 

The Answer
The interpreter evaluates standalone functions before the other expressions.  So it is as if 'function MyFunc...' were written before everything else.  This can be verified by calling MyFunc() in the first line of the script.  The expressions (which include assignments) are then evaluated.  So what appears as the second assignment of MyFunc is really the third, and the third is really first.

21 July 2009

My Take on Newspapers in America

I have read numerous articles and blog posts over the last 12 months about the decline of the newspaper industry.  Having spent a few years in the trenches myself, and having opinions on the matter, I thought I could add something to the discussion. 

A few things about me:  From 2000 to 2007 I worked as a programmer for Dgital Technology International (DTI), one of the leading newspaper software vendors (editorial and advertising) in North America and Europe.  I worked primarily on editorial products.  I have made roughly 25 visits to customer sites to perform troubleshooting or assist with software installations or upgrades.  So I have an insiders look about how newspapers operate, albeit with a technical slant.  I never learned much about how newspapers are run though.  That kind of knowledge would have made writing this easier.  If there are any inaccuracies (and there probably are), feel free to call me out on them, either in the comments or by way of email.

What is happening to newspapers?
To sum it up, the business is drying up.  Circulation numbers are in decline.  Whenever this happens, advertisers tend to pull back.  The result is a net loss of revenue. 

But why is this happening now?  Can it be blamed on the recession?  I was around during the last recession.  There was a lot of talk in 2001 and 2002 about newspapers going extinct then, since advertising rates had fallen and circulation was in decline, much like it is now.  In fact, the biggest difference between now and then is the severity of the problem.  For me, watching the Rocky Mountain News shut down operations really opened my eyes to the magnitude of the problem being faced by print journalists.

So if the slump can be blamed on the economy that would mean that circulation would probably not have declined during the good times.  Right?  Let's check the numbers.  I'll use the New York Times as a metric, even though it's not a good metric for the entire industry.  Here are the ups and downs of circulation starting in 1998.  I got these numbers from the NYTimes corporate site. 

1999: +2.2%,
2000: +1.3%,
2001: +0.1%,
2002: +3.8%,
2003: -5.3 %,
2004: +0.3%,
2005: +0.2%,
2006: +0.5%,
2007: -1.9 %,
2008: -3.9%,
2009: -3.5%

What I see here is one good year, a few years of stagnation, and a several years (the most recent ones) of significant decline.  I don't think the decline of readership can be based on economic factors; there must be something else.

Cultural shift?
Maybe we're changing as a people.  Unscientific guessing tells me that we're working more and doing more things (after all, we're multi-taskers).  We don't have time to read the paper in the morning or when we come home at night.  Further, when we do make it home, there are so many other things available to occupy us.  100+ channels on the tube, a backlog of events on the TiVo and this miraculous internet invention all await us.  There may be studies to support this, but I don't care.  This is my hypothesis and I'm running with it: less people read newspapers because they have too many other things to do, and those things are far more interactive.

What can newspapers do?
There are two obvious solutions.  The first is to cut costs.  The second is to get more readers.  Let's take a look at each one individually. 

First, cutting costs...  Running a newspaper isn't cheap.  There are reporters, editors, more editors, press operators, delivery people, circulation people and advertising people.  Some papers have gone web-only.  That eliminates the press operators and delivery people, and with the right software-a good chunk of the circulation department too.  Give a few good salespeople the right software and analytics and I think advertising and sales would be covered.  Could they skimp on reporters and editors--the real content producers?  I think so, to a degree.  See, if newspapers focused on local news and stopped trying to compete with CNN.com and USA Today for national and world coverage, I think they would be able to own that niche for some time.  Radio took a similar path on the advent of the television age when home listeners declined.  They found a niche to occupy (the car) and did well there for years.

Since I am in the software business, I'll go ahead and say that the software could be better.  I'm not referring to the quality of the software, but rather what it does and how it used.  For instance, at DTI we had release cycles of around 6 months.  Imagine waiting 6 months to see something like Twitter or Facebook integration, or integrating the latest Adobe CS suite.  Shortening that cycle would have been difficult from quality and cost perspectives.  By "better" I mean more nimble.  Smaller pieces working together instead of a monolithic suite.  It would be hard to do, but I think it could be done.

Next is readers: how do they get more readers?  My first suggestion is to reach out to them wherever they are--not just on their front lawns.  Smart phone adoption is on the rise.  I get a good chunk of news through my T-Mobile G1.  It is easy to scan my syndication feeds when I'm in line for something.  But I don't pay for it, which means nothing is going back to the paper, or whoever generated the content in the first place.  So increasing readership alone isn't going to keep the papers afloat.

I just don't see myself paying for news.  The Internet has made me used to having things free and my way, and I think a lot of people are with me on this one.

But this content has value, right?  Surely, someone is willing to pay for it.  I mean, if the switch were turned off today and all news went away, there would be a hole in my life.  Americans need and crave news coverage.

As in the past, I think the advertisers will step up.  But they're probably going to want to know a little bit about you, to, you know, make sure you get the right ad.  Consumers benefit from this.  Even if you routinely ignore all adversing, under this scenario, you're ignoring advertising targeted to you for stuff that might actually fit your interests.  I have found myself, on occasion, clicking on Google ads, even though it rarely results in me buying something.  The process works.

My predictions

In ten years, there will still be newspapers.  But they'll be owned by local television stations, who will have taken over as the main supplier of news content.  This suits me: their stories are shorter and I think that fits the lifestyles of more people nowadays.  These newspapers will be free and contain copy taken from the newscasts and modified slightly for print.  The ads in the papers will be the result of TV spot upsells.  There won't be classifieds since you can't execute a full-text search on a newspaper.

This model cannot currently exist in the United States because laws prevent interests that own one type of media outlet from controlling another type.  But that will change soon, if it hasn't already started.  (Tracking the status of this without becoming an expert is well nigh impossible.)

I don't know much about what kind of software TV stations use to handle their content (I know a bit about the advertising side), but I seriously doubt it would integrate well with print content at this point.  The disciplines haven't converged enough yet.

It will be fun to follow this story for a few years to see how things pan out.

14 June 2009

Simplifying the Trip

Our vacation starts soon.  We're going some place far away by way of jet. 

We've had a Sony MiniDV camcorder for almost 10 years.  It still functions perfectly, but with four children in tow, it has started to feel more like an anchor than anything else.  The bug bit last summer and I bought a smallish camcorder that recorded directly to a hard drive.  Two days later with a bit of buyers remorse and the utter realization that the camera was completely incompatible with the MacOS (even though the box claimed otherwise) I returned it.

I decided to be a bit more pragmatic about it this year.  After some reasearch I realized that I didn't want to spend good money on a small SD camcorder knowing that I would probably want a HD recorder in the next 5 years.  But I'm not ready for an HD recorder yet either (I don't have the storage capacity).

So what do I do?

It didn't take long for me to come across the Sony Webbie and the Flip Ultra HD.  These are small devices that record directly to flash in HD mpeg-4 format, priced in the $150-$200 range.  Now don't be fooled by the "HD" in the product names.  While both devices do record HD video, they do so using a codec that his highly compressed and lossy (think youtube HD quality).  They don't do well in low-light situations either.

All this got me to wondering what the video quality on my digital camera, a two year-old Sony DSC-T20, was like.  Turns out, it records 640x480 mpeg-4 at 30fps.  This falls in the range of "good enough for me" and it's technically HD like the Sony anf Flip.  After all, I'm not going to use it to record piano recitals, awards ceremonies or new babies.  I just need something good enough to capture the cute moments that I want to remember when I'm on a trip.  And let's face it--Nicole and I only ever go back and watch these videos once or twice a year anyway.  (Maybe they will become more important as we age.)

So it's settled--I'm going to use my digital camera to record video on this trip.  I did decide to spring for a larger memory stick though--8GB where there were only 2GB before, and a second battery for hot swapping.

Side question: I wonder how long before these devices converge?  Tangential jab: And will it include a cell phone and app store as well?