Categories
Random observations

New work address

As of Monday, NICTA’s Queensland Research Lab will be located at UQ. Here’s the address:

Queensland Research Laboratory
Level 5, Axon Building (47),
Staff House Road,
St Lucia  Qld  4072

PO Box 6020,
St Lucia  QLD  4067

Categories
Random observations

I’m a Diigo convert

Today I discovered Diigo. Diigo is a bookmarking tool like del.icio.us, only, in my opinion it is vastly superior. Instead of just bookmarking, you can select a chunk of text in the page, and attach a sticky note to it. When you return to that page later on, there’s your sticky note waiting for you. Hugely useful for doing research. Yes they’re in direct competition with del.icio.us, but they’re also smart enough not to make you completely ditch del.icio.us: you can easily set up your Diigo account so that any bookmark you save to Diigo will be cross-posted to your del.icio.us account.

Check out my Diigo profile if you’re interested.

Oh, and this blog entry was written from within Diigo.

Categories
Random observations

The Get out Clause and Weezer

I’ve got some time to work on the context manager today, and I’m listening to some stuff as I code. Here’s a sample:

Also check out The Get Out Clause and this video. It was made by requesting CCTV footage through the Freedom of Information act (apparently).

Update: Here’s the “Paper” video clip inline:

Categories
Random observations

Rediscovering closures and nested functions

When you’ve spent years coding pretty much everything in Java, it’s hard to break out of the Java way of doing things. It means that you tend to forget that other languages might have things called closures, for example. Here’s how a closure looks in Python:


lambda x:dosomethingto(x,anothervariable)

The neat thing is that this closure can be passed around like a first class object. Also, anothervariable, bound in the outer scope, is accessible to the lambda expression when it is invoked later. You can do stuff like:


if isinstance(somevalue, int) or isinstance(somevalue, float):
  isfunny=lambda x:log(x)>somevalue
else:
  isfunny=lambda x:isalpha(x) and islower(x)

funnyitems=[item for item in mylist if isfunny(item)]
seriousitems=[item for item in mylist if not isfunny(item)]

Sure there are other ways to do the same thing. But this is arguably more elegant.

There’s also nested functions, which are kind of like closures. Rather than contriving an example, I’ll give one from the book I’m reading, Programming Collective Intelligence. In chapter 8, a crossvalidation function is defined. Forgetting the specifics and purpose of this function, just know that the crossvalidate function returns low numbers for good solutions and high numbers for bad solutions. Earlier in the book, we’d already been introduced to optimisation problems and cost functions. The cost functions take a single argument, which is a potential solution to be costed. The crossvalidate function takes a bunch of parameters, so for this and other reasons it can’t be used directly. But you can do something like this:


def createcostfunction(algf, data):
  def costf(scale):
    sdata=rescale(data,scale)
    return crossvalidate(algf,sdata,trials=10)
  return costf

So now your costf function knows about algf and data, despite not having them as parameters. That is, the bound variables to algf and data are available to costf when it is called at some later time:


costf=createcostfunction(knearest,mydata)
annealingoptimise(wdomain,costf,step=2)

So when annealingoptimise eventually invokes costf, costf has access to knearest and data. That is the bindings of algf to knearest and data to mydata live on after the execution of createcostfunction completes. Cool.

Categories
Random observations

Mod_wsgi

Forget my previous entry about mod_python. Just use mod_wsgi. It compiles without issues on the Mac (unlike mod_python, which is why I made a binary available for it), and seems to be the future for Apache/Python integration. See Graham’s comment on my last entry.

Categories
Random observations

Mod_python for the Mac

In case anyone’s interested, I’m making available a pre-built universal binary of mod_python 3.3.1 for Apache 2.2.8. I’m running Mac OS X Leopard 10.5.2 and Python 2.5.1. The DMG contains an installer package, and it will try to install mod_python to /usr/libexec/apache2, which is where the other apache modules are usually located. Use at your own risk.

You can download it here.

Categories
Random observations

Python

Newsflash: Python would be okay if whitespace wasn’t meaningful beyond separating tokens. List comprehensions are kind of nice.

Categories
Random observations

Gary Busey: bizarre

This is bizarre. Ryan Seacrest of KIIS FM and E! was doing an interview of Jennifer Garner and Laura Linney at the Oscars when Gary Busey interrupted the interview and kissed Garner on the neck. The next day, Busey calls Seacrest on his radio show and, well, I’m not going to try to explain it. Just listen to it. Watch the Oscars incident first…

… then visit this site and click the first “play” button on the right.

Credit to the Breakfast program on Triple J for bringing this to my attention a few weeks back.

Categories
Random observations

The Book Depository

Karen came across a fantastic online book store called The Book Depository. Its prices are highly competitive. But the best part is that they offer free shipping worldwide. We’ve already ordered five books from them: That’s Not My Puppy; That’s Not My Lion; Dear Zoo; The Art of the Start; and Programming Collective Intelligence. They arrived separately, but all within a week, in well padded packaging. One word of caution: be sure to visit the right web site. It’s http://www.bookdepository.co.uk/, NOT http://www.thebookdepository.co.uk/.

Categories
Random observations

Dressing for work

Ricky fashionProceed with caution: Ricky writes about fashion!

Lately I’ve noticed that I tend to dress differently for work depending on what I’ve got on my agenda for the day. Knowing that I’ve got something particular to do on a particular day is an improvement on the past for a start, and I put this partly down to GTD. Anyway, I seem to dress very casually (sometimes shorts and sandals) when I’ve got coding to do, colourfully when there’s an internal meeting to attend (e.g., a brainstorming session) or when I’ve got artsy/communications type stuff to do, and a bit more formally when I’ve got meetings with external parties. Dressing in a particular way seems to help me to get into the right frame of mind for the task at hand. This is a change from university days when shorts and sandals were the norm.

Today I’m wearing my stripy purple shirt with the sleeves rolled up and Hard Yakka drill trousers: a compromise given I started the day with a staff meeting and finished it in the coding trenches.