Archive for Blog
January 28, 2008 at 09:22 PM · Posted under politics
As
XKCD reports:
Obama has shown a real commitment to open government. When putting together tech policy (to take an example close to home for xkcd) others might have gone to industry lobbyists. Obama went to Lawrence Lessig, founder of Creative Commons (under which xkcd is published) and longtime white knight in the struggle with a broken system over internet and copyright policy.
Yes! When you want to talk copyright reform, the only person you should be talking to is Lawrence Lessig (who also supports Obama). Brilliant! I’m officially pulling for Obama on ‘08.

Comments (2)
January 27, 2008 at 01:36 PM · Posted under design, programming, techtips
After getting more into the depths of Django I was all set to write a comparison article, then I found one made by two guys who made the same website with both frameworks. Nicely written, lots of detail, objectively puts forward the strengths and weaknesses of both. Unfortunately the documents are not presented on a nicely written website, but in a subversion repository. I’ll put the links to the external resource first, but if those go away feel free to use the mirrored copy of the article below.
Rails vs. Django:
Local mirror:
While both frameworks do a great job of producing databases from their corresponding language code, my biggest complaint with Django is that it lacks a counterpart to Rails’ migrations. Migrations enable a Rails projec to incrementally develop the database model. Essentially it’s subversion for the database structure. You build up changes (adding/removing/altering tables, columns, etc.) using ‘migrations’ and can apply them or roll back at your whim. Django, on the other hand, really wants a fully formed database structure to start off the project. Any changes after the initial creation have to be shoehorned in by: 1) adding the stuctures to the database directly, then 2) updating the database model within Django…bleh!
Django is clearly designed to get sites with simple models up and running fast. Using it you can definitely feel its lineage as a rapid news story development framework. Rails feels more methodical, a framework for building many types of applications but with a corresponding increase in development time. But that’s just me. I’m much more familiar with the Ruby language and (as the Rails vs. Django article concludes) both frameworks are essentially equally capable, so go with the one that uses the language you know. There is a lot of awesome (and not so awesome) in Django and Rails.
Comments Off
January 25, 2008 at 02:30 AM · Posted under essays, learning, programming, techtips
MVC stands for “model-view-controller”, a programming paradigm where the application is split into three interconnected yet disparate parts (as interpreted by Django):
- the model: the data of the application
- the view: the presentation and selection of data to present to the user
- the controller: the brains of the application that connects the user to the correct view
Note, the MVC paradigm is interpreted differently by the popular “Rails” framework (used for this very blog!). In Rails there are multiple controllers that decide what data to present to the user, and the view is left to simply display the data. In this interpretation Django’s views would be seen as controllers, and Django’s templates would be views.
To best describe how MVC helps us do our jobs as web programmers better, lets look at a simple PHP webpage application written as a script:
<?php
$page_title = "Ten most recent blog entries";
include_once($include_path.'/header.php');
// setup $db
include_once($include_path.'/db_connection_for_this_application.php');
$recent_blog_posts = mysql_query("SELECT
posts.post_date,
posts.post_title,
posts.post_content
FROM
posts
WHERE
posts.post_status='publish'
ORDER BY posts.post_date DESC LIMIT 10, $db);
echo '<h1>Recent Posts</h1>';
while($posts_data = mysql_fetch_array($recent_blog_posts)) {
echo '<div class="post">';
echo '<div class="blog_date">' . $posts_data['post_date'] . "</div>\n";
echo '<div class="blog_entry_title">' . $posts_data['post_title'] . "</div>\n";
echo '<div class="blog_entry">' . $posts_data['post_content'] . "</div>\n";
echo '</div>';
}
include_once($include_path.'/footer.php');
?>
Simple enough. That’s actually the big advantage of writing web applications as scripts. They are (almost) entirely self-contained and easy to understand. You start reading at the top and finish at the bottom, with no file jumping or object modeling required.
Unfortunately, this simpliciy is also very limiting:
- The content and the programming are combined. This means that, aside from CSS, if any web designers want to update the look of the page then they’ll have to modify the same file that contains the application. That’s a great opportunity for things to go wrong.
- The header and footer are fixed. This means altering something like the title of the page forces the application to declare prespecified variables (e.g. the $page_title), that the header file assumes are in place. A bunch of these variables can quickly clutter an application. At a simple level, including headers and footers makes sense, but as pages get more complex they get harder to maintain. What if you have a standard header/footer, but want slightly modified versions for other sections? Using header/footer includes means that you’ll have to create separate include files for each. Without a clear organizational structure things can get confusing pretty quickly.
- Low-level programming is involved. The programmer has to build database queries by hand, which is a great place for bugs to hide.
- No object oriented programming. You can’t wrap up functions and data into logical blocks with specific interfaces (e.g. objects). In a better system, we’d just ask the “Blog” object directly for the ten most recent posts with something like {{ blog.posts | ‘limit’: 10 }}
As you can see, there is room for something better. That something is an MVC framework such as Django or Rails. Let’s look at how one (Django) solves the problems with our PHP script. I’ll show you the code first, then get into the explanation:
### models.py (the *model*) ###
from django.db import models
class Blog(models.Model):
entry_title = models.CharField(maxlength=50)
blog_date = models.DateField()
entry = models.TextField()
### views.py (the *view*) ###
from django.shortcuts import render_to_response
from models import Blog
def recent_posts(request):
post_list = Blog.objects.order_by('-blog_date')[:10]
return render_to_response('recent_posts.html', {'post_list': post_list})
### urls.py (the *controller*) ###
from django.conf.urls.defaults import *
import views
urlpatterns = patterns('',
(r'^recent/$', views.recent_posts),
)
### recent_posts.html (the *template* (part of the view))###
<html><head><title>Recent Blog Posts</title></head>
<body>
<h1>Recent Posts</h1>
{% for post in post_list %}
<div class="post">
<div class="blog_date">{{blog_date}}</div>
<div class="blog_entry_title">{{entry title}}</div>
<div class="blog_entry">{{entry}}</div>
{% endfor %}
</body></html>
Ok! That seems a little confusing compared to the script doesn’t it? Let’s dive in:
recent_posts.html
Take a closer look at the “recent_posts.html”. Think of how lucidly clear that file is to a web designer? There’s hardly any code! While of course no templating language can eliminate programming constructs Django’s system does a great job of only giving the template designers what they need to get the job done. The template “programming” is using its own programming language, not straight Python. There are two big reasons for this: 1) the language is meant to be simple and only provide the features needed to select or present the proper data, 2) the language doesn’t allow templates to do anything that the application should handle (e.g. a template can’t tell the database to delete itself).
Yes, my example doesn’t demonstrate how Django helps with header/footer includes, that’s coming up so be patient!
models.py
This is simply describing to Django how to organize the data object that we’ll be dealing with.
urls.py
This is routing a user’s request for the web address ‘recent/’ (e.g. mysite.com/recent) to the recent_posts function in views.py.
views.py
This is the best part, take a look again:
def recent_posts(request):
post_list = Blog.objects.order_by('-blog_date')[:10]
return render_to_response('recent_posts.html', {'post_list': post_list})
That’s it? That’s it! Our complex SQL query is now a higher level abstraction where we tell Django to tell the blog to give us the latest ten posts. Done!
Now lets look at that last piece: header/footer files.
Django does allow us to build templates that pull in header/footer includes, but it also lets us solve the common data problem with template inheritance. With template inheritance we don’t abstract the pieces of our web pages that are the same, we pull out the pieces that are different. Let me explain with a very simple webpage:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>My Website</title>
</head>
<body>
<h1>Page Title</h1>
<p>Customized content!</p>
<hr>
<p>This is my footer</p>
</body>
</html>
Done using header/footer includes:
### header include file ###
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>My Website</title>
</head>
<body>
### footer include file ###
<p>This is my footer</p>
</body>
</html>
### custom page ###
include(header_file)
<h1>Page Title</h1>
<p>Customized content!</p>
include(footer_file)
Now done with Django’s template inheritence:
### base.html ###
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>{% block title %}My Website{% endblock %}</title>
</head>
<body>
<h1>{% block pagetitle %}{% endblock %}</h1>
{% block content %}{% endblock %}
{% block footer %}
<p>This is my footer.</p>
{% endblock %}
</body>
</html>
### page.html ###
{% extends "base.html" %}
{% block title %}Customized Title!{% endblock %}
{% block pagetitle %}Customized page title!{% endblock %}
{% block content %}
<p>Customized content!</p>
{% endblock %}
See what we did there? The parts of the page that will change are pulled out of the base. Django’s template system lets you declare “blocks” that indicate that that part of the page may change. If an extending template declares a block that matches that of the parent template, then the parent’s block is overwritten. If a block isn’t declared by the sub-page, that is in the parent page then the parent page’s block is used. Notice in our “page.html” the footer isn’t discussed at all. Django sees that we are “extending” base.html and that we haven’t specified our own footer block so it defaults to the footer block that was in base.html.
Perfect! We can create base templates that allow for child pages to overwrite any part that we explicitly allow! No more locked headers or footers!
Templates can go through multiple levels of inheritence as well. We could easily have a base template that is then extended into “section” templates that are then extended to specific pages. With a clear and logical chain of command it is easy to see how the webpage templates work together. Much better than a couple dozen header/footer files lying around. We get all the advantages of reusing designs without the headaches!
So there you have it. Sorry for the rambling/unedited nature of this post. It’s 2:30am, I can’t sleep, but I felt like sharing.
Comments (1)
January 24, 2008 at 12:19 PM · Posted under quicklinks
Do’s and don’ts with babies
Comment
January 21, 2008 at 10:39 AM · Posted under politics
I encourage you all to read the entire article The Martin Luther King you don’t see on TV, but here’s a salient excerpt.
You haven’t heard the “Beyond Vietnam” speech on network news retrospectives, but national media heard it loud and clear back in 1967 — and loudly denounced it. Time magazine called it “demagogic slander that sounded like a script for Radio Hanoi.” The Washington Post patronized that “King has diminished his usefulness to his cause, his country, his people.”
In his last months, King was organizing the most militant project of his life: the Poor People’s Campaign. He crisscrossed the country to assemble “a multiracial army of the poor” that would descend on Washington — engaging in nonviolent civil disobedience at the Capitol, if need be — until Congress enacted a poor people’s bill of rights. Reader’s Digest warned of an “insurrection.”
Yes, Mr. King had started a new fight, but this one didn’t play as well. Declaring war on poverty and America’s supression of third world countries was not very popular. King’s Beyond Vietnam speech is depressingly prophetic.
In 1957, a sensitive American official overseas said that it seemed to him that our nation was on the wrong side of a world revolution. During the past ten years, we have seen emerge a pattern of suppression which has now justified the presence of U.S. military advisors in Venezuela. This need to maintain social stability for our investments accounts for the counterrevolutionary action of American forces in Guatemala. It tells why American helicopters are being used against guerrillas in Cambodia and why American napalm and Green Beret forces have already been active against rebels in Peru.
…
This call for a worldwide fellowship that lifts neighborly concern beyond one’s tribe, race, class, and nation is in reality a call for an all-embracing and unconditional love for all mankind. This oft misunderstood, this oft misinterpreted concept, so readily dismissed by the Nietzsches of the world as a weak and cowardly force, has now become an absolute necessity for the survival of man. When I speak of love I am not speaking of some sentimental and weak response. I am not speaking of that force which is just emotional bosh. I am speaking of that force which all of the great religions have seen as the supreme unifying principle of life. Love is somehow the key that unlocks the door which leads to ultimate reality. This Hindu-Muslim-Christian-Jewish-Buddhist belief about ultimate reality is beautifully summed up in the first epistle of Saint John: “Let us love one another, for love is God. And every one that loveth is born of God and knoweth God. He that loveth not knoweth not God, for God is love.” “If we love one another, God dwelleth in us and his love is perfected in us.” Let us hope that this spirit will become the order of the day.
We can no longer afford to worship the god of hate or bow before the altar of retaliation. The oceans of history are made turbulent by the ever-rising tides of hate. And history is cluttered with the wreckage of nations and individuals that pursued this self-defeating path of hate. As Arnold Toynbee says: “Love is the ultimate force that makes for the saving choice of life and good against the damning choice of death and evil. Therefore the first hope in our inventory must be the hope that love is going to have the last word” (unquote).
…
We still have a choice today: nonviolent coexistence or violent coannihilation. We must move past indecision to action. We must find new ways to speak for peace in Vietnam and justice throughout the developing world, a world that borders on our doors. If we do not act, we shall surely be dragged down the long, dark, and shameful corridors of time reserved for those who possess power without compassion, might without morality, and strength without sight.
Comments (3)
January 21, 2008 at 10:06 AM · Posted under politics, quicklinks, television
Martin Luther King, Jr.
Comment
January 19, 2008 at 09:57 PM · Posted under movies, recently

