Archive for March, 2006

Published by Niels on 31 Mar 2006

ViM Rocks!

Just downloaded, compiled and installed ViM 7.0c Beta and I must say it rocks! I still have to get used to a lot of things, but the following items really are good add-ons to ViM in my book:

  • Built-in spelling checker. I had to create the directory $HOME/.vim/spell before it worked, but when it works it works perfectly.
  • Editing files through a network connection (FTP/SCP/RSYNC/etc./).
  • The very fast internal grep.

There are also some things that sound good, but to which I probably am not used yet:

  • Omni completion. I only tried it with PHP, but it did not bring me any joy. It suggested the possible function names to me without any problem, but it did not show the signatures for these functions (parameter lists and return values). But not all possible settings have been explored. It even locked up ViM.
  • Tabbed pages. I find the MiniBufExplorer more convenient. The graphical tabs look awful and the text based ones look to cramped i.e. file names are truncated if there is not enough space and if there are many file than not all file names are shown.

But considering the fact that ViM still has a very small footprint (under 7MB of sources, compare that to that other editor :) ) I must say that this version is really a step forward.

If I find anything new I will put that in a new weblog. But the next couple of days I will probably be busy testing the Code Plugin with the new ViM.

Published by Niels on 19 Mar 2006

More on the old beast

In this log I mentioned that the Dell Dimension XPS I am running has been extended with a Promise Ultra ATA-100 TX2 IDE card. This has the advantage that, instead of the local IDE’s 33 MHz bus, the PC can now utilize its full 100 MHz bus power. This meant that I could make better use of a new 40 GB hard drive I bought (which can operate at 150 MHz, but hey!). On this newly installed drive Ubuntu Breezy Badger is installed and on the old drive Windows already had been installed. The chain-loader used for Windows gets a bit confused if the Master Boot Record is on this second drive on the second controller, so some fancy Grub settings have to be put into /boot/grub/menu.lst. Here is mine:


# This is a divider, added to separate the menu items below
# from the Debian ones.
title Other operating systems:
root

# This entry automatically added by the Debian installer for a
# non-linux OS on /dev/hda1
title Windows
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
chainloader +1
makeactive

If there are any questions on running Linux on old hardware just let me know.

Published by Niels on 18 Mar 2006

Useful links

Google is a great search engine and it has helped me very often to find the information I needed at that very moment. But filtering all the results presented by Google can soon become a tedious task. Not always are the best results for what is wanted presented at the top of the search results. So I always try to find (and bookmark) pages that provide a good overview. And so recently I found two (well, one was presented at SlashDot :) )

The first one is a link to IBM’s DeveloperWorks that shows a ‘reading list’ for PHP developers. The title is a bit misleading because they provide links to common tools, articles, web-pages and yes, even books. I wish they had created this page a month ago. It would have saved a lot of searching.

The second link surprised me a bit. But is really a Microsoft owned page linking to a lot of tools that can be used for .NET development. And the part that surprised me is that they also link to 3rd party tools and even Open Source projects. Do I hear the sound of an air born pig in the distance?

Published by Niels on 16 Mar 2006

A storage pattern

Every time I build software that makes use of a Model-View-Controller pattern I always have the feeling that the wheel is being re-invented with regards to the View part (and to a lesser extent the Model part as well). This is caused by the fact that, to me, the most obvious solution for a view is a tree-structure of elements that share a single interface so that a simple draw() on the top-most interface is sufficient enough to get the whole tree drawn (to screen, file, paper, etc. but that will be for a later story).

The pattern below is what I always use to implement this:

Storage Pattern

This makes it very easy to create objects that either store a single element that is drawn, or multiple elements that are drawn. You have to choose if the concrete element is either a SingleElement storing ‘content’ or a ContainerElement that can store other elements. This way it is very easy to build a tree of similar objects that have a shared interface. This pattern is more commonly known as the Composite Pattern.

The diagram is drawn using Dia. The original diagram source can be found here.

Published by Niels on 12 Mar 2006

Networking and sound on an old system

So we have this old system running at home. That is, this message is brought to you by a Dell Dimension XPS R450 that originally had 64MB RAM, a 450MHz Pentium II processor and a whopping 9GB hard-drive. Last year I have upgraded the system to a 1.3GHz processor using a Powerleap PL-iP3/T processor board, added some extra RAM (256MB), a second hard-drive of 40GB using a Promise Ultra ATA-100 TX2 so that the system could fully use its 100MHz bus potential, and last but not least a CD-RW drive instead of the 8x CD-ROM that came with it.

