Older blog entries for shlomif (starting at number 22)

Vim Macro

Due to the fact that I could not find any decent editor outside KDE that behaves just like I wanted, I decided to try and make gvim into an xmms front-end. Which naturally meant adding two macros (one for playing a file and the other for enqueuing it) into my .vimrc file.

I knew Vim macros were basically a recording of all the commands needed to execute them. So, after consulting the vim help pages a bit I came up with a generic macro that did just that. This macro had a problem in which it was not resistant to shell's special characters.

I worked on two other revisions of the macro. In the third revision everything was fixed except for filenames that contain newlines (which are pretty rare as it is).

What I did was copy the line containing the filename into a register, duplicate it below, substitute all the single quotes with the sequence '\'', copy it into the register again. Then, I entered the command line :!xmms '$reg' on the shell, and afterwards deleted the extra line.

Guy Keren once said to me that one did not do real programming until he programs with Vi macros. So, perhaps this was a baby step in the direction of becoming a "real" programmer.

This macro looks like line noise, doesn't it? ;-)

So many things happened since my last diary entry and I have so many things to write. Well - better start somewhere - here goes:

"The Great Kernel CVS Mutiny"

That was the name of a post I made to the Linux-IL mailing-list, which started quite a flamewar. Basically, I made two suggestions for improvements to the way the Linux kernel was managed:

  1. That a source control mechanism be used by Linus and the other kernel developers (hence the name)
  2. That Linus will not necessarily OK all the patches that will go into the main kernel tree, but rather rely on the good judgement of the subsystem maintainers, the module maintainers, etc.

Suggestion #1 seems to have been resolved (with or without my influence - IANA prominent kernel developer) by Linus' switch to BitKeeper. Suggestion #2 seems to have been raised in the "Patch Penguin" post. I did not thoroughly read either the original post or Torvalds' reply to it, so I cannot say right now whether or not it has been resolved the way I think it should.

An interesting theme to my posts was an analogy I made to the story of Moses and Jethero in the Exodus. Read the posts and be amused.

A New Bike

I finally have a new bike which is a blue Raleigh A4 (yes, like the paper size). I rode it several times the past weekend and this one, and it feels pretty good. Some things in it are a bit of an over-kill, if you ask me, but all in all I'm happy.

I'm supposed to take it to the shop were I bought it after a month or so, for some maintainance.

User's Guide for the IP-Noise Project

Roy is finally through with his Milu'im. We decided that we can add more meat to our final report by writing a User's Guide. We decided to write it in HTML, after ruling out POD (which is very limited) , LaTeX (which is harder for MS-Word to import) and DocBook (which I still have to learn). POD is still great for writing man pages, and Roy agreed with me that the nroff syntax is much more horrid.

We will explain setting up and using the front-end in detail. I believe I have GraphViz around, which should prove useful for including diagrams that explain about the Markov chains.

Exercising

My bike broke again last Friday, which made it impossible for me to ride them in the further part of the weekend. This has finally convinced my father to buy me a new bicycle.

My father and I went on a hiking trip on Saturday. We walked in a narrow water-less channel, which did not have too many flowers or interesting trees. The road up to it looked nicer than the road inside, IMO, but it was good to have a trip back again.

It's been constanly raining here since the weekend, so I could not jog even assuming I would want to do that. Maybe, I'll go to the gym today, or tomorrow...

Technion Courses

Things are not going very well with Game Theory and with "Intro to Thermodynamics and Statistical Physics". In Game Theory I missed a few lectures due to these wretched Real-Time DSP experiments and was not very successful in solving the home exercises on my own. In Thermo, I missed a few lectures and T.A. sessions and also have a learning gap.

I called a tutor for Thermo and he said he was busy this week and that I should phone him on Thursday. There are no tutors for Game Theory unfortunately, but I'm going to consult with the lecturer today about the situation.

FCFS RWLock

I hacked on it a bit in the past few days. Right now there is a working man page with many aliases for every function it contains. Took me some Autotools games to put the man page on a separate directory.

I also combined release_write() and release_read() into one function.

Misc Stuff

vipe.technion.ac.il has been inaccesible for some time but is now. I wonder why does the dorms network causes me so much trouble.

