Older blog entries for Ankh (starting at number 135)

I was reminded today by something a deviant art person wrote (and no, I'm not Ankh there, someone else got it) that I haven't posted for a while a link to the Simple Path to Live By. I try to follow it, but it's very very hard to live up to such a difficult standard.

My piano is back in tune. I am thikning of getting a Yamaha electronic keyoard, maybe the DGX505 or maybe the S90, does anyone have recommendations? I want to play with some music software, preferably on Linux of course!

raph, will pictures of money do? (there's a larger version linked from the parent page too).

The scans of Centaur look cool; I did briefly try your code, but then went on a trip to working group meetings and forgot! No surprise that you got a lot of interest from the typophiles. How to make money from type design is a major part of most type designers' lives as far as I can tell. They want things like food, shelter for the Mac, and sometimes even shoes!

A week of all-day technical Working Group meetings can be pretty tiring.

ncm - your article didn't mention which programming language to use, and although it's clear the approach I posted isn't what you were thinking of, it doesn't depend on any external libraries. It doesn't need to: dates and times are first-class native datatypes in XPath 2 and hence XQuery.

Date measurement algorithms, like binary search functions, are things that many (most?) people find difficult, and there's a good reason to encourage people to use libraries.

ncm, choice of programming language makes a big difference.

let $second := xdt:dayTimeDuration("P1S"), $time := xs:dateTime("2004-02-29T23:59:59") return $second + $time

works in XQuery (e.g. try it in Saxon).

Admittedly this doesn't have the lexical form you wanted for input or output, but it shows that some problems become a lot easier when one switches language.

It's also pretty easy in Perl :-)

OK, off to California for yet another business trip. Oracle has two buildings shaped like disk drives (deliberately so) in Redwood Shores. Possibly a trip to Fry's with a friend from Italy who will also be coming to the meeting.

We're working on a review of the latest drafts of XML Query and associated specifications; there were new public drafts just posted. XML Query seems at first to be a huge language, but in fact it's probably comparable to C, with the function library being compared to something like the C/posix libraries. Unlike C, though, it's declarative, and has XML items as fundamental data types. You can include XML fragments as literal constants too, of course.

AlanHorkan, I really liked the Inkscape calligraphy screenshot you posted. I'll have to try it when I get a chance to upgrade Inkscape, although I don't have a tablet and I suspect it's needed. If you like such things you can see some of my own calligraphy using more traditional media. :-)

pipeman yes, MikeLowe has been posting links to a commerce site here for some time, using a number of different usernames. I've marked him as uninteresting "1" and I think if enough people do that, maybe it will help.

Probably I (we) should take the time to complain to the ISP hosting the Web site. I get so much spam in my inbox (it's a pain that my email address at work is very public) that I usually only follow up two or three a week, mostly ebay or paypal scams.

haruspex *laugh*, no, that's not what I meant at all! It's a tiny detail, but what's interesting is to think about whether there comes a point at which tiny details don't matter, or if they all add up. It's rare that I've seen more than a megabyte or so of savings in a program by reordering structs, and usually there are larger gains to be had elsewhere. Those who start out not thinking about architectural details and code without worrying about memory will get bitten, though.

So a minor point, and all I can say is I was bored :-)

In order to declare a C struct sensibly you need to know a little about alignment and machine architecture, at least if you want to avoid objects with holes in them. Does it matter? Programs that use more memory than they need to run slower simply because of the paging overhead. The case where all programs fit into main memory seems increasingly rare on an out-of-the-box Linux system, and even minimalist ubergeek systems like NetBSD run on computers with finite amounts of memory, typically with more disk storage space than memory. So application memory competed with the disk block buffer cache. Every little matters at least a little.

At one time there used to be some commercial software that stripped away duplicate copies of C++ class dispatch tables generated by inefficient C++ compilers, saving (they claimed) about 25% of executable space and boosting startup time.

I mention this for no particular reason except that I think it's all too easy to fall into the trap of thinking that memory is cheap and mempry usage unimportant. Most profilers won't help you detect slowdowns caused by wasted space.

deekayan, yes, Mandrake is a Gnome release behind; it's not so much because of profitability but because the Gnome releases come out just after the Mandrake Linux release freezes. For my part it'd be worth delaying a Mandrake release by a month or so, but there's an obvious hit in revenue if they do that, not just for Mandrake but also for resellers.

anderson, what your diary entry didn't indicate to me was, why would i want to join DotNode? Saying that it's like Orkut isn't a strong incentive: once one has joined, orkut loses interest, or so it seems to me. Mostly becuase you can't link to pages within it. It's not bloggable.

Kerry, good luck! :-) :-)