Review: 5/5
Apparently a very polarizing movie. I loved it from start to finish. I surprisingly caught up with the character story, so much that I was actually shocked when the monster action started. The movie really is presented as though filmed from a single camera. The special effects were amazing, most especially for how tightly integrated into the movie they were. It really looked like incredible things were actually being filmed by a hapless guy with a camera. So great! I loved that the camera guy was a character. Some people dismiss this movie outright because of the shaky camera, but it seriously didn’t bother me at all. I was actually expecting it to be worse than it was. There was also some wonderfully surreal intercutting between the monster movie and a film that everything was being recorded over.
Comments (13)
January 17, 2008 at 01:55 PM · Posted under quicklinks, science, tech
New blackest material created – check out that picture, the material looks like a hole in the table.
Comment
January 14, 2008 at 10:53 PM · Posted under videogames
Mass Effect is, in large part, a superb remake of Starflight, one of the greatest space opera videogames.
I’m still impressed at how excellently the pieces of the game fit together. It is astounding that we are able to play a game that can so adeptly become so many games. Tonight I played some Gears of War, some Starflight, and a fun new game I like to call Offworld Offroad Mining Survey Action Racer: all within Mass Effect.
Comment
January 14, 2008 at 02:01 PM · Posted under videogames
Sarah bought me Mass Effect over the weekend. I spent most of Sunday afternoon having a great time running around this huge space station and wowing over the graphics and having a great time with the story.
Let’s talk graphics. Lush, is a word that comes to mind. You can really tell that the game designers had a lot of fun adding tons of detail to their game world. Characters facial expressions and eyes are singularly impressive. I’ve played Bioware games before (Knights of the Old Republic, and Jade Empire) and always ran into the edge of believability pretty quickly due to the lack of graphical quality. This was, of course, necessary due to the fact that their environments and game scale were so huge. Thankfully, such dark ages are behind us. This game is space opera at its most grand.
The gameplay is pretty amazing as well, it ties together the elements of a shooter action game with those of an adventure game and role playing game very nicely. I went in expecting them to get the RPG right, the adventure aspects (e.g. conversation branching) ok, and the shooter passably; but all have been quite impressive.
So anyway, there I am having a blast and thinking that it can’t get any better. Then I get to the point where my character is given a ship, a crew, and millions of stars to steer her by. Yes! Via the ships interface my character seems to fall into a gorgeous galatic map with familar features such as the horsehead nebula and I get to pick a point and say: let’s go there!
From the galaxy view I was presented with a dozen or so destinations. Nice enough I thought, but then I drilled down through that beautiful galactic map and found that each of those destinations had more than one solar system (whoa) and then that each of those solar systems had more than one planet! I was expecting just a one system, one planet type of space exploration (Star Wars, Star Trek, etc.) but no, this game has bigger plans. I pick a planet of interest (say we are getting faint distress call reading from an uncharter planet) and get dropped onto the surface in my airtight Mako vehicle that looks like they modded the personnel transport from Aliens for offroading action (and added a kickass gun turret). I literally said, “Wow,” when I first started driving around under the green sky of the windswept, dust filled, desolate landscape of an alien planet looking for the source of the distress signal beacon. Amazing! The planet was about 3/5ths Earth gravity so I careened about the landscape like some superpowered Mars rover, jumping dunes, climbing mountains, and racing down into valleys.
Check out this Mass Effect trailer featuring galactic exploration to see what I’m talking about.
Comment
January 14, 2008 at 10:47 AM · Posted under quicklinks, tech
WRAL’s Antenna Giveaway
Comment
January 11, 2008 at 10:51 AM · Posted under books, recently