I forgot my cell-phone at home. At times, I feel the urge to call people using it. Maybe I'm becoming too technocratic...

SICP

I spent a lot of time in the weekend working on the Structure and Interpretation of Computer Programs course's homework. I forgot the LaTeX files that contained the cover page I prepared on my Com-Net Lab workstation, so I re-created a cover page from scratch. It was not too hard.

It maybe my impression but it seems that Scheme programs are more prone to bugs than Perl programs. And those bugs are harder to trace. MIT Scheme is rather strange in the sense that the identifiers there are case-insensitive. I checked it on Guile and A and a are completely different variables.

Bicycle Ride

I rode my bicycle twice on Friday and once on Saturday. Now I'm going to bike again. Last weekend one of the brakes cords of my bicycle broke, and I had to return with them to home walking. This thursday, I walked with them to the bicycle repair man and he fixed them.

I'm getting tired of my bicycle breaking down, so I asked my mother to buy me a new bicycle for my birthday instead of an electrical organ which was our original plan.

Refactoring the Law

There's a small article I have been intending to write for a long time about re-factoring the Law. To sum up, I believe that adding new laws is like making ugly changes to the code that attempt to add more functionality but mess it up completely.

The equivalent of refactoring a code is taking out redundant or harmful laws out of the Law Canon.

Linux Saves the Day

Dudu, Eran's friend, recently bought a new computer which came with Windows XP installed. Another friend of both Eran and Dudu installed Mandrake Linux 8.1 there, which I helped configure a bit after it was installed. A couple of days ago, Dudu called me by phone and informed me his Windows won't load (and he blamed it on the Linux). I told him I'll get to him and try to do whatever I can do to help.

After a long bus ride to the lower city of Haifa, I came to Dudu and checked the computer. The LILO was perfectly fine and indeed booted XP. XP even started to load some files, but then it yelled that something was wrong there. I had no idea how to fix it and Dudu did not have the CD, so I could not re-install it. What I did was mount the XP partition (an NTFS) one on the Linux and back up the important files on a different partition.

The next day Dudu re-installed Windows XP, which naturally run over the boot loader, which made it impossible to boot Linux. While using the phone, I instructed Dudu to insert the first Mandrake CD into the CD-ROM drive, set it as bootable. Then press F1 and quickly type "rescue" at the prompt and press enter. This brings the rescue image. It turned out that it automatically loaded the Linux partition on /mnt. Realizing that, I told Dudu to invoke the following command:

# chroot /mnt /sbin/lilo -c

Which is a trick I saw someone do in a Linux Insta-Party. This restored the LILO and Dudu told me he was then able to boot both Linux and WinXP again.

Note that I'm not entirely sure it's the Linux fault that XP got corrupt. Before I configured it, the Linux did not even mount the NTFS partition much less write to it. And XP is at the moment full of bugs. I advised Dudu to upgrade to Service Pack 1 as soon as it is available.

Safe X-Windows Locking in Run-Level 3

Runlevel 5 (when X runs automatically) considered harmful, because X-Windows can respond very delicately to hardware changes. However, when using X-Windows on runlevel 3 after it was started using "startx", there is a security breach involved in just locking it. The problem is that a malicious person who has physical access to the computer can press Ctrl+Alt+F1, press Ctrl+C or Ctrl+Z and have access to a shell prompt in which X runs.

I found a way to resolve it by logging into another console and typing "vlock -a", which locks the console and does not allow moving to a different one. This, however, has the unfortunate effect of making the computer unusable, except for remote login. I came up with a better solution, though: run "startx" inside a "screen" session and detach the session. That way, the computer is still perfectly usable.

Or maybe Runlevel 5 does make sense sometimes... :-)

Haifux' Meeting

The meeting of the Haifa Linux Club took place this Monday as usual. This time we had an English speaker who did not know Hebrew well, so the lecture was given in English. That's the first time I remember that was the case.

mulix and Guy Keren gave a fascinating lecture about syscalltracker. You can find the lecture's slides on-line here.

I thought it was funny that they kept a workaround for a compiler's bug in the code, instead of telling people to upgrade to a new compiler. I personally would never do such a thing.

In any case, I finally was able to get acquainated with the famous (or perhaps notorious) Nadav Har'El. Adir Abraham suggested we wage the "Technion - good or bad" war in real-life there, but I decided to skip it.

