Archive for the 'Computer' Category

Published by Niels on 14 Nov 2007

Color schemes, Color schemes, Color schemes…

As a passionate and seasoned user of the best editor in the world I always look around for ways to improve the editing experience. One way to improve that is by selecting a good color scheme. The ViM website offer a ton of color schemes but no way to sample them other then look at the user ratings, install them and then judge for yourself. And even then the color schemes on the ViM site are not all schemes that are available.

Fortunately someone wrote a page where, as far as I know, all color schemes are shown and downloadable. Even my two favorite ones: here and here. The only minor annoyance is the fact that the color schemes are not all alphabetically ordered.

I know, I know, old news, but I still like to use this web site as my own long term memory…

Published by Niels on 29 Aug 2006

Release of NanoBlogger Gallery plugin 0.6.0

There is a new release of the NanoBlogger Gallery plugin. The previous version had a problem when run in Bash versions below 3.1. There are some differences when initializing arrays from a ’string’ using $IFS.

In Bash 3.1 you can do this:

1
2
3
4
5
6
7
8
#!/bin/bash
 
a="1.2.3"
IFS='.'
declare -a arr=( $a )
echo "${#arr[@]}"
 
# Outputs 3 in version 3.1 and 1 in version 3.0

But if you instead do this then it works in both versions:

1
2
3
4
5
6
7
8
9
#!/bin/bash
 
a="1.2.3"
IFS='.'
declare -a arr
eval "arr=( $a )"
echo "${#arr[@]}"
 
# Outputs 3 in version 3.1 and 3.0

So hopefully the Gallery plug-in is better prepared for the real world :). Thanks to Chris Gratham for helping me out with this.

The new version can be downloaded here.

Published by Niels on 02 Aug 2006

NanoBlogger and ViM

NanoBlogger is a minimalistic approach to blogging as vi (or ViM) is a minimalistic approach to editing. Okay, not as minimalistic as ed or ex, but you get the idea.

Using ViM as the default editor for NanoBlogger is as simple as setting the variable $EDITOR in .bashrc, $BLOG_DIR/blog.conf or, if you want control of NanoBlogger settings for each machine that you work on, $HOME/.nb.conf.

But the default settings for editing entries or articles are not particularly nice. Fortunately ViM can have settings on a per-file basis using modelines (if you don’t know what they are just type :h auto-setting on the ViM command line). To make editing with ViM a bit nicer, just edit the following files:

  • $BLOG_DIR/templates/entry.metadata
  • $BLOG_DIR/templates/file.metadata

and add the following line at the end of the file:

vim: set ts=4 sw=4 ff=unix fo+=t et:

This should provide you with some decent ViM settings across all machines that you are working on.

WARNING:
NanoBlogger versions <=3.3-RC5 have a bug that will overwrite the template files with the default template files and undo your modeline setting. This can be fixed by either using a later version (not available at the time of this writing), using the CVS version or editing the file lib/tools.sh in the same directory where your NanoBlogger binary is. Search for a line that has the following:

$NB_TEMPLATE_DI/

and change that to:

$NB_TEMPLATE_DIR/

Published by Niels on 12 Jul 2006

Some C++ STL programming trivia

I use this weblog as a brain dump. Not only to be able to remember long forgotten stuff, to make sure knowledge is not forgotten but also to share knowledge with others.

If you do a lot of C++ programming it is almost unavoidable to use the STL and at some point you probably will end up defining your own templates. This is not a bad thing since you then make use of the strengths of the C++ language.

The problem starts when you make a programming error using a (STL) template. The error messages from the compiler are cluttered with so much noise that it is often very hard to spot where the error has been made. Fortunately someone has written a filter (STLFilt) to parse these cryptic messages and make them more readable. It works with most compilers although support for GCC is a bit behind. Support for version 3.4.x and up is worked on. My experience, however, is that it is still very usable for GCC version 3.4.x and up.

You can find a distribution of STLFilt for your compiler here.

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.

Next »