May 21, 2008

Cool Python hack

Filed under: Uncategorized — Tags: , , , , — alsuren @ 12:58 am

Some of you might be familiar with python (or haskell, or erlang or …)’s map, filter, and reduce functions. You may also be familiar with lambda expressions, and think that they’re really ugly (especially in python)

If so, check this out (genuine input and output lines from ipython)

In [358]: filter(var==2, [1,2,3,4,5,4,3,2,1])
Out[358]: [2, 2]

In [360]: filter(var>=2, [1,2,3,4,5,4,3,2,1])
Out[361]: [2, 3, 4, 5, 4, 3, 2]

In [363]: filter(var>2, [1,2,3,4,5,4,3,2,1])
Out[362]: [3, 4, 5, 4, 3]

So how did I do it? Well if I could get it to indent correctly then it might look like this:

class Placeholder(object):
    def __lt__(self, other):
        def match(arg):
            return arg < other
        return match
    def __ge__(self, other):
        def match(arg):
            return arg >= other
        return match
    def __le__(self, other):
        def match(arg):
            return arg <= other
        return match
    def __eq__(self, other):
        def match(arg):
            return arg == other
        return match


Now, I *think* this should generalise to map as well, for things like
map(var*5, [1,2,3,4,5,6,5,4,3,2,1] )
just implement __mul__ and friends. Annoyingly, there is also an __rmul__ function, so you don’t know which will be called. Also, don’t let python try to use __cmp__, because it actually checks the type of its return value (so you can’t return a curried function)

Okay, that’s enough g33k for tonight.

[edit: fixed lessthan and greaterthan signs]

May 18, 2008

Oh Microsoft-chan. How we laughed

Filed under: Uncategorized — alsuren @ 9:29 pm

Alex pointed me at, saying it was confusing him. I’m not surprised: It appears to be made of epic lolz (as you might expect from redmond)

From what I’ve gathered, it’s basically a patented, “secure” version of zeroconf, for use in p2p applications. “Features” include:

a) public key “secured” name resolution, of the form hash(key):name.
b) IPv6 only.
c) Can be extended to the internetz at large, using a known server (provided exclusively by MS).

Now correct me if I’m wrong, but surely 1 is not possible in a P2P system? Here’s my thinking:

1) The client must have before-hand knowledge of the public key.
2) The server must have knowledge of the private key.
3) All nodes in a P2P network are both clients and servers.
4) For commercially installable software, the client machine cannot be trusted.

5) 2, 3 imply that all copies of the software include the “private” key.
6) 4, 5 imply that the private key cannot be trusted

lolz on line 6.

So a) is not valid for the target market (to be honest: why the hell would you want security at the dns level anyway? Surely that’s what SASL crap and SSL are for?)

b) is probably about the only thing I’ve found that you need IP6 for.

c) makes it a bit like standard DNS then, I guess… except without the whole “dhcp support” or “interoperable implementations”, or any of the things you might want to help you avoid painful configuration issues.

May 13, 2008


Filed under: Uncategorized — Tags: , , , , , , , , — alsuren @ 9:57 am

I don’t need to talk about the blues dancing workshop, because a) it was obviously going to be amazing and b) rob has already blogged about it:

The other important event of the weekend was that my mum and dad came up. They have a van, which is a complete tax dodge, but nevermind. This means that I will have no trouble getting my stuffs back home in the holidays. They also brought my eeepc.

Now the eeepc does live up to its name: it’s very [squ]eee and quite [w]eee. There are a few little gems about it: the charger is like an oversized phone charger, for example, and there’s a light on the webcam that tells you when it’s being used. The user manual is pretty priceless. Version E3509, which I found and mirrored here:
gems include:
“The solid-state disk drive’s head retracts when the power is turned OFF to prevent scratching of the solid-state disk drive surface during transportation” — 1-5
The finger in 1-7 pointing to the power button
Section 5 contains some really useful hints for optimising windows XP for low disk usage. It seems that you can get windows (without office obv, and no backup partition) into about 2GB. The Xandros they have installed contains a complete recovery partition and OOo, Konq and Firefox, Kontact and Thunderbird, and webcam utilities etc. and leaves you with ~ a gig (can’t remember, and I need to run: will add the real number later.)

The only peeves I have are the windows-like “single user, who’s able to do pretty much everything” feel, and the large quantities of bespoke that have been piled on (you can’t set konq to do tabbed browsing, for example, and they’ve renamed *everything* apart from firefox) Also, it took Tom K to show me where the ~ was, after 5 minutes of my complaining.

So yeah: might be installing xubuntu if anyone can lend me a decent sized usb stick or remind me where my old 1GB SD card went. kthxbi

Blog at