Older blog entries for wspace (starting at number 28)

First of all I am totally disgusted by the attack on Madrid. Don't know how to do something about it, support the Spanish, write about it, buy Spanish wine, whatever.

I decided not to put here a big anti-arab and anti-terrorist rant I wrote. But things here in Europe are starting to look grim. In the USA you don't have that many arab people, but in Europe it is really running out of control. There is a *huge* difference in culture.

Back to software development etc.

via Martin Fowler to a Ruby library for XML.

There is this example from Java
for (Enumeration e=parent.getChildren(); e.hasMoreElements(); ) { Element child = (Element)e.nextElement(); // Do something with child }


and then a Ruby evangelist writes that in Ruby it is so much better because it is


parent.each_child{ |child| # Do something with child }


and then there is "Can't you feel the peace and contentment in this block of code?. Ruby is the language Buddha would have programmed in."


Talk about a difference in culture. If Ruby is still for you then you are very different from me.

Next time you develop a tool call it a "Distributed mobile data-driven XML application". Interoperable. Buzzwords compliant. Great.

But now there is a new problem whenever a bug is detected: where is the bug.

pyps.py

I have to draw a lot of boxes and arrows diagrams, so I am currently hacking on a Python module for creating diagrams in .eps.

That is useful when you need to include it in LaTeX. There will also be SVG support, but first I want to get the design right. It has a Box, Circle (Curve), Text and some Arrow classes already, with dash, rotation and scaling support.

It is not just for drawing, but for programming such diagrams. The idea is to be able to write a program like

p = pyps.FileContents()
b1 = pyps.Box()
b2 = pyps.Box()
a = pyps.Arrow()
p.add(b1)
p.add(b2)
p.connect(b1, b2, a)
print p.epsText() 

in this example without having to specifiy coordinates at all. I am still thinking about the design for the connect method so that is not there yet. An example created with pyps is here. It was created as .eps and then translated to PNG with ghostscript (Windows install). Also shows a weakness of the Windows ghostscript: it could not find all the right fonts.

It has been a while doing such OO things, but this seems like a good case for OO. If you feel like trying it out, your comments are welcome!

Once it is mature enough, maybe there are other people who would like to join and start a project at Sourceforge.net?

Better writings with an editor?

I read several writers who wrote books back in the 1970's. They did not have editors then, just typewriters. Seeing a smart remark of one of those writers recently in the newspaper, it made me wonder if today they would even write better. It is so hard to write without an editor! Would their books be even better when written with an editor? Are we writing better books these days?.

XML

On second thought, maybe XML isn't all that bad. What about handling tabs, unicode, namespaces, processing instructions, schema declarations, ...

But recently I had to "code" a lot of small XML snippets with an editor. Not just configurations files, all sorts of stuff. Maybe I can come up with a simple translator tool, from human-readable-editable to XML and back. Should not be too difficult. Except for all the fancy XML stuff mentioned above.

If you *are* using indentation, why use XML?

The example by Linus:

    # This is an example
    myhost.com
        passwd Make1Up
        timeout 50

yourhost.com passwd Crappy4You timeout 0

instead of

    <!-- This is an example -->
    <host>myhost.com
       <passwd>Make1Up</passwd>
       <timeout>50</timeout>
    </host>

<host>yourhost.org <passwd>Crappy4You</passwd> <timeout>0</timeout> </host>

Agreed, much more readable. And parsing is no problem.

But the XML example is not using attributes, and his readable version doesn't have something like it either. The order of elements in a list is significant in XML; the order of attributes is not (it is a *set* of attributes). And you need to have 1 root element in XML.

I have been thinking a bit about it but I am still not sure what a good readable format would look like.

Perhaps

    # This is an example
    host protocol=http [myhost.com]
        passwd 
            type=secure 
            date=112503 
            [Make1Up\=nice]
        timeout 50

Every line has to start with an element, unless it is an attribute or text content of an element.
Attributes have an =.
Text content goes inside square braces, and may be on the same line as the "last" attribute.
Indentation of elements gives the tree structure: top down + indentation corresponds to the root-left-right traversal of the data tree.

But this format does not make clear that the order of attributes is irrelevant. So I am not happy with it yet.

12 Nov 2003 (updated 12 Nov 2003 at 14:12 UTC) »
A solution for spam

How to avoid spam?  A solution is to only open emails
from people that are on your contacts list.  But then
it will be impossible for people to contact you if
they are not on the contact list.

To get on your contact list people have to register their email address at your homepage. To avoid spammers from registering, they also have to recognize a word displayed by a picture, and type it in. There are tools for generating such pictures automatically from a dictionary.

This is the only real solution I can think of. And it will not be difficult to write a CGI script in Python that can handle the registration. I wonder if it has been done already, do you know?

Hey, the word-in-a-picture recognizing thing is also a solution for "blogspam", or guestbook spam.

Look at www.blogshares.com, a site for trading virtual
stocks in blogs. I managed to get this "blog"
registered there, via some trick I forgot in one
of my earlier postings here (they want you to link to
them, once or so).

I don't get it. I did not write here anything for over
a month. And still there are peeps trading my shares
there. While there are others with active blogs and
*huge* share value that don't see much trade. Weird.

mikehearn: You mention
a) High level programming languages are a good thing.
b) C is *the* language for sharing code on linux/OSX/cygwin/solaris/etc.
In the case of Python a lot of time is put into wrapping C libraries. Indeed I believe this is the wrong way to do it. I also believe the other way around is possible, but very hard perhaps, and expensive. Instead of wrapping C libraries: translate Python to C and use the C compilers.

How was your holiday? Hope it was as good as mine! We stayed home, no going to faraway places this year, just enjoying the garden and home.

A friend claimed it would not be possible to do something like a roguelike via CGI. So I did a fun little project during holidays:

http://wspace.sourceforge.net/cgi-bin/webrogue/play.py?name=TestMe&pw=test&action=rest

You can get the source and some notes and a Tkinter GUI for it at

http://sourceforge.net/project/showfiles.php?group_id=72532&release_id=181250

Biggest problem was not the software design but getting CGI to work. The permission issues drove me nuts. It turned out that after creating a new db you have to wait a while before you can use it. Geez.

Unfortunately I am not a webserver wizard so my friend was right it is too slow. But it *is* fast enough with Apache running on my local machine.

If I can find somebody who can improve the performance (perhaps host it?), then it would be fun to add multiplayer and other things. The architecture is simple so adding stuff is not difficult.

There are so much people blogging now that I started to use an RSS aggregator to check what's new. I then moved all the blog URIs that supplied RSS to another subdirectory in my bookmarks (called favorites in Internet Explorer). After a while I realized that I don't use these bookmarks anymore since I read their blog via the RSS aggregator (I use effnews). I only use blog bookmarks for blogs that don't have RSS (or broken RSS :-) And I think more people are doing it this way.

So, if you have a blog, and you want to stay in people's bookmarks, don't RSS.

Heh.

19 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!