On cross-platform development, I've always been interested in the idea of control objects (widgets, knobs, etc) that hook up to (conceptually) remote interfaces. I suppose a modern way to say it would be a collection of control/manipulation/display obects that use RPC or Web Services to connect to an interface, and that also are connected to each other by ThingLab-style constraints.

Then you get a very distributed application indeed, where the user is in control -- it's a way to open up a model-view-controller architecture.

In terms of toolkits, of course I always liked The NeWS Toolkit, or did after I'd started to get somewhere with it, and in away it shares some of this design: you could send a method to an object without needing to know where the object lived, at least in principle, whether in the client part of your application or in some display server somewhere. But it wasn't exactly cross-platform :-)

Haruspex, I wonder how many other active Advogatoers are in Toronto?

Someone asked me a question about refactoring code today so I thought I'd share part of my reply.

He was thinking of replacing lots of special-purpose functions (hasCar, hasTractor, hasTruck) with a pair, hasVehicle and getVehicle. This leads to:

if (hasVehicle(Marvin)) {
    theVehicle = getVehicle(Marvin);
    drive(theVehivle); // or whatever
}

A better idiom, though, might be

theVehicle = getVehicle(Marvin);
if (theVehicle) {
    drive(theVehicle);
}

This avoids a number of problems. One is that it can be made thread safe, whereas the first idiom has a race condition. Another is that it's more efficient. Another is that the resulting code is slightly simpler, easier to read and understand, and hence less error-prone.

It does have the down side that tehVehicle has scope outside the test, so you can improve it (in C) with

{
    sometype theVehicle;

    /* above code goes here */
}

In C++, Perl and other languages there are other idioms for short-lived local variables, of course.

Although my friend's question wasn't actually about vehicles, I should also note that in choosing a new name for refactored code you need to choose a name whose meaning is obvious from the context in which it's used, so that people don't have to go and read the documentation for your function whenever it's called. Not that documentation is a bad thing, but only that program code that's easier to understand is a good thing.

There was recent discussion about XLink and linking in XML on the xml-dev mailing list; I'm pleased to see a few people talking about the more general problem of representing and discovering relationships, which can then be implemented as hypertext traversal.

Anyone running some flavour of Unix and Apache willing to help test a web log analysis script? I've been using it since 1999 or so, and am in the process of cleaning it up for others to use. It'll be on Sourceforge when I'm satisfied it's a little cleaner :-)

I'm in upstate new york (Oswego) this week to help Clyde (my husband) move to Canada (yes, husband, get over it!). But it's a working week so I'm not sure how much I'll actually be able to help.

Oswego is a town of maybe 10,000 people, surrounded by American chain stores like Walmart, American fast food chains like Subway and Dunkin' Doughnuts and McDonald's (at least two of each of those I think), two nuclear power plants and a campus of about 10,000 students. The campus and town have a slightly uneasy and distrustful relationship with each other. A couple of years ago a local pizza store refused to serve a couple of students onthe grounds that they had dark skin. Then the place was picketed by students. Then the owner burned it down and collected the insurance.

I'm glad Clyde is getting out of here. The university, however, offers one of the best courses in graphic design and fine art in the area. It was very weak on typography -- I think Toronto's York University's joint programme with Sheriden College is much better from that point of view. But SUNY Oswego was stronger on ceramics, which interested Clyde, and the York degree wasn't offered when he started. Now he has graduated and it's time to finish moving to Canada and settle down :-)

