Peter · of · the · Norse · Thinks · He’s · Smarter · than · You


He Might be Right

Recent Entries · Archive · Friends · User Info

* * *

I was watching 2001 recently, and it doesn’t hold up that well. It’s not just that history and technology turned out differently, but the clothes were straight out of the late ’70s. Even more than movies set in the late ’70s. This is often a problem with sci-fi. Styles are extrapolated from current trends. But trends don’t move in a straight line. They weave and turn and oscillate unpredictably.

Instead, moves have lasting power when they take cues from other genres. Blade Runner is noir, so most things look like they’re from the ’40s. Firefly was a western, so things looked like they came from the end of the 19th century. The first Alien movie saw itself as pure sci-fi, and looks like crap. The second knows it’s a horror, and the set designs show it.

There are differences that can’t be copied from the past. HAL from 2001 looks good, because it (he?) was a completely new thing. New technology will look good as long form follows function. Good sci-fi lets the plot and tone dictate the other details.

* * *

Style is always the last step. While I’ve got some CSS for layout, it’s still all wrong and ugly. But as a break from Django coding, I did some stuff with the javascript. I knew javascript sorting would be great, but animating inserts and deletes is pure win. The old one just blinked lines in and out. No fun. Now they slide in and out. It’s actual feedback that something happened. Now if only I could figure out how to animate changing data.


Getting sorting working properly was a challenge. Mostly because I’m not sure what the right thing to do is. When working the playlist, what is the least surprising thing to do? Resorting songs that haven’t been played yet isn’t a problem, but what happens when you move an unplayed song into a group of played songs?

Use cases:

  1. Setting up the playlist for the future. Solution: Don’t do anything if the songs are unplayed.
  2. The DJ accidently hit play on CD player 2 instead of 3. Solution: When two songs next to each other, swap the times.
  3. I can’t think of a third. There’s a chance that things got screwed up without the DJ noticing right away, or a song accidently was marked played. The default should be just to mark it as unplayed. We know that the time would be wrong anyway, so what else can we do?

There’s only a touch of work with sorting itself. Set the update callback to pass the moved object and the object just before it to AJAX. The Django code will return the updated time.

* * *

Now that Windows 7 is out, I thought it might be a good time to talk about why Vista sucks.

Once upon a time, Windows 95 did things the way it did because it was little more than DOS. Things like the Internet and multitasking were new, and it was Microsoft’s first attempt at them. Like all first attempts, they weren’t perfect. But Microsoft is real big on backwards compatibility. So even when something was completely broken, or a security risk, it was carried over in to the next version of Windows. In fact there are bits of code in XP that are unchanged from Windows 3.

Microsoft has been telling developers not to use these bits of code since Windows 98. “It won’t work in the next update.” But of course it did, because MS worships at the altar of backwards compatibility. And MS cried wolf with each new release. Until it was eaten by Vista. Much of the vaunted “improved security” of Vista comes from getting rid of the old ways — particularly with drivers — and it works. The old ways were insecure. But that didn’t mean people weren’t using them. And when a driver or program tried, it would crash.

Now you might think that means the developer is at fault. After all, they were warned about it. But this is where Microsoft failed to ghetto.

A computer ghetto is a punishment. When you do things the wrong way, you lose something. Perhaps you can’t use some new technology, or it runs a bit slower, or things just don’t look right. Windows 95 ghettoed well. DOS programs couldn’t use the full video resolution, and file names showed up like INVOIC~1.DOC. Developers loved it, since it meant that people had to upgrade their programs in order to work right.

Driver Signatures is the latest ghetto. There were so many buggy drivers out there that Microsoft started a program where they would look over the device drivers, and make sure that they didn’t crash the whole computer. If a hardware company failed to have their drivers looked at, a XP would suggest that there might be a problem with it. Some people viewed it as extortion, but it really was just an attempt to improve code quality.

But this is where they failed to ghetto. Many of these drivers were written by people who had been writing drivers since Windows 95, and hadn’t bothered to update their techniques. They didn’t crash XP, so they were signed. But they still used the old code that was due to be disabled in Vista. And when that happened, it crashed.

The best example might be to look at Roxio Easy CD Creator. CD burners first came out when 95 was new. The fastest, easiest way to write a CD burning program was to use the “upper filters”. Don’t worry about what they are, just know that’s how it was. It was a mess though. You couldn’t use more than one program, because they both installed drivers in the filters, and they would conflict. Windows 2000 included support for burning CDs and DVDs, so there was no need to write your own drivers. But you still could, just to maintain backwards compatibility with Windows 95. Roxio still does it the old way, and Microsoft still signed the drivers.

All is not lost though. Windows 7 knows how to ghetto. It has a list of drivers it will not load. It knows that despite being signed, Roxio sucks. If you see a message about not loading software from Sonic Solutions (Roxio’s name back in 1995) know that you are being saved by a ghetto. And uninstall everything from Roxio.

Tags:
* * *

The documentation for building custom admin commands is a bit sparse. Fortunately, James Bennett is very good at documentation. So good in fact, that you should just look at what he’s done rather than read my second hand nonsense.

The only difference is I use NoArgsCommand and use the commit_on_success decorator on handle_noargs.

Tags:
* * *

I’ve heard three amazing covers at shows: Painted Saints covering “Oh Comely”, Jesse Sykes and the Sweet Hereafter playing “Sweet Nothing”, and now The Legendary River Drifters doing “Baby Bitch”.


For the most part though, the UMS was a disappointment. (I’m sorry. “Theums”. Fix your fucking URL.) Actual line from the program guide: “We believe in Denver.” That’s CEO doublespeak that they say right up until they close the factory and plunge the town into a recession.

