Older blog entries for spiv (starting at number 3)

Physio

Physiotherapy is great, but expensive when you have it several times a week. I think my shoulders are slowly improving without needing physio anymore, so I probably won't be making any further appointments. It'd be good to be able to stop consciously thinking about my shoulders and wrists, though.

Twisted

19:21 <adiabatic> get a flower and say to yourself "how can one screw up sending a filelisting via passive FTP? let me count the ways..." and then start plucking petals

0.18.0 was released a while back, and seems to be solid. Unfortunately some of the FTP unit tests are failing again, and there seems to be really nasty timing issues involved -- adding a blank print statement to a single-threaded program should not make a test pass. Similarly adding a time.sleep(0.1) call somewhere else shouldn't make another test fail.

The FTP server code is sufficiently ugly that I think I'll simply rewrite most of it, and see if the bug goes away. It needs a rewrite for other reasons anyway, it should be using stuff like twisted.cred. I suspect this is simply a different manifestation of the same bug that causes the bulk of the FTP tests to fail on Win32. At least I'm reasonably certain the bug is in the server and not the client code, which means it's not my fault ;)

PyGTK

I had an opportunity to muck around a little with PyGTK this afternoon, helping a housemate plot a wave to a pixmap in a window. It turned out to be surprisingly difficult, mainly due to us making various incorrect assumptions. I stupidly assumed that the colormap's alloc method took 8-bit RGB values (I'm too used to HTML), whereas it took 16-bit, meaning that I everything I did seemed to come out black. The other big problem was that the pixmap persisted between invocations of the python script! That meant that making a change and trying that, then undoing the change and trying again would not give the same results as the previous time until we explicitly cleared the pixmap with a draw_rectangle call. GUI programming is painful.

Python

A small problem that I occasionally bump into: sometimes you want to iterate over every 2nd item of a sequence (or more generally, every n'th item). I'm yet to find a satisfying solution to it, as it doesn't map cleanly onto a for loop, and slices don't support skipping n elements like that. You could do it with a generator that keeps a counter internally, or perhaps subseq = [seq[x] for x in range(0, len(seq), 2)]. Actually, that list comprehension isn't so bad, that didn't occur to me before. I guess I'm just feeling spoilt by Python's tuple unpacking that allows stuff like for a,(b,c) in [(1,(2,3)), (4,(5,6))]: ...

Ouch
My shoulder and neck have been hurting alot. I'm seeing a physiotherapist about it, and I've realised it is due to bad posture. I've fixed the problem at work, thanks to an adjustable chair, but my home computing environment is the real problem. I'm currently sitting on an "executive" style chair, which means it leans back if I lean back at all... very comfy, until you find yourself hunching forward to counteract the leaning back. Hence the severe pain. Moral: Posture is important. And don't wait a few weeks hoping the pain will go away by itself.

SLUG
A month ago, I allowed hypatia and jdub (both of who I live with!), who are on this year's SLUG committee, to convince me to give a talk on Python to SLUG. I was assured the Perl bigots would be gagged ;)

I'm generally not a confident public speaker, to say the least. I've had many bad experiences with hand tremors and general nervousness making public speaking a real nightmare. Also, my previous talking experience has never been for more than 10 minutes, and a SLUG talk is typically 40, so I was starting to feel quite worried as the hour of the talk approached. However, I felt very confident that I knew what I was talking about (as opposed to half-researched uni assignments), and I apparently gave a really good talk. People asked questions during and afterwards -- and I could answer them. And it is really, really wonderful to have people come up immediately afterwards and say "Thanks, that was a really good talk". It sounds so simple but it is such a great feeling to receive that sort of compliment. Thank you to everyone who was kind to me after the talk!

I was unsure of what I should say. I didn't really know how many people were at all familiar with python -- or indeed with programming in general. I decided to do a broad, but shallow talk, which means I covered lots of random things, but didn't spend very long on any one thing. My reasoning was that Python is easy to learn, and there are good tutorials on the web that can probably teach it better than I can, so instead I should try demonstrate why you might want to use Python. The format of 10 minutes flicking through the basics ("here are the built-in data types, here's what functions and classes look like"), followed by an overview of Python's object system, functional programming, and random odds and ends (the talk was roughly 40 minutes all up). Things like interactively using the dis (disassembly) module and the one-liner mandelbrot generator were nice examples, I think. People also seemed interested in the wacky stuff like generators and nested scopes.

Perhaps the most remarkable thing about the talk was that people found my joke about Singleton funny :) Singleton is where I grew up, and it has the southern hemisphere's largest monolithic sundial (the sign in the town simply says "WORLDS LARGEST SUNDIAL"). People don't expect a picture of a big concrete sundial to appear on slide about implementing the "Singleton" design pattern...

Neato
Hooray... updating my diary from the Python interpreter. Very cool.

Twisted
My FTP client for Twisted seems to work well. I'll check it in tonight. It feels odd to be rewriting something as common as FTP, which you just get used to taking for granted...

14 Mar 2002 (updated 14 Mar 2002 at 08:54 UTC) »

Ok, I finally caved in and got an Advogato account :)

Twisted
I've just been given CVS access to Twisted, for my efforts in writing a version of the main loop that uses Win32 events. It's painful, but hopefully should be working nicely and elegantly one of these days. Itamar has a nice job of testing it, finding problems, and making it work. For some odd reason the website is down right now, though.

It's neat to know that code you've written is available via apt-get, albeit a small piece of a much larger project.

Twisted is great fun to work with. The source is quite nice too, although the documentation is still a bit lacking.

glsnake
Jaq has mentioned glsnake before, but I'm very happy with it. I'm going to write some Python bindings for it soon, just because I can...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!