Short solution for short problems

Spam in Blogengine.Net 1.5

I'm gettings attacked by spam bots, some times hundreds of SPAM comment each day.

So I was looking for aniti-spam measurements. Lack of time, I tried only 1 solution, but it failed, so I just tried the following:

I added an image with some text, this is always the same text. And the user has to fill in this text. My guess is it will keep the bots away, since they will not write a special bot only for this image and this blog. I put a regular expression field on the textbox checking on the text. So it only takes 3 or 4 lines of code to implement this:

1. Add an image with custom text

2. Add a textbox

3. Set a required field validator on the textbox

4. Set a regular expression validator on the textbox, checking on your text.  

After some waiting, the spam bots still got through, even if I removed the image. So my guess is that they look for the validators. So I will have to do the check in the code behond.

Temporary no comments

Because of all the SPAM comments,

I decided to disable the comments, until I've implemeted a anti spam extension to the blog.

I did not have time to do this yet.

You can always contact me via the contact form of this blog.

Animal randomization into animal groups and cages

This procedure described below will help you to randomize animals into animal groups according to the needs of a G(x)P environment:

The algorithm is based on a document published by Sage. You can find it here. The title is Randomization of Animals by Computer Program for Toxicity Studies. The process will follow the exact process using 5 different weight range groups. The only deviation on the process is that for we can use variable amount of animals for each group. The document assumed that all animal groups had an equal number of animals assigned.

This process runs separate for males and females.

  1. First the animals are sorted on weight.
  2. Then they are divided into 5 different weight groups.
  3. Each animal is assigned a unique random number within the weight range group.
  4. Then the animal groups will start picking the animals from the weight range groups.  The system calculates based on the number of animals that need to be allocated in the animal groups how many animals need to be taken from each weight range group. Then the first group starts taking the animals from the different weight range groups with the lowest random number. When the first group is finished, the second group starts taken animals from the weight range groups. It will start with the weight range group that follows the group where the first exposure group picked its last animal from and so on.

Here is a simple example:

40 animals are divided into 5 weight range groups, means 8 animals per group.

Animal group 1 needs 20 animals.

Animal group 2 needs 10 animals.

Animal group 3 needs 10 animals.

Animal group 1 will take 4 animals from each weight range group.

Animal group 2 will take 2 animals from each weight range group.

Animal group 3 will take 2 animals from each weight range group.

All animals are now randomly assigned to the different exposure groups and they are equally picked from the weight range groups.

  1. Then the animals are placed in cages so the animals in one cage have the best matching weight.
  2. Then the cages are randomized within the exposure groups.
  3. Then the animals are assigned animal number and animal group.



For each group the Mean value, Standard deviation and RSD is calculated. Then we calculate the maximum mean difference between the group. Good practise is to keep this number below 1%. The algoritm will help you on this. If the percetage is to high, then rerun the allocation and it will give a new result. Rerun untill you find a satisfying result. If the result is not satifying, this will mean that the weight of the animals is not suited for the allocation and you will have to remove some animals that have a very high or low weight.


Free movie, CD and books database part 2

The first version is almost ready to be published. Here's a screenshot of the configuration part.

As you can see, you can select an automatic backup. You can manually backup and restore files. Also you can disable functions, for example if you are not using the movie database:

Only the tesing fase and then the first version will be released. When you are using them, all data is stored in a format that is supported for future versions. so start using it as soon as it becomes available. then you can get the new version just as free as you are getting this one!

Read part 1.

Free movie, books and CD database part 1

Recently I started a new project, for personal use. I have a large collection of CD's and DVD's, this taking up more and more place. So now I was looking for software to keep an inventory of all these multimedia. I could find some, but the most interesting where not free. So I decided to make my own. This is a really nice porject in which I try some new stuff. When it is ready I will make it as a free download including the source code. For now you it will cover 3 types of multimedia: Audio CD's, Movies and books. There is a build in lend out system and some other cool stuff. I choose not to overload the objects with to much properties.

Here's a first look at the program:

I store all data in XML files. When data is first called I cache it, so the program runs smoothly. Since it is only text, it will not take to much memory.  

The caching is something I'm looking into with much interest. Before you start caching, you'll have to look into what to cache and when. For example, you could load all data at program startup, but then the startup takes long. The program I'm making consists of 3 big parts, Audio, Video and Books. I will create the system so that you can disable and enable these functionalities, so this makes caching more complicated. It's really fun to think of the best and most performant ways to cache.

What I also will implement in the system is an online update. I got some ideas in my head, just trying them out as soon as the first version of the program is almost ready. It's offcourse important to have the update procedure ready before I will release the first version.

I can assure you that you will find updates on this program on regular basis. It's a hobby!

So the first version is ready for publication. You will find it soon as a download on this site. The last step is testing and user manual generation. My wife will do the end user testing and I will generete a short manual.

Read more about this in the second part 2. 

