GRRR. This new amplifier setup is far from Hi-Fi... I wonder where that 50 hz hum comes from, maybe some sort of boxthingmagic should do the trick - but I'm not a Hi-Fi freak so I don't know... =(

I'm listening to MechWarrior 2 soundtrack... wonderful stuff. I also listened to the Starcraft Terran tunes, because, um, those tunes are among the greatest tunes to start the day with =)

Anyway, I'm off to the University soon... Maybe I should get some experience with things like Python and Perl's object oriented interface.

And, oh, about the recent Editor log topic on "Are Logs Ideas Or Things": I node mine as ideas. A "log" is a "thing" all right; Instance of "log" is an "idea" because it merely describes something, while not being anything other than the description itself. Just my personal weird way of putting it, no need to monkey the idea =)


I just moved my home page to my new ISP... I hope the iki.fi redirection gets updated soon!

Now, to the Uni...


Oh goddamn it...

Okay, first an announcement: Python is a decent programming language.

Then another announcement: If anyone says it's kewler than Perl (at least today), I'll personally disembowel them. Understood?

Okay, the scenario: I have one shell script here that has become Dangerously Big And Scary so I need to use some real scripting language. I first thought of Rexx or Perl, but decided to use Python just for chance (and to learn).

(FWIW, Debian seems to have Python 1.5 or something. So if any of these idiocies I list below are fixed, I will eat my words about that...)

Now... How do I convert sh backtick operation to Python? Perl accepts it allright with no specific tinkering... The original shell script had this:

declare freemem=`free | grep Swap | perl -ane 'print @F[3],"\n";'`;

Since the documentation and tutorial didn't tell me that, I resorted to this:

mi = open('/proc/meminfo', 'r')
meminfo = mi.readlines()[-1]

freeswap = re.sub('^SwapFree:\s+', '', meminfo)
freeswap = re.sub('\s+\w+B$', '', freeswap)

Which may or may not be Cool from porter's point of view...

And then I ran into the Really BIG headache...

freeswap = string.atoi(freeswap)
swaplimit = (int)((3.0/4.0) * freeswap)

You know... the distinction between string, integer and float types are too strong in Python for my tastes. Furthermore, all regular expression and string functions are hidden behind packages!

I said (3/4)*freeswap but then it returned 0. I found out that I needed to convert the integer to string (Perl does that automatically)... so what happened now? Still 0. Grrrrr. Then I remembered the Nights of Horror I had had with other languages ages ago... (3.0/4.0)*freeswap => HAR! it started to give understandable results... Should have just said 0.75 all along!

Oh, and I had to typecast it too. "We are the People of Programming Republic of Perl. We don't do that sort of thing."

Beats mucking around with expr any day, though, if you expect me to say something positive...

::WWWWolf sighs:: Two hours, and 9 lines of the original script ported! You know, they say it's easier to port a shell than a shell script... =)

What else I did today? Well, I watched a bit of Hackers movie... R00l1nG Skr1pt k1dd0 m00v1, d00dz!!11!1!11


I hacked again some Emacs-Lisp to get my mind away from that Python shock... results are available, as usual!


(See small matter of programming. Yeah, the Python script above was definitely a SMOP by that definition... =)

Other day logs o' mine...

Noded today by y.t.: expr backtick
Updated: Small helpful scripts for noders