More people, fewer venues, and duller bands. It felt like KBCO was a sponsor at some of the shows. Just because you don’t have a major label contract, doesn’t excuse you from sounding like Dave Matthews. The line to see Ian Cooke started forming at 8:00 this time around. Why they didn’t use the much larger outdoor stage for the headliner, I’ll never know.

I’m hoping next year won’t suck so much.

Tags:
* * *

With the update in changeset 11250, the code I posted recently doesn’t work anymore. It has to be changed to

return HttpResponseRedirect(reverse(self.admin_site.name + ':on_air_rotationschedule_changelist'))

I’m not sure how I feel about the namespaces. They seem like a good idea, assuming you have two different URL schemes going. It’s just that namespaces should be optional. There might be a little more work involved, but that’s the price you pay for flexibility.

Tags:
* * *

I have a cron job that runs each night that dumps the day’s playlist into the history table and rebuilds it. It’s a fairly simple script, especially since I can wrote it in Django. There are some gotchas when running Django code outside of a server though.

First, make sure that you have the the DJANGO_SETTINGS_MODULE environmental variable set. Fortunately, that’s as easy as import os; os.environ['DJANGO_SETTINGS_MODULE'] = 'dervish.settings'. Secondly, end with django.db.connection.close(). Otherwise your database log will be mostly unexpected EOF on client connection.

If you aren’t a fan of autocommit, you’ll also have to turn on transactions.

django.db.transaction.enter_transaction_management()
django.db.transaction.managed()

django.db.transaction.commit()
#or
django.db.tranaction.rollback()

django.db.transaction.leave_transaction_management()

It might get easier to set it up as a command, but that’s a kettle of fish I don’t want to get into.

Tags:
* * *

Speaking of updated tools, (Actually we were just talking about sex. Updates was the post before.) Django is this close to 1.1. My favorite features are the updates to the admin interface. For example: there is just one schedule. I want to be able to edit the whole all at once. My first attempt used a singleton parent object. That sucked. Instead, we can use the list_editable and have it work right.

class RotationScheduleAdmin(admin.ModelAdmin):
    list_display = 'order', 'rotation'
    list_editable = 'rotation',       #Don’t forget the comma
    list_per_page = 800

There’s only about 200, but overkill doesn’t hurt. We also want to make adding a new one a simple as possible. So we can override the

    def add_view(self, request, **kwargs):
        models.RotationSchedule().save()
        return HttpResponseRedirect(reverse('admin_on_air_rotationschedule_changelist'))

The upshot is, when a user click on the “Add” button, a new line is added and the list is shown again. The save method provides good defaults.

I’m also using the example given of overriding the admin views.

    change_list_template = 'on_air/admin/rotation_schedule_change_list.html'
    def changelist_view(self, request, extra_context=None):
        if (extra_context == None): 
            extra_context = {}
        extra_context['rotation'] = models.dj.Rotation.objects.all()
        return super(RotationScheduleAdmin, self).changelist_view(request, extra_context)

and

{% extends "admin/change_list.html" %}
{% block object-tools %}
<table>
  <thead><tr>
    <td>Rotation</td>
    <td>Suggested</td>
    <td>Songs</td>
    <td>Scheduled</td>
  </tr></thead>
  <tbody>
    {% for rot in rotation %}
    <tr>
      <td>{{rot.rotation}}</td>
      <td>{{rot.max}}</td>
      <td>{{rot.song_set.all.count}}</td>
      <td>{{rot.rotationschedule_set.all.count}}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>
{{ block.super}}
{% endblock %}

So download the nightly build today. You’ll be glad you did.

Tags:
* * *

In So Long, and Thanks for All the Fish, there’s a scene where Arthur Dent teaches his girlfriend to fly. I always liked the imagery and sometimes have dreams where my lover and I are flying in the mountains.

We take off from the plains before dawn. High enough the air turns cold and we can see the curvature of the earth. The artificial lights of the cities and highways clash with the pre-dawn glow. We begin by diving down into whichever valley strikes our fancy. It’s a controlled fall just at the edge of disaster with the wind whipping around us so we can’t hear. At the last moment we swoop up again, straining against the effort and getting close enough to hear the birds chirping in the trees above our heads.

We would tumble and play in the air currents for hours, coming together and flying apart in a makeshift ballet as dawn breaks. Starting with the snow covered peaks, the golden light that can’t be found anywhere else slowly fills the world. Usually the aspen are turning and there are always granite and sandstone outcroppings. I pass though a cloud. Inside it’s dark and the mist forms drops against my skin. Suddenly I pop out to see the sight of the golden dawn light playing off her skin and the rest of the world.

When it’s still, there’s nothing but us. No distractions. No weight. No noise. Just her and me as we explore each other bodies. Sometimes the wind funneled by a pass causes us to tumble end over end. We barely fight against it while making love.

Needless to say, this is one of my favorite dreams.


There’s a TV show that has The Delgados’ The Light Before We Land as it’s opening theme. It managed to take me by surprise, and I remembered the dream. I won’t name the show, because I suspect it sucks. Since it’s attached to a wonderful memory, I can’t be objective.

Tags:
* * *

jQuery has been updated to version 1.3. Which means my little addition to it is now out of date. While the replacement API is very nice and useful, there are real rendering differences between the browsers when they use the native controls. If you explicitly style it, then they all act the same. But I don’t want that. I like the native controls. And there should be a way of detecting the OS as well. Pop-up menus on the Mac are one pixel taller than input fields.

I did make one change to the combo box. Now the up and down arrows go though the options like they should. Let me know what other behavior I’m forgetting.

Recommended addition to all websites:

if (!jQuery.support.boxModel) {window.top.location="http://update.microsoft.com"}
* * *

Previous

Advertisement