I've been sleeping a lot this week. Part of it is that I was tired after a 40-hour trip door to door home from Japan, but another part is depression after losing one of our two pet cats, and part is being a bit overwhelemed with all the stuff we have to do in the next few weeks, including probably moving house and sub-letting this one. I'm tempted to cheer myself up by buying a computer, but I'm not sure that's very responsible! I did get to look at lots of digital cameras in Japan, although they're way too expensive there.

Spent some time getting a sourceforge page set up for some Web log summary scripts I wrote years ago; some of the documentation is up, but not the code yet, because in writing the install notes I decided it was all to horrible and I want to improve it first!

*

robocoder, I'm aware of two main dangers of relying on captchas (e.g. images of hard-to-OCR numbers used to try to keep spambots out and let people in). The first is that blind people can't use them, and in many cases this can be discriminatory and illegal, so you have to provide an alternate method that's not so difficult as to be discriminatory in itself. The second is that these systems can be easily broken if there is a financial incentive. There have been reports of spammers using a system that relays the captcha questions onto a free porn site registration form, for instance. When someone registers, the corresponding hotmail (or whatever) registration is completed by the software. One way round that is to use text questions that incorporate the name of your Web site in the answer, I suppose.

Ingvar, if it takes a C program 14 seconds to read 43MBytes of data on a reasonably recent computer, either the data format is very very intricate or it expands into using an awful lot of memory when unpacked.

If you're not doing it already, use profiling tools such as gprof(1) and maybe consider using mmap(). If there's no obvious function using more than 10% of the time, maybe consider inlining some frequently-called functions r turning them into macros (depending on which compiler you use). Compiler options can help too.

My hololog program reads a 50MByte or so httpd logfile in Perl in less time than that, including matching multiple regular expressions on each line. On a 250MHz Pentium 1 "Pro" system with 128 MBytes of RAM and slow 7200RPM disks. But it should be a lot faster if I work on it some more some time, I suspect.

Sometimes a good compromise is to write a C program to read the data and extract some of it into a text format (e.g. XML-based), and then weed it further in Python or Perl, or even XSLT or XML Query.

My flight back from Tokyo was delayed by 17 hours, which I had to spend at the airport gate, where there's no restaurant. American Airlines didn't tell us the flight was delayed until the next day in time for us to book a hotel (they were all full), although they knew at least two hours earlier, since the pilot and crew had left, luggage and all. Other flights to the US took off after ours was canceled because of the typhoon, including at least one American Air flight with a similar aircraft. I value honesty very highly, and am not sure I want to continue flying with American Airlines, despite the extra room in economy and the laptop power outlet.

I'm thinking of offering a reward for anyone who can fix X11 (x11.org) with an ATI graphics card in a laptop so that it can switch to and from an external monitor without restarting X or rebooting, just like Windows 98 manages so well. Maybe I'll start by offering a pair of socks. Black ones. Argyle if you like. It's such a pain to speak at conferences and when you need to restart X in the break before your session the AV person sneers, "oh, a Linux user, they always have problems". It's a worse pain at workshops when you can't suddenly decide to project without losing all your windows. And XFree86 3.x used to manage to switch just fine on the same hardware.

Someone ordered a CD of some of my pictures scanned from old books so I'm finishing off the images they requested before sending off the CD. It's making me wonder if I could make the GIMP faster by hand-optimising the convolution filter code. But it's hard to believe it isn't already pretty well tweaked. A convolution filter on a 5,000 x 4,000 pixel image takes too long for my comfort!

Thinking about my Web site reminds me to say that after a couple of people requested copies of my Web server analysis scripts, I've registered a sourceforge place to distribute them and maybe let others hack at them too. I'll post details later. The scripts give both a more "holistic" overvew than most others, and also a more useful detailed view than others I've seen, and were designed to help build Web sites up from (say) a few hundred hits a day to a few thousand.

*

A couple of specific responses:

haruspex, you can try in Linux to add net.ipv4.tcp_keepalive_time=300 to /etc/sysctl.conf -- this fixes a symptom in which the router forgets NAT associations after 15 minutesor so of idle time. Another common problem is with MTU, and setting that to 1400 with ifconfig may help.

raph, you are often in our thoughts.

*

126 older entries...

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!