MOTD

Message Of The Day

Wed, 23 Mar 2005

22:53 [zork(~)] cat totally-prologing-this.txt

We Will Embrace The Fifth Generation

| ?- append(First,Second,[a,b,c,d,e,f,g]).

First = []
Second = [a,b,c,d,e,f,g] ? n
Action (; for next solution, a for all solutions, RET to stop) ? a

First = [a]
Second = [b,c,d,e,f,g]

First = [a,b]
Second = [c,d,e,f,g]

First = [a,b,c]
Second = [d,e,f,g]

First = [a,b,c,d]
Second = [e,f,g]

First = [a,b,c,d,e]
Second = [f,g]

First = [a,b,c,d,e,f]
Second = [g]

First = [a,b,c,d,e,f,g]
Second = []

Thu, 17 Mar 2005

00:31 [zork(~)] cat of-course-php-is-dongz.txt

MySQL + PHP Still Not a Real Choice

Ok it's really super dumb that PHP pretty much handles MySQL connections to a database server one at a time. No seriously. There are some ways around this, but they are supremely lame, and in the function calls completely optional. So if a person ends up using code that someone else wrote, and that person didn't feel they needed to pass this completely optional argument on their database calls then person A's day can be made very hard. Especially if person A needs to use a couple different databases from one page.

http://us3.php.net/manual/en/function.mysql-select-db.php

Mon, 14 Mar 2005

05:20 [zork(~)] cat hacking-the-guhnome.txt

When in doubt...

...hack it yourself.

Since Warty came out I have become a much more hardcore gui desktop user. I've hacked up quite a few Nautilus Scripts to make my life a little easier, but after "losing" a hard drive on my laptop I'm back to basic Nautilus. Now I've hit an annoying missing feature in it yet again.

Nautilus has this nice context menu that pops up for certain file types and allows to do nice things like add a bunch of files to Rhythmbox, make a tarball, or what have you. What they've never had was a way to make an image your desktop background. I know that this a silly thing to get all crazy about, but it really bugs me that it doesn't support this out of the box.

I used to have a script that would do this for me, but it is kinda annoying to have to right click, wait for the menu, then go to the Scripts menu, and wait for it to come up, and then finally click on "Make this my background." Also since it was attached to the scripts menu it could come up for any filetype which seems a little strange since you could ask the system to make an text file your background. It wouldn't do it of course it just seems like a bit of UI there.

So now here's what I want. I want a context menu for images that says "Change Desktop Background to image..." And then does it. And I would prefer to learn as little as possible about the guts of Gnome and Nautilus in the process. And I don't want to have to do it in C, I'd rather do it in python.

So I whip out google and start to figure out how to do this "simple" task. There seems to be a few python-bonobo tutorials out there, mostly working with making panel applets. Bonobo adds this big maze to some of the Gnome stuff. There are a few tools to manipulate it, but it mostly works like a scary black box. And doesn't appear to like making any log messages at all.

So I start taking apart some apps that use the interface namely file-roller. The nautilus source package also has a pdf that contains some documentation on how to build some interfaces. So I start to learn about bonobo. For instance, did you know that bonobo can be used as a primitive medieval torture device? It's true. Also it has something to do with CORBA which accounts for it's rampant insanity. So I try randomly typing strings into vi and started to get some results. The bonobo query whatnot was telling me that yes it knew about my crazy extension, but nautilus still was not using it.

Why nautilus? Why do you hate me so?

Follows is some of the notes that I was taking:

Try some tricks. ltracing nautilus == crash.

Sure would be nice to find out how nautilus pulls these menu items out
of it's ass.  Apparently it doesn't use the bonobo activation the way we think
it should.  libeel.  More nautilus guts.  Also some eel guts.  Remember to wash
hands.

So in the end it looks like someone decided to extricate all of the bonobo bits out of nautilus. Great. No more bonobo. But now there is no easy python way (at least from what I see) to screw around with nautilus.

I guess sometimes when in doubt just keep doing it the lame crappy way. Ok, back to hacking pgscsh. Hacking the guhnome is too hard today.

Fri, 28 Jan 2005

08:59 [zork(~)] cat cool-python-idiom.txt

Cool Python Idiom

This is a handy thing if you are playing with big stuff in the python repl.

import os
less = os.popen('less', 'w')
less.write( ... bunch of data written out here ...)
less.close()

The great thing is also that you can pass less anywhere that you have a filehandle that you're writing to.

Beaujolais!

What would be really great is if you could make a file object that would invoke less if you have more than $LINES of output in a go. Then you could do:

sys.stdout = less_stdout()

or somesuch.

That would be totally bitchin.

Sat, 18 Sep 2004

02:30 [zork(~)] cat python-abuse-1.txt

THINGS THAT HAPPEN

import UserDict,os

class WriteFileCacheDict (UserDict.UserDict):
    def __getitem__ (self, key):
        if not self.data.has_key(key):
            self.data[key] = open (key, 'w+')
        return self.data[key]

class MagicalFileDict (WriteFileCacheDict):
    def __getitem__ (self, key):
        if not self.data.has_key(key):
            d = os.path.dirname(key)
            if not os.path.isdir(d):
                os.makedirs(d)
        return WriteFileCacheDict.__getitem__(self, key)

[zork(~)] cal
[zork(~)] tree
[zork(~)] syndicate.py
[zork(~)] cat README