Implementation of the log function

One side-effect of the lecture was the Muli and Guy said they would like to test their code on an SMP machine. This reminded me that I'd also like to make sure IP-Noise is SMP-safe, so the day afterwards I e-mailed Orr Dunkelman, Muli and Guy that I'd like to share the session with them. This sparced a small discussion which I will not detail here, but everybody agreed that I could do that.

In parallel, I tried to find an SMP machine in the Computer Networks Lab. All I could find was an old Dual-Processor SPARC station. There is no problem installing Linux on it, but the IP-Noise code uses an i386-assembler coded implementation of log(x), so I had to adapt it to the SPARC. I tried to look at glibc (from which I took the i386 routine), but could not make heads or tails of it. So I made a post to Linux-IL which sparced (pardon the pun) a very big discussion. It turns out the SPARC's floating-point unit does not have an internal implementation of the log function and one has to code iteratively.

With some help and input from the Linux-IL'ers, I coded a log() implementation in Perl and then converted it to C. You can find it here. It is not very optimized but it is fast enough for our needs.

I think it would be a good idea to have a central repository of kernel-compatible C and C++ source code, that kernel developers can use in their modules. That way, the wheel would not need to be coded times and again.

GNOME

In order to help keep balance in the force I decided to switch to using GNOME for a while after a long time when I used KDE 2.x. Nautilus is not so bad, for selecting mp3s for playback after I turned off the automatic previewing of files. What did cause me some problems were the Netscape fonts.

I tried to set the Fantasy and Cursive fonts (whatever they are) to something nicer than Courier New, but it turns out Netscape 6.2 gives a long list of fonts, with a very slow scrolling mechanism. I tried Galeon instead - it has the Gtk+ font selection dialog (yey!) but crashed after I tried to set the fonts. It's version 0.12.1 so maybe I should upgrade.

End of story: I'm writing this entry on Konqueror running on top of a GNOME desktop as I speak. Konqi usually brings up half of KDE with it, so thanks God I have 320 MB of RAM.

Aside from that, GMC and Nautilus put together seem to clatter my desktop with icons, but since I don't use the desktop icons much, it's not a major concern.

IP-Noise Project

I discovered that there is a readers/writers lock mechanism that can be used inside the Linux kernel. Check:

http://www.lisoleg.net/doc/Kernel-Hacking-HOWTO/kernel-hacking-HOWTO-5.html

This is good news because so far we defaulted on a mutex, which could have been inefficient in an SMP machine.

Otherwise, I made some minor improvements to the code and documentation - mostly adding comments and the such. I think Roy and I should hand the document to Lavy as it is, so he can review it and hopefully we will get the final report over with. Or the worst case is that we will have to write a very detailed (and IMO useless) architecture document.

The EE-Lab 2 Experiments

In "Electrical Engineering Lab 2", Technion students need to choose 3 experiments from a list of about 20, perform them (with the help of an instructor), and hand reports on them. Usually there are two meetings so sometimes we have a preliminary report for the first meeting, a summary report for the first meeting, a preparation report for the second meeting, and a final report that should be handed after the second meeting. %-)

Two of Eran's and mine experiments: Image Compression and Wavelets went very well. (in the second Wavelets meeting, the instructor was not present, but Eran and I managed to finish the experiment after just two hours anyway.) The "Real Time Digital Signal Processing" one however was not the case. Eran and I set a Technion precendent by leaving the first meeting in the middle and declaring that we wish to give up on the experiment. It turned out to be impossible, so we were scheduled a different meeting.

The second meeting took place last Wednesday and the second take of the first one a week earlier. We finished what we had to do (with a lot of help from the instructor) , but otherwise it did not went too well. Eran wants to get the final report over with ASAP, so he forced me to get to the Technion early today (from Tel Aviv) and work on it in the morning. Good thing that I wook up at 5:15 AM today.

Eran said, that if anyone proposed to give him 55 in that experiment, he would take it. (and I second that) He also said that he also does not mind giving up the experiment and even this entire take of "Lab 2". I said that we should at least give our best shot at "Real-Time DSP" before we give up.

Freecell Solver

