2004-05-09 15:42

Hard Python question

I am trying to do something which is, I think, pretty cool, in python.

However, I like showing things working, and I am having troubles with the last final step on what I am trying to achieve.

Since I know a few better python programmers read this...

Suppose I have this:

def fun(self,x):
        pass

class C:
        pass

C.a=fun
C.b=fun

What code should be in fun() so that it figures out if it has been called as C.a or as C.b?

I am thinking something like reading the higher step in a backtrace, but I don't know enough python to figure out how to do that.

2004-05-07 17:39

Updating my palm

I have been using my Palm m100 for appointments and reading etexts for two months already and it has been really really nice.

However, after reading a slashdot discussion, I am upgrading, to a almost-new Sony Clie SJ-30

Reasons:

  • Color vs Black&White (not grayscale)
  • Higher resolution (320x320 vs 160x160)
  • Smaller
  • Rechargeable battery vs AAA batteries. This means that as long as I remember to plug it every once in a while, I won't lose data.
  • I can sell the m100 and pay part of the Clie that way, so it's not all that expensive (about US$100 in the end)
  • More memory (8MB vs 2MB)
  • Memory stick slot
  • Almost everyone likes the Clies as far as I can see. Almost everyone hates the m100. Why? ;-)

The only possible con is that with a nice set of Duracells, the m100 could go on for two weeks of reading about 4 hours a day, and the better screen in the Clie will eat battery much faster (I've read about 2-day battery lifes from some users).

2004-05-07 13:46

Mingetty autologin patch

A student asked me how to autologin on a linux terminal. I thought... that can't be hard... I just don't know how it's done.

So, I googled, and there's a patch for mingetty that allows autologin... but it's for an older version (0.9.4) and I can't even find it.

After a while, I check the SRPM from RH9... and it has the patch in the source tarball, but doesn't apply it. No wonder, since it doesn't work.

So, I patched the patch, and here it is: a autologin patch for mingetty 1.0.1... I have so clear in my mind why I don't program in C :-) (although it was rather easy).

The patch

I even have a patched SPEC file (no biggie there), and even src.rpms that should work on any Red Hat like thing.

After you install the patched mingetty, you can put a line like this in your /etc/inittab

1:2345:respawn:/sbin/mingetty tty1 --autologin=ralsina

And a session for user ralsina will open in tty1. You can't even quite logout, since it logs you back in.

2004-04-13 19:13

Back in the mines

So, I'm back after a 9-day trip to the beach... relaxed, strong, happy... and TV-less since it seems to have burned something inside when I turned it on yesterday.

Oh, well, who needs it anyway.

And next week I'm seeing Kill Bill Vol. 2!

I am a Tarantino fan, and it has so far scored 100% at the tomatometer (www.rottentomatoes.com), so it seems to be good!

On a professional level, I just nabbed enough support contracts to do what I want to do this year.

A reasonable fixed income is something I haven't had in a couple of years, it has been up-and-down, great months and bad months, with a rather nice average, but...

I needed a fixed income this year because I intend to save a couple thousand dollars for september.

Why? Because I am going to meet a fellow KDE developer, the one that's closest going east from Buenos Aires...

2004-04-06 09:37

Why I ain*t posting much

I am on a little vacation. I will be back next sunday.

Also, I*ve been quite busy, and the couple of hours a longish pst takes simply was not there.

And nothing interesting happened, so no short stories either ;-)

2004-04-05 15:25

That*s NOT me!

The Leon County Sheriff's Office has arrested two men in connection with an August robbery of the Petro gas station, 3626 Mahan Drive. The gunmen stole cash out of the register and cigarettes before leaving the store, headed in an unknown direction, said Lt. Linda Butler, spokeswoman for the Sheriff's Office. The Robbery Task Force Unit, following a lead, was able to connect two men to the robbery and arrested Marcus Kitchens, 21, and Roberto Alsina, 23. Both were charged with armed robbery.

THe first time ever I found out about someone with my same name, and he*s in jail :-P

2004-03-29 18:00

Holy smoke!

I decided to bring my office PC into the XXI century by adding a few USB ports to it.

I turned it off. I plugged in the board. I started screwing it... and dropped the screw inside it.

That has happened a billion times before, so I'm not too worried... until suddenly the computer turns itself on, and a awful smell comes from the ISA end of the mobo, along with acrid, black smoke.

I pull the plug, and it doesn't work. It seems to boot, but it makes a constant beeping sound.

Keyboard error.

I put another keyboard.

It all works, except the power LED is now always on as soon as I plug it. But the computer isn't. When I press the power switch, the power LED gets brighter, then it starts.

I wonder what exactly I burned :-)

2004-03-23 16:48

Dcoppython

In a whim, I checked out kdebindings/dcoppython from KDE's CVS.

I see the README: dcopython is broken

Then I said to myself: maybe I can fix it. And you know what? It seems to be not broken! :-)

At least for simple data types, that is.

dcoppython lets your python program become a DCOP server or client.

A DCOP server is capable of being controlled by KDE's kdcop, and is a very simple way to make your application externally scriptable.

A DCOP client is something that contacts a DCOP server, so that means you can control and script KDE applications (or other DCOP servers) from python scripts.

The neatest thing here is that this stuff doesn't require Qt!

I intend to use it to make some of my apps externally scriptable without PyKDE.

2004-03-22 12:19

Tarpitting works. Here's proof.

I have recently enabled tarpitting in one of my customer's mail servers.

Tarpitting is adding a small delay after each recipient (after a certain number of them). The idea is that a message with a few recipients goes fast, a message with many goes slow.

So, it should make spammers less efficient.

Some mail administrators say tarpitting doesn't work. That spammers, instead of sending a zillion mails over one connection, send a few over each of a zillion connections.

But a zillion connections are more expensive for the spammer! Or at least slower.

Well, I have proof that it does work. Sure, something like a per-ip limit on concurrent SMTP connections is a good complement, but even naïve tarpitting, all by itself, has a good effect.

Since I enabled it, peak message rate is down 60%, average is down 40%. Pretty good!

But a picture is worth 1000 words...

Contents © 2000-2019 Roberto Alsina