Tao of the Machine

Programming, Python, my projects, card games, books, music, Zoids, bettas, manga, cool stuff, and whatever comes to mind.


After Doom and Quake, there's now a (seemingly stable) Windows 2000/XP version of Duke Nukem 3D: duke3d_w32. The binaries work, but you need to provide your own duke3d.grp file. This page might come in handy too...

Posted by Hans "who wants some" Nowak on 2003-09-19 22:16:13   {link}
Categories: games


...to everyone who replied to yesterday's request. The general consensus seems to be that my resume isn't "wrong", but there's definitely room for improvement... some things should be worded differently and/or moved around. I will update the resume shortly.

Posted by Hans Nowak on 2003-09-18 22:08:11   {link}
Categories: general


Alright my good people. Check out my resume. I understand that this isn't the greatest curriculum vitae in the world, but what I am interested in is, is there anything here that is an absolute no-no? (By American standards, that is, or better yet, Floridian standards.) Are there parts that sound ridiculous, or will make a possible employer recoil in disgust? Please mail me with any tips for improvement.

Reason for this is, I am curious why hardly anybody seems to reply when I apply for a job. Is it that employers can afford to be rude during a recession (like I mentioned earlier), or is my resume just not up to snuff? (It would be OK in the Netherlands, but this is a different country, after all...) I don't see a huge problem with it. Neither does my wife. But it never hurts to get more opinions.

Posted by Hans Nowak on 2003-09-17 13:25:02   {link}
Categories: general

Autism test

(via Stuart Langridge) An autism test. My score is 27, above average but not in the 'very high' category. Whatever that means.

What I don't like about tests like these is that if you get a certain score, you are associated with Asperger's Syndrome or even autism. Those are negative connotations; nobody starts a conversation with "hey, you know what, yesterday I found out that I'm autistic!", because it's not considered a desirable trait. (On the other hand, maybe that is exactly the kind of thing a real autistic person would do. :-) A low score is considered "normal", a high score "abnormal", and you enter the realm of disorders.

It's all a matter of how you interpret the test. Somebody with a high score would have a good memory, a good eye for detail, and a vivid imagination. Those are good things, IMHO, but the test presents it as something negative. Similarly, somebody with a low score would have little imagination, a bad memory, and not be interested in details. Yet, those people score "normal" on the test. If you score high, you are the one with the disorder, not the non-imaginative, forgetful and sloppy people. Hmm. Something is skewed here.

I am already very doubtful about the existence of some disorders, but tests like these make me doubt even more.

OK, back to my coding... I was at line 457... emoticon:wink2

Update (2003.09.18): See the comments, especially the URL. Seems the autistic person typically has little imagination, contrary to what I assumed.

Posted by Hans Nowak on 2003-09-17 13:09:03   {link}
Categories: general

Return to innocence

I wrote about the Self language before (1, 2), and produced some code to emulate Self-style classes in Python. There's now a new version of that code (available in the download section). The selfish_v2.py and objects.py modules should work in any recent Python, but if you want to run the tests, you'll need the testipy package.

(Basically this update came about as a detour from my "editable source" idea. I got carried away playing with new.instancemethod. :-)

I got rid of the SelfMethod class in the old code, and the slots attribute (which had nothing to do with new-style objects __slots__, by the way). The new code relies solely on __getattr__ and __setattr__ for method binding, inheritance and attribute lookup.

In short: A "blank" object is created by instantiating SelfObject. Then you can add attributes and methods to it. You don't add methods by subclassing, since the idea of a "class" (vs an instance) is unknown to Self.

import selfish_v2 as selfish
a = selfish.SelfObject()
a.x = 42
def gossip(self):
    print "She ate", self.x, "hamburgers!"
a.gossip = gossip

An object can have zero or more parents. A parent is any SelfObject that is bound with a name ending in _p. (Self uses an asterisk, but that syntax would obviously not be valid in Python, so I settled for the _p suffix.) If an attribute/method is not found in an object itself, its parents are searched.

b = selfish.SelfObject()
b.name = "Fred"
b.a_p = a
b.gossip()  # calls a.gossip() with a's x
b.x = 2
b.gossip()  # calls a.gossip() with b's x

If you just want a certain method, you can just copy it, by the way.

