Dec

24

Happy Holidays

As an atheist who celebrates Christmas, I don't see what all the fuss is about.

I mean, I think I do, but wouldn't it be nicer to find a way to live with these rituals rather than purge them all?

I don't want to have big, unavoidable religious hullabaloos in our public spaces, but I think we've already proven that we know how to take a major religious feast and turn it into a secular party for the rest of us. Nothing mandatory, but nothing reasonable excluded.

Isn't it time we had a crass, commercialized, mass market celebration of Holi?

More...

Jul

27

Things To Remember

  • When I'm with him: How scary it is when I think I've lost him*
  • When I think I've lost him: How in-your-face crazy it is when I'm with him

More...

Jul

7

Like QuerySets, but crazier

I have a crazy QuerySet idea.

Imagine we have this:

class Task(models.Model):
foo = models.CharField()
 
class TaskStatus(models.Model):
task = models.ForeignKey(Task)
user = models.ForeignKey('auth.User')
status = models.CharField(default='not-done')
 
class Meta:
unique_together = ('task', 'user')

Now imagine we're listing Task.objects.all() on a page. We need to show the user's status for each task, so we do something like this:

b_list = []
for a in A.objects.all():
b_list.append(a.b_set.get_or_create(user=request.user))

That sucks because it's doing an extra db query for each object. We can work around that problem, but this also sucks because we're sort of needlessly creating new records when we don't need them. If the TaskStatus is being created with a default status, and we know that's what it will be because we're creating it, couldn't we just assume that status if there's no TaskStatus object and skip the creation? Yes, we could probably do that too. But now our code's going to look a little messier. I won't both writing it out, but you can imagine, right?

Here's my crazy idea:

Write a manager method that returns a custom QuerySet subclass that will do something like this internally:

    def get_for_user(self, user);
tasks = Task.objects.all()
task_status = dict([(ts.pk, ts) for ts in self.get_query_set().filter(user=user)])
for task in tasks:
if task.pk in task_status:
task = task_status[task.pk]
else:
task = TaskStatus(task=task, user=user))
yield task

But, you know, done up so it behaved like a queryset instead of a plain iterator, where you could filter, exclude, get, etc.. So what you get is a queryset that includes all the objects you would normally find from the db, plus some freshly created (and un-saved) objects.

It seems like something like this could let you avoid a lot of db hits and extra db entries and would be transparent to the code that was using it.

Implementing this for general use would require some deep Query fiddling, but I think it could be manageable if I wrote it for this one application instead.

So crazy it might work, or is it the wrong amount of craziness?

Nov

30

URLs on multi-lingual sites: A solution

Let me tell you about two problems:

  1. Your site is localized into multiple languages, but the words in its URLs can only be in one language. For example, "/products/" isn't a great URL if you can't read English.

  2. Django's language switching is kind of crappy. You have to post to a view to change the language, and it's hard to expose all the site's translations to search engines for indexing.

Ladies and gentlemen, the solution is at hand: Transurlvania!

More...

Mar

19

Winter Walk

When we first moved to Nova Scotia we had one car and it wasn't very good. Winters were very isolating. They were colder and snowier too, I think.

I remember one time when my mom, my brother and I walked to the convenience store. It was a 4 kilometre walk along the shoulder of the backroad that was our only road. It was the day after a big snowstorm. The sky was blue and the wind was low. The snow made the walking harder. We didn't see anybody on the road until about halfway to the store, when we saw a strange angular structure crest the next hill. I remember it felt like it took a long time to come close. It was the home dune buggy contraption of Danny, the recluse who lived in the woods around there. I can't remember if we waved as he drove by.

What I remember is the silhouette of a black trapezoid rising up over the hill with white snow and spruce trees and blue sky all around.

Nov

24

Oh Apache

Man oh man.

I just resolved a stupid Apache issue that has been driving me nuts for over a year.

The problem was that one of the domains for this very blog, pocketuniverse.ca, wasn't working, while the other domain, www.pocketuniverse.ca, was working just fine. If you went to the later domain you saw the site, if you went to the former domain, you say Apache's default "It Works!" message. For some reason the default virtual host was being selected for pocketuniverse.ca even though it was listed as the ServerName of my blog's virtual host.

Read on for the exciting conclusion!

More...

Sep

3

Guess Who's Going On Vacation

oh boy oh boy oh boy!

Sep

1

Unhelpful Anger

Man, I just read this TorStar story about a hit and run and I'm just mad. I don't have a reasoned opinion. I want to beat in the brains of the driver of that car.

Here's what I think. Drivers: you blew it. You had this incredible luxury, and you were a bunch of stupid assholes about it so now it's done. All your licenses are revoked. If you want to drive your car, get in line for your new license. Only this time the tests will be harder. You'll have to demonstrate that you're the sort of person who should be entrusted with a giant killing machine. And if you want to drive your SUV, you're going to have to find four other people to rid with you or you'll be taken off the road. Those who do not need to drive four people around regularly are invited to buy smart cars. Or bicycles.

May

26

Bike Lanes in Toronto

Here I am. Driven by desperation to actually blog about something.

I built up a head of steam and ranted a bit about cars and bikes. Read on.

More...

May

12

PyCon - Day 2

So much for writing about day 2 at the end of day 2. This is my heavily abridged, well after the fact recap of Day 2 of Pycon.

(it's short but still to be big to get posted right on the home page, read on for more)

More...

Apr

14

Dear CRTC

Bell wants to start billing its resellers (like TekSavvy) extra for usage over 60GB per user. Basically, they'd like to bill TekSavvy customers the way they bill their own customers, removing what little opportunity for competition they were forced to offer. Here's the message I sent to the CRTC:

I strongly object to Bell's tariff application to introduce Usage Based Billing. I switched from Bell to one of its DSL competitors because Bell's service was poor and Rogers has at least as bad a reputation. It's completely unreasonable for Bell to force their own business decisions on the competitors. They would remove what little room their is for competition and hold us back even further.

Canadian broadband is already falling behind. It's critical not just that the CRTC act as a check against massive self-interested parties like Bell, but to move to create more room for actual competition. Bell does not have the best interests of Canadians at heart (nor, arguably, should it). We Canadians depend on the CRTC for that.

Please reject Bell's tariff application. Please support small, independent ISPs. Please help Canada reclaim its reputation as a telecommunications leader, instead of the backwater it is becoming.

You can let the CRTC know how you feel by filling out the form here: http://support.crtc.gc.ca/crtcsubmissionmu/forms/Telecom.aspx?lang=e. Select "Tariff" and then put "File Number # 8740-B2-200904989 - Bell Canada - TN 7181" in the subject line. TekSavvy sent me this email, but I think this is a big deal for all Canadians who care about the Internet.

More...

Mar

28

Schwaggy Dog

Dig All the Schwag:

Mar

28

PyCon - Day 1

Day 1 of PyCon was great. I should have started writing this yesterday because I'm already forgetting some of it.

Read on. This is a long post.

More...

Mar

27

A Noob In King Guido's Court

Here I am, somehow, impossibly, in Chicago and attending PyCon.

Somewhere in this crowd are other Djangonauts. I need to figure out how to find them.

Feb

22

Pictures! I hear these are popular with the kids.

My friends, I am pleased to present our two adorable kitties, Nacho and Mika.

I'm also pleased to present my new image attachment feature.

I'll put something wordier up in the Developer category at some point. This is just to celebrate (and confirm that it's really working).