Category Archives: General

Stuff that doesn’t fit into existing categories

Programmatically create Django security groups

Django authentication has security roles and CRUD permissions baked in from the get-go, but there’s a glaring omission: those roles, or Groups, are expected to be loaded by some competent administrator post-installation.  Groups are an excellent method of assigning access control to broad roles, but they don’t seem to be a first-class concept in Django.

It seems that you can kind-of save these values in by doing an export and creating a fixture, which will automatically re-load at install time, but that’s not terribly explicit – not compared to code. And I’m not even sure if it will work.  So here’s my solution to programmatically creating Django Groups., which is created in the same directory as your and is automatically run during python syncdb:

from django.db.models import signals
from django.contrib.auth.models import Group, Permission
import models 

myappname_group_permissions = {
  "Cinema Manager": [
    "delete_ticket",         # for sales reversals
    "add_creditcard_charge", # for sales reversals
  "Ticket Seller": [
  "Cleaner": [ # cleaners need to record their work

def create_user_groups(app, created_models, verbosity, **kwargs):
  if verbosity>0:
    print "Initialising data post_syncdb"
  for group in volunteer_group_permissions:
    role, created = Group.objects.get_or_create(name=group)
    if verbosity>1 and created:
      print 'Creating group', group
    for perm in myappname_group_permissions[group]: 
      if verbosity>1:
        print 'Permitting', group, 'to', perm

  sender=models, # only run once the models are created
  dispatch_uid='myappname.models.create_user_groups' # This only needs to universally unique; you could also mash the keyboard

And that’s it. Naturally, if the appropriate action_model permissions don’t exist there’s going to be trouble.  The code says: After syncdb is run on the models, call create_user_groups.

“Microsoft account”. One product, 6 names.

Hahaha, what a classic:

Microsoft account (previously Microsoft Wallet,[1] Microsoft Passport,[2] .NET Passport, Microsoft Passport Network, and most recently Windows Live ID) is a single sign-on web service developed and provided by Microsoft that allows users to log into many websites using one account.


So over the years it’s had 6 names!

Nice work, Microsoft.

WordPress Content Disappeared

While editing a WordPress post the other day I clicked on Add Media before I had saved or published the draft.

When I tried to upload the image I received the error WP couldn’t write to the disc. Odd. I then returned to editing and went to save a draft before I investigated what was going. Then I got the error that I was unable to save the past as the post did not exist. I returned to the the Dashboard and there were no posts or pages, only a few categories and comments.

I tried to look at the site’s home page but it returned the error the no content could be found in that category. All my posts were gone and no media was listed in the media library when I logged in again. The admin section worked fine, the page template displayed but there was no content for the pages.

The problem was a corrupt database. To solve the problem of WordPress content that has disappeared just run Repair on your tables using PHPMyAdmin and your site will come back to life.

The spinning globe

I’ve long been a fan of TV idents, and I used to love seeing the late-80s BBC1 globe animation, when it occasionally popped-up on television here. As well as the Alas Smith and Jones spoof version.

Here are a couple of fascinating articles on how it was generated: by a standalone computer, which animated the 12 second rotation, at the PAL standard of 25 frames per second.

(Update: Found a better video)

Birthrate<2.0 in Australia does not mean the end of the species

I’m listening to politicians rambling on about paid maternity leave and one just observed that it’s a crying shame that in Australia the birth rate is less than 2.0 per female.  Said same politician is advocating for more financial support for those undergoing IVF.

This planet does not need more people.  Governments should not be encouraging their production.

I’d like to point out that as it has in the past, Australia can very easily import humans to fill any shortage of warm bodies needed to care for the Baby Boomers in their dottage.  We don’t need to breed workers for the elderly-care industry.

Picking an ADSL2 provider

With the need for more than the current quota 500Mb of traffic allowed at home (256Kbps shaped to 56Kbps), it was time to switch plans… and given that change was in the air, no holds would be barred. The current spend is about $75/month including Internet, two mobiles, fixed line rental and phone calls. Mobile calls are carried on the Optus network; coverage and performance is satisfactory.

ADSL2 connections are cheaper than ADSL1 because of the Telstra monopoly. The current provider offers ADSL2, but they don’t have their own DSLAMs in my local exchange, so they resell Telstra product. Because of the need to maintain profit margins and Telstra’s pricing regime, the base-level product is $70/month. That doesn’t leave much room for calls or mobiles. shows both the locations and coverage of exchanges around Australia, and importantly also lists (as does, based on your phone number) what companies have DSLAMs installed. The Google maps mash-up showing the boundaries and location of the exchange allows you to estimate the distance to the exchange, which impacts the achievable line speed. Given we’re planning on moving sometime in the future, this information will also be used in selecting a new home – and because we vaguely know where that is, it would be desirable to have a provider that has DSLAMs in both our current and out future exchanges.

For me, that means Telstra, iiNet and TPG. Telstra is immediately excluded as being a bad idea. There are a bunch of iiNet resellers, and iiNet themselves, but the best deals seem to be from Netspace (I understand that they’ve been bought out by iiNet, so I expect plans bought from them will be grandfathered, but after that all bets are off).

Netspace’s most attractive plan is their ADSL2+ Super 20 Anytime plan, which bundles ADSL2 ($30) with a PSTN line ($30) and gives 20Gb of qutoa (plus another 20Gb off-peak, but when the hell is anyone awake between 2am and 8am?). Just as we were signing up, we noticed that the phone line isn’t $30 a month – it’s $40 and includes $10 of calls. If we made $10 of calls, that would be fine. But we don’t. So it’s not. Besides which, it pushes the plan to $70, leaving $5/month to run two mobiles. Next…

For less quota (15Gb) and more money ($40 instead of $30) Netspace has ADSL2+ Super 15 Anytime, their naked product. This would require VoIP, but given we’ve got $25 to play with, that’s do-able. The only problem is, at the end of the contract, what will the prices be? iiNet, Netspace’s future owner, doesn’t have the super-attractive plans; their cheapest naked plan is $50 and is 5Gb (even less for even more). On the upside, Netspace is does Single Service Transfer, which means about 10mins of Internet outage when the swap-over occurs (iiNet is not, so swapping away at the end of contract will be painful and expensive). Shaping is to dial-up speeds (56Kbps).

No one resells TPG ports. TPG’s cheapest naked plan is $50 for 20Gb (+20Gb), but interestingly they have a $51 plan that includes a phone line! Well, $61 because of the included $10 of calls. Apparently it’s a POTS line, but it does sound like a VoIP thing they’re pretending is a PSTN line. Oh, and the call prices are at full retail (25c local calls, timed national, 40c/minute mobiles), not crazy-go-nuts VoIP prices (~10c calls to landlines, ~25c/minute mobile calls). But they do number porting and give you 130Gb of quota, shaped down to 1Mbps when (!) you exceed it. That’s a bit of a step up from 500Mb and 256Kbps shaped to 56Kbps. But, if you wanted to use crazy-go-nuts VoIP prices, you’d just set yourself up with a VoIP provider. So let’s pretend this really is a PSTN line. It’s $9 less the then Netspace includes-phone-line offer, and you get 130Gb instead of 20 (which I can’t imagine using, so no advantage there).

So, the choice comes down to TPG’s Super Fast Standard /130GB ($61) vs Netspace’s naked ADSL2+ Super 15 Anytime ($40 + VoIP provision). $21/month is a lot of money to buy VoIP with, so I think, perhaps, there’s a winner. We can get a ported number and all the calls we’d make for about $10 from a bunch of VoIP providers.

As for the mobiles, TPG has a $1/month mobile plan with really good per-minute rates – and, importantly, no included calls. They provide bonus data to TPG customers on this mobile plans, but given I don’t use data on my mobile plan – meh, not a compelling reason to sign up with TPG. Each phone has a $20 sign-up fee. I’d expect our phone call costs to be… $5 or maybe $10 a month on this plan.

So, if we go with Netspace for the naked DSL and TPG for the mobiles, our monthly spend will be about $60.

Weird bug

Weirdest bug I’ve seen in a long long time. If I delete the star out of the following text:

Ubuntu is coming out with a Long Term Support version (3 years) real soon now. It’s got a few cycles to go before it’s released in April. I want it now, so I downloaded Lucid Lynx* alpha 3, and found some weirdness – which you’d expect in an alpha release.

WordPress says it doesn’t know what or who I’m talking about. “Post? What post?”

One character. Two days to make that reproducible.

Weird. FAIL

Ubuntu is coming out with a Long Term Support version (3 years) real soon now. It’s got a few cycles to go before it’s released in April. I want it now, so
I downloaded Lucid Lynx* alpha 3, and found some weirdness – which you’d expect in an alpha release. is meant to be some kind of bug reporting thing for Ubuntu. It does everything it can to stop you reporting bugs. Everything. First of all, it takes a bazillion years to figure out what product you’re trying to report a bug for. Then once you’ve finally found it, there’s a link on the RHS for reporting the bug, which proceeds to tell you to stop bothering them with all these bug reports, try this method, try some other method, why don’t you do this instead. Oh, and by the way, if you hand craft a URL a little like this we’ll let you into the magical inner sanctum of people who care enough to have read all the way through vast swathes of text trying to figure out how a bug report can actually be filed.

Once you’ve made the magical incantations, the tool tries to distract you with other bugs that sound just like the one you’re filing, except for other products. If you’re clever enough to create a bug title that fools it, finally it lets you enter the details. Then, in a fit of pique, it says after you submit the bug:

Sorry, something just went wrong in Launchpad.

We’ve recorded what happened, and we’ll fix it as soon as possible.
Apologies for the inconvenience.

Trying again in a couple of minutes might work.

(Error ID: OOPS-1535F528)

Gagh! I’ll just hit the ‘back’ button and ZOMG! Fscking Ajax ate my bug report! How the freak am I meant to re-submit that, you *#$%&@$*%@#*!

They can go get stuffed. Worst. Bug reporting. Ever.

Microsoft Laser Mouse 7000 Recharging Problems

I love Microsoft hardware, regardless of what you think of their operating systems it’s hard to argue they make good mice and keyboards. I bought a new mouse yesterday – a Microsoft Laser Mouse 7000 and left it to charge up overnight but this morning I found it hadn’t. The charge light was flashing red, instead of pulsing green (recharging) or solid green (recharged).

A search shows that this model has problems with its supplied battery. I tried the quick fix for the Microsoft laser mouse not recharging, putting a folded piece of paper on top of the battery to make it press on the battery detector, but this didn’t work for me. A new battery, somewhat thicker than the one supplied by Microsoft gave an initial green glow before it too started flashing red.

If you want to know what battery works with the mouse try an Energiser Rechargeable 900mAh. It has a slightly longer positive terminal and slightly larger girth. The mouse is now recharging fine.