rc3.org

Strong opinions, weakly held

Month: November 2006 (page 1 of 2)

A wry comment on real life

From the Onion AV Club interview with Demetri Martin, on working for The Daily Show:

AVC: What allowed you to transition from intern to correspondent?

DM: It was a pretty simple process. All I had to do was leave the show, work at temp jobs, then become a full-time proofreader, do hundreds of stand-up shows, some comedy festivals, a couple of writing jobs, some screenplays, two pilot scripts, and about 20 minutes of Pilates. Then, a mere eight years later, I returned to the show to become the nation’s least relevant fake reporter.

It’s never as easy as it looks.

Spam that I like

Periodically, Netflix sends me an email asking me when I received a movie that they mailed, or when I mailed a movie back to them that they received. I assume that this is so that they can confirm that the mail is getting delivered in a timely fashion, and I’m sure that some people regard them as a nuisance, but these emails actually make me feel better about the service. They give the impression that somebody at Netflix actually cares. (Needless to say, I always click through to let them know that the service is working.)

Found on emusic.com: 1000 Years of Popular Music

I’ve decided to start a little series of post about interesting music I’ve found at emusic.com. Not because I want to promote that site, but rather because it’s where I’m finding most of the new (to me) music that I’m listening to these days.

Today’s interesting album is 1000 Years of Popular Music, a live album by Richard Thompson. I’ve been familiar with Richard Thompson for quite some time, but I had never heard of this release. Thompson was asked to come up with a list of the greatest songs of the millenium, and being serious about his task, actually came up with a list that comprised songs from the entire millenium. He wound up doing a series of concerts where he performed songs from his list, and that in turn resulted in this live album.

The material is wide ranging and Thompson’s performances are top notch. It’s a nice mix reinterpretations of songs you’ll probably be quite familiar with, and others that you’ll be hearing for the first time. One of my favorite things about the disc is that when I knew the origins of a song, the style of the original performer was discernible. For example, there’s a Jerry Lee Lewis song on the disc. When Thompson performs it, you can tell it’s a Jerry Lee Lewis song, even though he doesn’t have a piano accompanying him. (The one exception is “Oops! … I Did It Again”, which sounds like an REM tune here.) Great stuff.

My two favorite tracks on the disc are “1985” and “A-11”. Thompson’s version of the Squeeze classic “Tempted” is also outstanding.

Is auto development mimicking software development?

AutoWeek reports that Ford put a release candidate of its new model, the Edge, in the hands of some customers for last minute testing. They’ve made some minor changes to the vehicle in response to feedback from the testers, and will reportedly tweak the production line over the course of the year with other changes. I find it interesting that even the most old school manufacturing industries are trying to tweak their release cycles to be more responsive to customers.

Why stats matter

I confess that I’m a sucker for quantitative analysis of sports. Heck, I’m a sucker for quantitative analysis of just about anything. One argument people who are interested in statistics often hear is that the numbers suck the joy out of the game. Breaking down the stats is somehow a less noble way to follow sports than to just watch the games. David Berri, one of the authors of The Wages of Wins, asks the following:

Of course, if you are not engaged in such research (or even interested), then maybe you shouldn’t care how performance is measured. Then again, maybe the discussion of sports statistics is just part of the fun people get out of sports. I would be interested in hearing how people respond to the question “why should we care about measures of performance in basketball?”

Here’s my answer: everyone who cares about sports talks about why players and teams perform at the level that they do. Why did Houston Rockets lose most of their games last season? How did the Detroit Tigers go from being a bad team in 2005 to being a World Series team in 2006? How have the Oakland A’s been able to win so many games with one of the lowest payrolls in baseball? How were the New York Knicks so terrible last year given that they had a legendary coach and one of the highest payrolls in basketball?

Quantitative analysis (also known as stats) can help answer these kinds of questions. Indeed, I believe that statistical analysis often does a better job of revealing truths than the “analysis” of most sports fans and sports journalists. Outside the world of statistics, you read all about “choking” and lack of character and lack of chemistry and all sorts of other amateur psychology. Breaking down the numbers provides a falsifiable alternative to this kind of sports talk radio babble, enhancing my enjoyment of sports.

If I’m going to spend time arguing about sports, I’d prefer to have more evidence on my side than, “It sure seems like so and so strikes out every time he comes up to the plate with runners on base.” I know plenty of sports fans disagree, but I don’t have to respect them. And I certainly refuse to acknowledge their willful ignorance as a purer form of appreciation than my own.