c = selfish.SelfObject()
c.x = 3
c.gossip = a.gossip
c.gossip()  # uses c's x, not a's

That pretty much covers the basics. You can add special "abilities" to objects by creating fancy objects and then setting them as parent. Currently, there's only one, clonable, in objects.py. "Inheriting" from it makes an object, well, clonable.

a.clonable_p = objects.clonable
d = a.clone()
d.gossip()  # uses d.x (which happens to be 42)
d.x = 4
d.gossip()  # uses d.x again (now 4)

Note that in Self, cloning functions much like instantiating. You create an object, set some attributes, and then use that object as a template for other objects.

I'll have to read the Self manual to see what other objects would be useful for inheritance.

Posted by Hans Nowak on 2003-09-16 22:30:49   {link}
Categories: Python

Metaclasses, reprise

After my little rant about why metaclasses are evil, here's a legitimate use of them: reloadable classes by Ian Bicking. (I believe I've seen this elsewhere, too, though. In the newsgroup?)

I tried writing a non-metaclass version of this code, and while it does seem possible, it requires more work on the programmer/user's part. The problem is that you can use metaclasses as a "when this class is created, do X" hook, and regular classes don't have this. In my "non-meta" version, classes need to inherit from a Reloadable class, and call its __init__. Also, when a class is overwritten (like the C class in Ian's example), you need to call a reload() function that regenerates the old class; there's no automatic trigger like with metaclasses. (I can post the code if anyone's interested, but I can make no guarantees about its correctness.)

Posted by Hans Nowak on 2003-09-15 11:36:42   {link}
Categories: Python

Straight from the source

Here's an interesting one. In some languages (Smalltalk, Self, Lisp) you can have an environment, in which you can edit existing functions or methods, or add new ones. For example, I've seen Smalltalk environments where you can select an object, select a method, edit that method, apply, and the environment happily goes on with the new implementation of the method, working like it has been there since day one. I believe you can do similar stuff with Lisp in Emacs (not sure, I use That Other Editor :-).

Now, would it be possible to do the same in Python? To a certain extent, yes... I can imagine a similar environment with objects. You have a list of objects, select one, select a method, edit that method, apply, stick the new version of the method in the class, and go on. This is only possible if we somehow keep track of the source, though.

Let's say that object Foo must be editable. When loading it, it should be processed in a special way... maybe it's stored specially, so we can create the object, then stick methods in it from source that was stored somewhere for this purpose. Or maybe it's possible to take a "regular" Python file and parse it in such a way that the source of certain methods becomes available as strings.

Python is a multi-paradigm language, though, and I wonder if it's possible to do this trick with *any* object. Add a function, method, class, then edit it later? There doesn't seem to be an easy way to accomplish this. A few problems:

  • How will we store the source? (One approach could be, to use an attribute 'source'... the source for function f would then be in f.source, etc.)
  • Can we get source from existing, "normal" Python files? E.g. if I have a module with functions a, b and c, how will we extract the source for these functions?
  • How to store and restore the environment?

Ideas are welcome. :-)

Posted by Hans Nowak on 2003-09-14 23:57:10   {link}
Categories: Python

Sweden says no to euro

So far, the euro hasn't been a great success in the Netherlands. I can't speak from experience, really, since I left for the US before the euro was introduced. However, this is what I grokked from conversations with family and friends so far. (Dutch readers, feel free to correct me.) The story of the euro in 5 easy sentences.

Dutch government: Let's introduce the euro! A referendum will not be necessary, since we know what's best for everyone.
Stores: Ha, this is a good opportunity to raise prices!
Bars and restaurants: Even better, let's just replace the guilder sign with an euro sign!
People: (complaining)
Government: According to our statistics, prices didn't rise in 2002.

I don't understand how the Swedes cannot want this. emoticon:devil

Posted by Hans "goud zij met ons" Nowak on 2003-09-14 22:19:55   {link}
Categories: general, Nederland

Google In-Depth

I wrote a little program that might be useful to some. (At least it is to me; I use it to look for BitTorrent files.) Google In-Depth gets the URLs from Google search results, then scans those pages for certain other URLs. (For example, I search for "manga .torrent", then scan the resulting pages for URLs ending in ".torrent".)

Posted by Hans Nowak on 2003-09-13 22:08:54   {link}
Categories: Python

Generated by Firedrop2.