I released version 2.0.0 of it. There are two very big things which I'd like to do with it now: add support for multiple threads to operate on the same states' collection, and port to Java. I'll do the former first, so I'll have a good code-base to translate into Java.

Otherwise than that, I'm also thinking of finding a way to abstract prunes without messing the code too much. But since Freecell Solver is fast enough as it is, it's in a rather low priority.

First-Come First-Served Readers/Writers Lock

I coded such a beast for POSIX threads and you can find it here. I did it mainly for fun and to see if the model I thought about for implementing it would work. It seems that it does.

I received some feedback about it from various people. Now I have an idea for improving it, so there will be a smaller number of condition variables that are allocated. But I'll release the current implementation as 0.2 before I do that.

Unfortunately, I'm not going to use such a mechanism for Freecell Solver's multi-threading capabilities. The reason is that the atomic operation of managing the states collection is of checking if a state exists and if not adding it. (and returning whether it was the case). That way, a mutex is enough.

Humanity

I added an incomplete scene called "The Street". It has a lot to do with Computer Science, so I recommend hackers to read it.

The Technion

After having to do 5 exercises in "Structure and Interpretation of Computer Programs", I won't be surprised if I'll start dreaming in parenthesis. During the last lecture, I managed to correct the lecturer on one occasion. Read about it in this post I made to Hackers-IL.

In case, I did not mention it here earlier, I'm writing the answers in English and using LaTeX. It's very convenient and causes much less trouble and frustration than Word. I discovered that one should write {\tt My text} instead of \tt{My text}. LaTeX is not without its idiosyncrecies, but at least one becomes familiar with them eventually, which is not the case with MS-Word.

Other than that, I stopped studying "Digital Communications". The lecturer and the T.A. were great and the material was very interesting, but the homework took too much time. And after I worked in the summer on the project, I'd like to have a light semester.

Freecell Solver

The refactoring of the code was eventually declared successful. Since then I've added a few more changes. One of them was to make sure that the fc-solve executable made use of the freecell_solver_user library. This is programmatically correct due to the "eating your dog food" concept. Afterwards I spent some time implementing a randomized Depth-First Search scan. The so-called random-DFS scan sometimes yields very good results which vary with the different seeds one gives it.

Lastly, I coded a test_multi_parallel.c program that runs several scans on one board simultaenously. From a benchmarking I made it seems that it solves a range of boards, much faster than a single-scan run. The next step in this direction would be to allow for several simultaneous scans to share the same states' collection. I'll probably work on it for the next release of Freecell Solver unless I find something more pressing to implement. But I have higher priorities, like the studies that have just been re-initiated (see below).

Michal Reading Ayn Rand's Books

My sister Michal finished to read the book "The Fountainhead" by Ayn Rand. She said she enjoyed it very much. Now she's reading "Atlas Shrugged" and for the time finds it less intersting. We had a small discussion about these books the other day. I told here that Atlas Shrugged is purposely made more irritating as one goes on reading it. But that's a good thing<tm>.

The Technion

Well, studies so far have been incomplete due to the lecturers' strike. But now the strike is over and hopefully everything will be back on track.

There were some rumours about nasty things the lecturers are going to do to compensate for the missing lectures. I sure hope those rumours are not true.

SICP Amusements

For those who do not know, SICP stands for "Structure and Interpretation of Computer Programs" and is the name of a book and a course in the Technion and in other universities. I had some fun solving Problem Set No. 3. Basically, we had to draw figures on the screen using one drawing primitive (that draws a single point) and a lot of abstractions above it. I'm considering playing with it some more and building transformations for generating such shapes as the cycloid, the hyper-cycloid, an Escher-like condensing pattern, etc.

The IP-Noise Project

Not much to report here. Roy said he sent me a draft of the final report, but I did not recieve it. There's a flow-chart I want to prepare for it in Visio. Otherwise, everything is set and ready for prime-time.

The Image Processing Course's Test Appeal

I failed on my Moed Beith test and to make a long story short, I agreed with the lecturer that I'll hand him another appeal. I decided to print the whole test, and I used LaTeX for this purpose. It did not came out half as bad (much better than my hand-writing that's for sure). And it went much faster than Word despite the fact that I had to check out how to do a lot of things in LaTeX when I needed them. God bless Google and the Haifux mailing list.

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