Transitioning from mystery to thriller

When it comes to stories, the difference between a mystery and a thriller rests on the knowledge held by the audience versus the knowledge held by the protagonist. In a mystery, neither the protagonist nor the audience know the answer to the question central to the plot. The challenge is for the audience member to solve the mystery before the protagonist does. In a thriller, the protagonist doesn’t know what’s really going on, but the audience does. (See Alfred Hitchcock’s famous explanation of suspense to François Truffaut.)

My current favorite show is Dexter. It’s about a blood spatter specialist in Miami who moonlights as a serial killer (but only kills other serial killers). For the first seven episodes of the season, the show was a mystery. The main plot line of the show concerns another serial killer in Miami who is artfully killing prostitutes, and simultaneously playing an elaborate game with Dexter. We don’t know the identity of the killer, and as audience members we’re trying to work through the clues along with Dexter, the protagonist.

Last week’s episode turned the show into a thriller. Dexter has no idea who the killer is, but we now know the killer’s identity, and that one of the other main characters is in peril! So for the final four episodes of the season, the show becomes a suspense thriller. Now we hope and pray that Dexter discovers the killer’s identity before the killer can spring what we assume is his nefarious plan. Of course there are many more unanswered questions, but we’re now firmly in thriller territory.

Before this show, I hadn’t really thought much about how thrillers and mysteries differ, or about stories that transition from one genre to another. When I think about it, though, there are plenty of other shows and movies that make exactly this change. I consider it a testament to the quality of the show that it has me thinking about such things. Now I’m hoping that the writers of the show can do suspense as well as they do mystery.

If you’re not watching Dexter, you should be, but be sure to go back and start with the mystery before getting into the thriller.

Merging a branch back into the trunk in Subversion

Let’s say you’ve got a project in a Subversion repository, and you’ve created a branch of trunk, in branches/newfeature. You’ve been merging changes from trunk to branches/newfeature for awhile, but now you’re done with that work and you’re ready to move all of the changes in the branch back to the trunk. What’s the best way to do this?

You can follow the directions in the Subversion book, but that leads to a huge number of conflicts. Is there a cleaner way? If you’ve merged everything from the trunk into the branch, then what you really need is to just move the latest stuff in the branch into the trunk, without worrying about conflicts at all.

Testing the boundaries of ActiveRecord

I am a huge fan of object-relational mapping. One of the most tedious problems for developers who use object-oriented languages is transforming query results into objects and generating insert and update statements to save objects. There are a number of ways to deal with this problem, but the easiest way to handle it is to use somebody else’s ORM tool. Ruby on Rails includes an ORM library called ActiveRecord. This morning I ran into a problem with ActiveRecord that turns out to be an application design problem. I thought I’d write it all up in case anyone else runs into a similar problem.

Let’s say I want to retrieve all of the “question” objects stored in a database. With ActiveRecord, I just make the following call:

Question.find(:all)

It generates this query:

SELECT * FROM questions

If I want to retrieve the most recent 10 questions, I can use the following call:

Question.find(:all, :order => “created_at DESC”, :limit => 10)

That’s converted to:

SELECT * FROM questions ORDER BY created_at DESC LIMIT 10

Questions have categories. If I want to pull up the categories for questions along with the questions themselves, I can add the include parameter:

Question.find(:all, :order => “questions.created_at DESC”, :limit => 10, :include => :categories)

Here’s where the ORM power comes through:

SELECT id FROM questions ORDER BY questions.created_at DESC LIMIT 10

SELECT questions.id AS t0_r0, questions.current AS t0_r1, questions.status AS t0_r2, questions.created_at AS t0_r3, questions.updated_at AS t0_r4, questions.categorized AS t0_r5, categories.id AS t1_r0, categories.name AS t1_r1, categories.default_keyword AS t1_r2, categories.community_id AS t1_r3, categories.created_at AS t1_r4, categories.updated_at AS t1_r5, categories.parent_id AS t1_r6 FROM questions LEFT OUTER JOIN categories_questions ON categories_questions.question_id = questions.id LEFT OUTER JOIN categories ON categories.id = categories_questions.category_id WHERE questions.id IN (‘4839’, ‘4838’, ‘4837’, ‘4836’, ‘4835’, ‘4834’, ‘4833’, ‘4832’, ‘4831’, ‘4830’) ORDER BY questions.created_at DESC