This system ran Gentoo Linux for a while, but I found that the continuous compile sessions became somewhat of a burden (this is a mild remark, the truth is a lot worse). So Ubuntu was installed and everything was fine. Except for the sound card that refused to work. The lspci command showed me that the sound card was of the cs46xx type. But when I did modprobe snd-cs46xx the module got nicely loaded, but the sound card did nothing. After some tinkering with several modules I found that the system worked using the snd-cs4236 module. All was fine and I put this module in the /etc/modules file. After a reboot (just to check) the network did not come up. Some research later revealed that one of the IRQ’s the sound card occupied was IRQ 10. Did I mention that my network card is a 3Com 3c509 hard-wired to use IRQ 10?

Everything works fine now that the following line is included in the file /etc/modprobe.d/alsa-base:

options snd-cs4236 port=0x530 mpu_port=0x330 irq=5 mpu_irq=3 dma1=1 dma2=0

This nicely forces the card to use IRQ’s 3 and 5. My daughter can now even play Putt-Putt games using Wine and her own mouse :).

If you want more information on upgrading your Dell Dimension XPS there is a lot of information to be found here.

Published by Niels on 09 Mar 2006

Check this out…

If you want to learn something.

Out of curiosity I started writing an application using PHP and MySQL. The syntax of PHP wasn’t a problem, it feels like a very dumbed down version of Perl, with which I am very familiar. And neither was MySQL. It is ‘just’ another RDBMS and a simple one at that. Nor was the design of the database tables a problem as I remembered my lessons and experiences on database normalization.

When I wanted to code the entire application I found out that I lacked experience in setting up a website using the n-tier model and the MVC (Model-View-Controller) pattern. After some searching Tony Marston provided me with a lot of good insights. He is very pragmatic, but don’t let that scare you off. The proof is in the pudding and a wonderful pudding he made and explains how he made it.

Published by Niels on 03 Mar 2006

Alas, poor sl, I knew him well

To update a site created by NanoBlogger you either have to:

  • Painfully copy the newly created entries by hand and move or remove all other files.
  • Use a protocol like rsync. But some of us are not fortunate enough to have a hosting company that offers this protocol (as a side note: that is about the only shortcoming I can think of regarding BHosted).
  • Brew your own update script that works quite well, but is still a little rough around the edges. In order the smooth things out you would have to spend considerable time which you don’t have.

Or you can read the NanoBlogger newsgroup where a question on site-synchronization was answered by me and then by someone else who had a better answer.

So suffice to say that I will be no longer using my home-brew sl, instead I will be using sitecopy. It works on the same principle as my own solution, only more mature and maintained by somebody else :). The observant reader will notice that sl no longer is in my category list. The entries and the program will stay however. So if needed they can still be found.

Sitecopy is very simple. All it needs are two things:

  1. An entry in a file called .sitecopyrc in your $HOME, where an entry has to be created per website. The permissions of the file have to be set to 600. Mine looks like this:
    site heirbaut.nl
        server server9.bhosted.nl
        protocol sftp
        rsh "ssh"
        rcp "sftp"
        username ***
        password ***
        local /home/niels/Projects/www/www.heirbaut.nl/
        remote /srv/nielsh/www/www.heirbaut.nl/
        state checksum
        checkmoved renames
    
  2. A working directory called .sitecopy in $HOME with the permissions set to 700.

Published by Niels on 03 Mar 2006

Just documenting

One of the reasons I keeps this weblog is to have a central storage of my cumulative knowledge. That is, instead of writing all kinds of little tidbits in a notebook, I put them here. This has the benefit that wherever there is have web-access the information can be found and perhaps someone else that is looking for the information is happy to find it here.

OpenOffice Writer was given me a minor problem: it set the page size for all new documents to the Letter format. It is not difficult to change, but quite annoying. After some investigation I found that the best (only?) method was to:

  1. Open OpenOffice Writer.
  2. Open the Stylist by pressing F11.
  3. Go to the list with page styles.
  4. Right-click ‘Default‘ and select ‘Modify‘.
  5. In the Page-tab choose the format you want (A4 in my case) and click ‘OK‘.
  6. Go to ‘File -> Templates -> Save‘ to save the current template. Choose a new name.
  7. Go to ‘File -> Templates -> Organize‘ and right-click the save template (probably under ‘My Templates‘) and select ‘Set As Default Template‘.
  8. Restart OO Writer and check if the page size is indeed the correct one.