Review: 3/5
More interesting than Prince Caspian, but what story still suffers from C.S. Lewis’ writing. Like Prince Caspian the plot is very straightforward and unsurprising. All of the characters are completely flat, although Reepicheep is amusing. Eustace is the only character that changes at all, and he only in a very predictable manner.
Comment
January 10, 2008 at 10:04 AM · Posted under books, recently

Review: 4/5
A fascinating retrospective of Playboy from the fifties to the new millennium. Before this book I didn’t know that Playboy has contributed so much to our literary culture. A small list, Playboy: discovered Shel Silverstein; published The Fly, Fahrenheit 451, and much else; published Ron Kovic’s memior Born on the Fourth of July; helped Alex Haley (who was a longtime contributer) compile his widespread research into the epic work Roots; assigned Cameron Crowe to review The Who (which got him his job at Rolling Stone) and later published his Fast Times at Ridgemont High; conducted the last interview with John Lennon.
Unfortunately (in the case of the articles) this book is a pictorial retrospective and so contains pictures of the first page or artwork for the article and a description of it, but not the full text.
Comments (1)
January 09, 2008 at 03:05 PM · Posted under family
Sarah and I had another ultrasound today, this one partially in realism-adding 3d. Behold!

Aww, our very own lolbaby.
Comments (5)
January 08, 2008 at 12:55 PM · Posted under learning, quicklinks
Flash Guitar Tutorials
Comment
January 08, 2008 at 09:12 AM · Posted under books, recently

