Saturday, December 31, 2005

1961.aspx

Best wishes for 2006

2005 was a rich year in experiences, both professionally and personally. The money could be better so I am eating lentils to improve my situation in 2006 :-)


The end of the year was particularly busy any exciting, promising an interesting new year. I hope you had a great 2005 and will have an even better 2006.


Happy New Year!

Friday, December 30, 2005

1948.aspx

Spammers killed my will to blog

No blogging this Christmas.


200+ spam comments per day took forever to clean up via the dial up connection I had during my (too short) vacation. The anti spam features I added to my blog last spring worked like a charm until I went away (Murphy's law). Very few, if any, spam posts made it through the system. Then the MT blacklist was taken off the air and I was left my backup solution based on regular expressions. It worked, but the system was only as good as the list of expressions used to validate post. Normally it was not a problem as I updated the list ASAP. The spammers changed tactics during Christmas; instead of one burst per day which I managed to handle, they started spamming a 24 hours a day.


I am back and I have blocked them, hopefully for good. The first thing I will do next year.... is to update my anti spam system so I can manage it from remote. I will blog my updated version when I have tuned it properly. It has a tarpit feature that slows down spammers but it also ties up valuable resources. Time will tell if it is a pain or a gain.
 
Enough whining. Back to my regular programming next week.


A Happy New Year to you all!

Thursday, December 15, 2005

1490.aspx

Smart Paster plugin for Visual Studio

Shame on me for not posting about the Smart Paster 1.1 plugin before.


In Windows Forms applications I sometimes have to show long messages explaining why an operation failed or to provide additional information. The text is usually provided by the customer or a technical writer. Cutting and pasting it directly is normally not an option as:



  • the string is impossible to read in the editor or on paper when it is too long
  • there may be formatting characters which have to be escaped

XML and other text formats with quotes in them are even worse.


Unless you use Spart Paster that is;



The Smart Paster inserts the contents in a properly formatted String builder according to the configuration options:


Building XML the brutal way with string (i.e. not using XmlWriter) becomes a piece of cake. This source string in the clipboard:



<root>
 <node attribA="a" attribB="b"/>
 <path ="c:\temp\test.txt"/>
</root>


Automagically becomes this if you paste it as a StringBuilder called builder:



StringBuilder builder = new StringBuilder(81);
builder.AppendFormat(@"{0}", Environment.NewLine);
builder.AppendFormat(@"{0}{1}", ControlChars.Tab, Environment.NewLine);
builder.AppendFormat(@"{0}{1}", ControlChars.Tab, Environment.NewLine);
builder.AppendFormat(@"
{0}", Environment.NewLine);


All quotes and strange characters taken care of. What more can you ask for?

Monday, December 12, 2005

1479.aspx

Troubled waters ahead: changing telco provider

I am changing telco provider this week so my site and mail will go offline for a (hopefully) short time.

Friday, December 9, 2005

1475.aspx

Error using SmtpMail: Could not access 'CDO.Message' object

I recently got a problem sending e-mail using System.Web.Mail.SmtpMail while implementing a system for notifying users that their password is about to expire. The SMTP server I was using supports authentication and .NET 1.1 automatically tries to log in if the server supports it. This is an edited network trace of the request that failed:



220 somehost Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready
EHLO egilh
250-somehost Hello [10.0.4.44]
...
250-AUTH GSSAPI NTLM LOGIN
250-AUTH=LOGIN
<250 OK AUTH LOGIN
<334 ...
>...=
<334 ...
>...==
<535 5.7.3 Authentication unsuccessful.


There is no properties for disabling automatic authentication, but you can control the behavior of the SMTP client using the Fields collection. The line in bold below shows how to control the authentication


System.Web.Mail.SmtpMail.SmtpServer = "10.10.*.*";
 
System.Web.Mail.MailMessage message = new System.Web.Mail.MailMessage();
message.From = "from@***.com";
message.Subject = "Mail subject";
message.To = "to@***.com";
message.Body = "And this is the body of the message";
 
// Set NO authentication (0=>none, 1=>basic, 2=>integrated)
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 0);
 
System.Web.Mail.SmtpMail.Send(message);
 

The http://schemas.microsoft.com/cdo/configuration namespace allows you to control a lot of other features as well. The most useful ones:



  • sendusername: User name to authenticate with

  • sendpassword: Password to authenticate with

  • smtpconnectiontimeout: Set the connection time out

  • smtpserverport: Control which port is used

  • smtpusessl: Use SSL when sending mail

Thursday, December 8, 2005

1470.aspx

Koders and CodeKeep plugins for .NET

A good code example is a great help when using a new API for the first time so I was pretty exited when Koders and CodeKeep released their plugins for Visual Studio. They take two different approaches:



  • CodeKeep searches private and public code sniplets

  • Koders searches a huge collection of source code


CodeKeep
I like the idea behind CodeKeep as it works on code sniplets that does something useful and not a huge db of source code. CodeKeep only has a plugin in for Visual Studio .NET 2003 but versions for Visual Studio 2005 and Eclipse should be out soon.



Even though I like the idea, I quickly hit a big limitation: CodeKeep only searches by Description or Title. This is a problem as it requires you (and everyone else) to enter a good great description. It maybe useful for organizing your own code sniplets but searching for sniplets on how to use a particular API is difficult.


Koders
Koders take the other approach; they do not search the title or description but the code. With an ever growing code base it allows you to find an example for most APIs.


The Koders Visual Studio plugin installs a menu short cut and a small search toolbar. Versions for 2003 and Eclipse are available as well.


Conclusion
Both solutions are useful, but I would prefer mix that allows me to:



  • search by code when I know the API I have problems with. The code must have a brief description/title so I know if it applies to my context or not.

  • search by title/description/category when I know the problem but not the API.

  • view feedback and provide feedback. The more people that find the code useful the higher rank it will get

  • work with a local and internet solution. I am sure the "private/public" concept of CodeKeep works but I doubt if my clients would be happy if I posted their code on the internet

Monday, December 5, 2005

1465.aspx

Mobility Developer Conference II (Milano)

The free Mobility Developer Conference II will be held in Milano Thursday 15/12/2005




Agenda:



  • Architecture of a mobile solution

  • Overview of Visual Studio 2005 and .NET Compact Framework 2.0

  • Strategies for exchanging information (MSMQ,Web Service, Socket, SQL CE, HTTP)

  • SQL Server 2005 Mobile Edition

  • The .NET Compact Framework connectivity APIs (SMS, Phone, Connection Manager, RAPI)

  • Tips and Tricks

See you there?

1463.aspx

How to get detailed file information using VB Script

The script I posted yesterday showed how to get the size files using FileSystemObject. Windows Explorer displays a lot more information like the Dimensions of photos, Audio bit rates of audio files etc. The Shell.Application object can be used to extract the following information: Album Title, Artist, Attributes, Author, Bit Rate, Camera Model, Category, Comments, Company, Copyright, Date Accessed, Date Created, Date Modified, Date Picture Taken, Description, Dimensions, Duration, File Version, Genre, Name, Owner, Pages, Product Name, Product Version, Protected, Size, Status, Subject, Title, Track Number, Type, Year


The GetDetailsOf() method gets one of the properties above. They are extracted using an ID from 0 to 34. The following script from Microsoft Technet gets the name of each property and then looks up the values for all files in the c:\temp directory. 


' Get the name of the different properties
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\temp")
For i = 0 to 34
    arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
Next
' Display the properties and their values for each file
For Each strFileName in objFolder.Items
    For i = 0 to 34
        Wscript.Echo i & vbtab & arrHeaders(i) _
            & ": " & objFolder.GetDetailsOf(strFileName, i)
    Next
Next

The Windows Image Acquisition Automation Library v2.0 can be used if you need basic image acquisition and manipulation functionality.

Sunday, December 4, 2005

1462.aspx

How to get the dimensions of files using the FileSystemObject

I got a question earlier this evening on how to get the dimensions of a file using the FileSystemObject. I put together the VBScript below that goes through all files of C:\ and lists the dimensions using the .Size property.


Option Explicit
'**
'Purpose: List sub directories with files and their sizes
dim oFS
dim oDir
set oFS = CreateObject("Scripting.FileSystemObject")
set oDir = oFS.GetFolder("C:\")
listDir (oDir)
sub listDir(rootDir)
'**
'Purpose: List contents of this directory and all subdirectories
dim oDir
dim oFile
    'Call ourselves for all sub directories
    WScript.echo rootDir.Path
    for each oDir in rootDir.SubFolders
        listDir (oDir)
    next
    'List all the files in this directory
    for each oFile in rootDir.Files
        WScript.echo vbTab & oFile.name & " [" & oFile.Size & " bytes]"
    next
end sub

Saturday, December 3, 2005

1451.aspx

Vodafone Live (Italy)

The latest release of vodafone live! (Italy) has taken away a lot of my time. The menu has moved to a different platform but the majority of the pages are still served by the platform where I am the software architect. After months of work it's nice to see it go live. With the latest generation devices you get a very rich user experience with background colors, tabbed navigation etc. as the following images show (sorry about the poor picture quality)


Home page:


Chat home page



A big step forward in terms of look and feel compared to what we released one year ago if you ask me.


I have recharged my batteries after the marathon release on the 1st of December so I should have the energy for posting something "useful" next week.