In this case, ActiveRecord actually generates two queries. The first grabs the IDs of the ten most recently created questions, then it plugs those into the second query. This is the only approach that will work, because if you plugged the limit into the second query, you’d get back 10 rows that may or may not comprise 10 questions (depending on how many categories each question has assigned to it). I discussed this problem back on April 26, 2005. As you can see, ActiveRecord uses the very approach I proposed back then.

This is all great, except that I find myself running into one more problem. Let’s say I want to retrieve the most recent 10 questions in a particular category. I can add conditions to my query, like this:

Question.find(:all, :order => “questions.created_at DESC”, :include => :categories, :conditions => ‘category_id is null’)

This yields the following query:

SELECT questions.id AS t0_r0, questions.current AS t0_r1, questions.status AS t0_r2, questions.created_at AS t0_r3, questions.updated_at AS t0_r4, questions.categorized AS t0_r5, categories.id AS t1_r0, categories.name AS t1_r1, categories.default_keyword AS t1_r2, categories.community_id AS t1_r3, categories.created_at AS t1_r4, categories.updated_at AS t1_r5, categories.parent_id AS t1_r6 FROM questions LEFT OUTER JOIN categories_questions ON categories_questions.question_id = questions.id LEFT OUTER JOIN categories ON categories.id = categories_questions.category_id WHERE (category_id is null) ORDER BY questions.created_at DESC

Note that I’ve left out the limit parameter here. The reason I did so is that it doesn’t work. When you use limit, include, and conditions together in one call to find, ActiveRecord wants to apply the conditions to the initial query that retrieves the list of IDs, and in this case, the conditions apply not to the questions table but rather to the categories table. It’s not included in the initial query that retrieves the IDs, so an error is thrown. Here’s the broken query generated by such a call:

SELECT id FROM questions WHERE (category_id is null) ORDER BY questions.created_at DESC LIMIT 10

Bottom line: there’s no elegant way to retrieve the last 10 questions that aren’t assigned to any categories. If I wanted, I could retrieve all of the questions with no categories and then pull the first 10 out of the collection, but that’s a dangerous approach if the data set is large. Failing that, the only approach is guessing. For example, I could stick an arbitrary date in the conditions to limit the result set and then pull the first 10 questions from that set. However, if less than 10 questions have been created since that date, I’ll wind up with fewer than 10 questions in my result set. If the count were important to me, I could then just push the date further back incrementally and run the query again until I got 10 records, but that’s messy.

It’s probably better to just change the application to present questions from the past week rather than the past 10 questions. Anyone have any better ideas?

Having a TV show is better than having a blog

I was watching Studio 60 on the Sunset Strip last night and it occurred to me that writing a TV show is better than writing a blog. Sure, I could write tedious posts explaining why gay marriage should be legal, but that’s really nothing compared to being able to write dialogue. You can dream up two people who are on opposite sides of the issue, write their arguments for them, and make your point in a way that’s totally entertaining. Plus millions of people will watch because the other shows you wrote were actually good.

Maybe next week Aaron Sorkin will use the Socratic method to examine the morality of torturing detainees in the context of a one hour drama about sketch comedy. We can hope!

Snap verdict on PDF books

O’Reilly has a series of short books that they distributed in PDF form, called Short Cuts. Yesterday, I bought Cody Fauser’s RJS Templates For Rails, which explains exactly what the title says it will. The sweet spot for these books seems to be between finding information about a topic with Google and ordering a book on the topic from Amazon.com. The nice thing about this series is that the books are only as long as they need to be (the PDF I bought is 56 pages long) and the downloadable format provides instant gratification.

RJS is a perfect topic for this kind of treatment because it’s new and somewhat obscure, so it’s not as though it’s easy to find comprehensive information about it using Google, and it’s not documented in any of the current books that are on the market. O’Reilly was able to get to the market first by putting out this slim volume rather than working the topic into the dead trees publishing cycle.

The book itself is quite good. There are some decent examples, a high level overview of the technology, and a useful reference. I suspect that the challenge for O’Reilly is in marketing the books. The ideal customer is the person who’s having a frustrating time and needs something to jump start their knowledge of a topic on short notice. I found this book because O’Reilly got the person who had written the most useful blog posts on the topic to write the book, so naturally he promoted it on his blog.

As an author, I can see the appeal of publishing such books as well. It would be particularly appealing for a first-time author I’d imagine.

The short verdict: best ten bucks I ever spent.

Older posts

© 2024 rc3.org

Theme by Anders NorenUp ↑