Review: 2/5
Beautiful artwork, but the writing and storytelling were unfortunately lacking.
Comment
January 06, 2008 at 09:29 PM · Posted under politics, quicklinks
Jesus v. Republicans
Comment
January 03, 2008 at 12:37 PM · Posted under design, site
Comments comments everywhere! You can now add a comment to any of my recent events (books read, videogames played, etc.) or any of the quicklinks. The quicklinks page doesn’t display comments in any manner, and the quicklink individual pages aren’t customized, and the events page isn’t customized, and the events individual pages aren’t customized…but soon!
Comments Off
January 01, 2008 at 01:27 PM
Only two more aught years until we enter the future.
The Ball Family had Christmas II over the weekend (mainly Saturday) which was remarkable because all five of us siblings were all at home at once with all of our respective significant others and children (that’s fourteen people!). This literally hasn’t happened in years and it was awesome. We all played a lot of Rock Band, which turns out is the best party game ever made. It allows four people to play simutaneously: one on drums, one playing guitar, one on bass, and one singing and playing tamborine or cowbell. During C2 Rock Band was pretty much running all the time and everyone got in on the action. What’s even better is that we all got our own copies of the game, so we’ll all be able to play over XBox Live!
Here’s a few things I’ve recently learned:
- Rock Band is the best party game
- The ScanGaugeII automotive computer actually works and works well. We’ve already used it to get the code from a ‘check engine’ light in the Jetta (P0678). Combined with a handy TDI club listing of all Volkswagen engine and transmission error codes we now know the problem is that one of the glow plug circuits is open.
- a Breville Juice Fountain makes tasty juice
- Super Mario Galaxy is practically tied with Portal for Most Mindbending Game
- Metroid Prime 3 defines a new control scheme for first person shooters that can’t be beat
- Timbuk2 makes an awesome backpack
Comment
January 01, 2008 at 11:39 AM · Posted under books, recently

Review: 4/5
Practically an antithesis to Atlas Shrugged. The writing style in Fight Club is much more readable than in Atlas Shrugged, engaging and exciting instead of dry and tedious.
Comment