Saturday, April 08, 2006

Need some sample text for testing

I recently discovered a useful function in Office Word that allow you to generate some sample text. It is very useful when you need some text for your tests instead of typing manually "bla bla bla".

Open Word, create a new document and type =rand()
Word will automatically generates the following text:

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

You can even pass 2 parameters to the rand() function. First parameter is the number of paragraph to generate and the second one is the number of sentences per paragraph.

By default, rand() is equal to rand(3,5)

Hope this will be helpful.

Wednesday, February 15, 2006

Free virtual CD tool

I finally got my boss to buy me a MSDN subscription :-)

MSDN comes with a lot of ISO file (CD image files), which are great but I did not want to burn a CD or DVD each time.

I looked for a virtual CD tool to mount this image files, but again did not want to pay for it...

I found that Microsoft has released a free virtual CD tool named "Virtual CD-ROM Control Panel v2.0.1.1". However it does not seem to be really marketed and is not available on MS.com
You can find it on Softpedia (http://www.softpedia.com/get/CD-DVD-Tools/Virtual-CD-DVD-Rom/Virtual-CDROM-Control-Panel.shtml)

The tool is rough but does the job!

Installation instructions

  1. Copy VCdRom.sys to your %systemroot%system32\drivers folder.
  2. Execute VCdControlTool.exe
  3. Click "Driver control"
  4. If the "Install Driver" button is available, click it. Navigate to the %systemroot%system32\drivers folder, select VCdRom.sys, and click Open.
  5. Click "Start"
  6. Click OK
  7. Click "Add Drive" to add a drive to the drive list (Ensure that the drive added is not a local drive. If it is, continue to click "Add Drive" until an unused drive letter is available)
  8. Select an unused drive letter from the drive list and click "Mount".
  9. Navigate to the ISO image file, select it, and click "OK" (UNC names don't work).

You may now use the drive letter as if it were a local CDROM device.

When you are finished you may unmount, stop, and remove the driver from memory using the driver control.

Friday, February 03, 2006

IE7 Beta2 Preview available

Microsoft has just released the Beta 2 of IE7.

It can be downloaded from the Microsoft site.

The new UI is simply great and simpler with the useful tab browsing, ripping off all the unuseful menus and toolbars to widen the screen space. A must with the endless growing content of websites. Another great feature to ease content reading is printing improvement, which is supposed to allow you to print pages without them being cut.

I have not tested the supposed now-supported CSS2 standards, but the rendering is good.

The font are rendered slightly differently than with the current browsers. While it is pleasant to read text the font looks like "bolder" (I hope that we won't have all to adjut our style sheets when it is released...)

Monday, January 09, 2006

Add a first blank item in ComboBox

The built-in ComboBox Windows Forms control is often used but it has a drawback in the sense that you cannot add an extra blank item automatically.

This is quite painful as you often like to add an item like "Select one item".

I have created a control BlankItemComboBox, which does this.
It works with DataTable, DataView and Collections. It currently does not support Arrays of objects.

You can download the source code here

NOTE:
There is one drawback which is that you must set the control properties before you bind the datasource.

blankItemComboBox1.BlankText = "Select";
blankItemComboBox1.BlankValue = "0";
blankItemComboBox1.ValueMember = "ID";
blankItemComboBox1.DisplayMember = "Name";
blankItemComboBox1.DataSource = ds.Tables[0];

Thursday, December 22, 2005

Cleaning HTML generated by MS Word

During my last project, I was using a HTML editor for the user to submit content. I used FreeTextBox http://www.freetextbox.com

I wanted to let the users copying their text from Word. However I wanted to "filter"the HTML I was getting to only keep carriage returns.

After some researches, I decided to use Regular Expressions and I found a very good code sample on a weblog that was doing something similar (HTML cleaning for CMS posts - http://tim.mackey.ie/CleanWordHTMLUsingRegularExpressions.aspx)

I worked out some regular expressions to get exactly what I needed for my project and here is the final method.

/// <summary>
/// Cleans the abstract text if copied from Word
/// </summary>
/// <param name="abstractText">Text of the abstract</param>
/// <returns>Cleaned Text</returns>
private string CleanWordHtmlText(string abstractText)
{
//Replace paragraphs with custom string to preserve Carriage Returns
abstractText = abstractText.Replace("<o:p></o:p>", "$##$BR$##$");

//Drop potentially dangerous HTML tags
abstractText = Regex.Replace(abstractText, @"</?(?i:scriptembedobjectframesetframeiframemetalinkstyle)(.\n)*?>", "");

//Drop XML namespace references
abstractText = Regex.Replace(abstractText, @"<?.(?i:xml)(.\n)*?>", "");

//Drop WORD HTML tags
abstractText = Regex.Replace(abstractText, @"</?(?i:fontdelinspspandivbemhstrongst1a[ovwxp]:\w+)(.\n)*?>", "");

//Drop Table HTML tags
abstractText = Regex.Replace(abstractText, @"</?(?i:tabletbodytrthtd)(.\n)*?>", "");

//Replace custom string with standard HTML carriage returns
abstractText = abstractText.Replace("$##$BR$##$", "<br/>");

return abstractText;
}

Thursday, September 01, 2005

Yet another blogger

I have been thinking to create my blog for awhile now, but I was not sure of what to write...There are lots of blogs outhere and many of them are just boring (you may think the same for mine). I did not want to blog about me. Blogging about technologies? Why not but there are already so many...


Finally I decided to post technical tips to share my experience and some of my knowledge, either to help others finding solutions or just to build my own knowledge base.


Don't hesitate to drop your comment or to contact me if you have any questions.