Archive for the 'Computer' Category

Published by Niels on 08 Apr 2010

Computable door de bocht

Ik heb me net heerlijk zitten ergeren aan een artikel op de Computable website. De stelling is dat het introduceren (het gebruik wordt niet eens genoemd), van Linux in een bedrijfsomgeving verborgen kosten met zich mee brengt. Dat zou helemaal waar kunnen zijn, maar de auteurs Johan Zwiekhorst en Jozef Schildermans van Data TestLab slaan volgens mij op een aantal punten behoorlijk door. De argumenten op een rijtje:

  • Bovendien is opensourcesoftware minder populair dan Windows, zodat vandalen het vooralsnog grotendeels met rust laten…Echt waar? Zouden de onderzoekers wel eens een gekeken hebben naar de echte getallen over Open Source? Apache, iemand? PHP? Java? Bovendien gaat het begrip Open Source veel verder dan alleen het operating system, dus het begint al door appels met peren te vergelijken.
  • Zoals je waarschijnlijk wel weet, bestaan er honderden Linux-distributies. De toon lijkt nu wel gezet. Feitelijk en tendentieus.
  • De basis van die bundel is de linux kernel: die is hetzelfde voor iedereen. Daarbovenop komt het GNU/Linux platform. Kennis van GNU/Linux ontbreekt blijkbaar bij de auteurs: de kernel is niet bij alle distributies hetzelfde. Ze zijn wel gebaseerd op dezelfde broncode, maar vaak aangepast door de maker van de distributie om zo goed mogelijk aan te sluiten bij de doelgroep van de distributie. De opmerking dat het GNU/Linux platform erbovenop komt is natuurlijk onzin. Het heet GNU/Linux omdat een Linux kernel wordt gecombineerd met de GNU applicaties om een operating system te maken. Richard Stallman zal het niet waarderen dat de GNU applicaties GNU/Linux worden genoemd.
  • Als je een Windows-gebaseerde server draait, dan moet je die clientlicenties betalen ongeacht het gebruikte desktopsysteem. Wat een raar argument. Als het een homogene Windows-omgeving is, moet er ook voor zowel de client als de server licenties betaald worden. Bij Linux ben je in ieder geval nog het bedrag voor het desktop operating system kwijt.
  • Zo blijkt het erg moeilijk om computers van A-merken te kopen zonder Windows erop. Dat is alleen Microsoft aan te rekenen. Dus feitelijk weer juist, maar het lijkt mij eerder een argument om zo snel mogelijk te stoppen met het gebruik van Microsoft producten, want daardoor wordt blijkbaar de prijs van apparatuur onnodig opgejaagd.

Afgezien van de hierboven beschreven argumenten, staat het artikel bovendien vol met taal- en/of typefouten. Ik ben benieuwd naar het vervolg op dit artikel op 12 april, maar gezien de argumentaties in dit artikel vrees ik het ergste.

Published by Niels on 02 Apr 2010

Error: Cannot modify header information…

If PHP ever gives you the following error (I just encountered it while developing with the Yii Framework):

Cannot modify header information - headers already sent by

Then you probably injected some whitespace somewhere in your output. The easiest way to avoid that is by not using the PHP closing tag ‘?>‘ at the end of PHP source files. Some people are against that but if I look into the sources for Yii and read the Zend Framework Programmer’s Reference Guide then it is obviously a well established method of avoiding the mentioned error.

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.

Next »