Greetings and God bless this world!



I am working on the update of this blog. There's no possibility to update directly from to 1.5.0. So I will have to import all my posts, categories etc...

Then I'll have to look for a nicer theme and adapt the layout to my needs. Put in the Google adds and stuff...

I hope you like the update, it will be visible in e few days...

You can check the progress here. All comments on the demo will be deleted when I migrate the site. Please feel free to comment here on the looks. I choose the default scheme with some minor adjustments.


I created a downloads page because there were several demands for a demo project.

The first download is a demo project of the directshow library. I show how to take a picture and adjust video settings quickly.

Here's a screenshot of the program:

I'm so sorry I didn't shaved. Please forgive me ;-)

Here's the link: http://www.dailycode.net/blog/page/Downloads.aspx

The little picturebox on the top left displays the camera stream, the large one shows the picture you've taken. The reason why I look so funny on the little box is that I'm holdong the webcam in one hand and trying to perform a alt-printscreen with the other hand. :-) The examples above are taken with a Microsoft webcam. As you can see the results are very good. If you have an older webcam, read on, this might help you...

When your camera is not showing up, try lowering the resolution.  

//const int VIDEOWIDTH = 1600; // Depends on video device caps
//const int VIDEOHEIGHT = 1200; // Depends on video device caps
const int VIDEOWIDTH = 640; // Depends on video device caps
const int VIDEOHEIGHT = 480; // Depends on video device caps

I tested the program with a very old webcam, who only supported 640*480. then I adjusted the brightness and this is what it looked like:

General function: Check for leading zero's

Here a function I end up putting in the general functions library. I bumped into into this problem more then once and decided to add it to our general library.

Remember this one, it can come in handy some time.

public static string CheckForDigits(string p, int length)
if (p.Length < length)
            for (int i = p.Length; i < length; i++)
                  p = "0" + p;
      return p;



CheckForDigits('try1234',8) returns 0try1234

CheckForDigits('try12',8) returns 000try12

You can also use the ToString('00000000') on a string to add leading zero's. So if you have a string test = '123' and you use test.ToString('00000000') then you get: '00000123'. But when you want to use this function on a number that is 24 digits, it gets hard, so then it is easier to use the CheckForDigits function. Also the padleft function can be used:


Now it gets really interesting when you have comma or point seperated numbers that need to be checked before and ofter the split sign. For this I created this variant:

/// <summary>

/// Checks a string for digits before and after the split sign

/// If the split sign is not present, it will add only digits up to the "numbersBeforeComma" in front is needed

/// </summary>

/// <remarks>

/// Given p = 25,2 -> numbersBeforeComma = 3 and numbersAfterComma = 3 and splitSign = ,

/// Then the result will be 025,200

/// </remarks>

/// <param name="p">Unformatted string</param>

/// <param name="numbersBeforeComma">Number of digits before the spit sign</param>

/// <param name="numbersAfterComma">Number of digits after the spit sign</param>

/// <param name="splitSign">The sign that splits the string</param>

/// <returns>Formatted string</returns>

public static string CheckForDigitsSplit(string p, int numbersBeforeComma, int numbersAfterComma, string splitSign)


    int splitSpot = p.IndexOf(splitSign);

    if (splitSpot > -1)


        string before = p.Substring(0, splitSpot);

        before = CheckForDigits(before, numbersBeforeComma);

        string after = p.Substring(splitSpot + 1);

        after = CheckForDigitsFromRight(after, numbersAfterComma);

        return before + "." + after;




        string before = CheckForDigits(p, numbersBeforeComma);

        return before;



Microsoft tech days in Belgium

This year I will be attending the tech days again. It is happening on 10 (pre-conference) , 11 and 12 march. To view the schedule, click here. You can view the schedule per interest, Architet, Developer or IT professionals.

It has been 2 years since I was there. The program looks very interesting. I will also be attending a pre conference:

Pre-Conference: Deep-dive into development for Microsoft Office SharePoint Server 2007
SharePoint 2007 is built on ASP.NET 2.0. When it was released the current development tool was Visual Studio 2005. Since then many technologies and tools have been released that integrate with MOSS 2007, we can think about Visual Studio 2008, .NET 3.5, IIS7, etc. This pre-conference will give you the ground-layer and go further than the basic introduction training on MOSS, taking into account the use of latest technologies into SharePoint development. The day will be split into 5 separate sessions that will address the following topics:

  • SharePoint Architecture (Site Collections, Lists, Features, IIS Web Applications) using the tools under Visual Studio 2008
  • Managing data (Site Columns, Content types, Lists, etc)
  • Events
  • WCF
  • Internet facing Publishing sites and more.

Pre-requisites: Basic knowledge of MOSS2007 development

At the tech days after the pre-conference I will be attending mostly the developer sessions, also some of the architect sessions, but it will depend on the schedule of the different sessions.

Tech days