Thursday, November 29, 2007


Scroogled: what if Google was evil

I really enjoy the writings of Cory Doctorow and I own several autographed books. Scroogled: what if Google was evil is a short story that I found particularly fascinating as I am going to work for Scroogled soon...

Tuesday, November 20, 2007


Visual Studio 2008 and .NET Framework 3.5 RTM

Visual Studio 2008 and .NET Framework 3.5 have been released to manufacturing. You can find the links to the trial, express and full editions at the Visual Studio home page.

The Akamai Download Manager does not like the proxy I have at work so I have to wait until tonight before I can download it :-(

Tuesday, October 30, 2007


How to say this?

It was the best of times, it was the worst of times…

It has been an incredible adventure and a great experience…

There is no easy or soft way to say this, so let me make a long story short. After almost 12 years working for Iris Technologies, IrisCube, IrisCube Reply, Sytel Reply I am leaving the company to learn something new.

I cannot wait to get started in my new job as I have a lot to learn at 10100

To my colleagues that read this:

I have one wish for a personal goodbye gift from you. I would really love it if you can send me your Outlook Contact card with your picture/avatar and whatever other info you want to share like phone number, messenger alias, web site etc.

I will continue to work in the Milano area so I am sure we will meet again soon. Please drop by my office for a chat and coffee before my last day at work 6/12.

I will miss you all…

Wednesday, October 24, 2007


Vodafone Betavine

The Vodafone Betavine site is a open community website created and managed by Vodafone Group R&D with the mission to the wider development community in stimulating ideas, developing, testing and launching great new applications for mobile and Internet communications.

Interesting. Vodafone is huge, so they should have the power to make device manufacturers adhere to the (few) mobile browsing and applications standards that exists. If you are not familiar with developing for mobile devices, you can compare it with the problems we had a decade ago developing for Mozilla and Internet Explorer. But imagine a headache hundreds of times worse as each device has its own peculiarities (even “standard“ software like the Nokia Series Sxx).

The site is open to anyone and I am thrilled to see that Vodafone is not censoring complaints (at least so far).

Judging from some forums they could have called the site VodafoneBetaWhine…  Vodafone, correctly, get a lot of complaints regarding their Mobile Internet which basically destroys all internet sites that provide their own  mobile rendering. Vodafone Italy goes one step further than the Vodafone operators in other European countries and even imposes their own Vodafone header and footers on some mobile devices making it look like the service is provided by Vodafone. Difficult to explain to customers that pays for picture perfect rendering just to see it garbled by Vodafone...


Thanks for the link Maurizio.


How to fix Error 1714: The older version of ... cannot be removed

It is several years since I last reinstalled my PC and it shows. I used to keep the setup program for the downloaded software in a download directory but I do not do it anymore as:

  • it wastes space

  • it only takes a few seconds/minutes to download the latest version from the web.

But installing from a "temporary" directory causes one problem: some programs cannot be uninstalled as they are unable to find the original setup so they return "Error 1714: The older version of … cannot be removed". :-(

This is bad design if you ask me. If you need something from the original setup, either you copy the stuff you need to your application directory or you tell me that I have to save it somewhere for the future. Downloading the latest version from the web does not help as you need the particular setup program you installed with :-( :-(

Being stuck with tons of old software on my PC I cannot uninstall is bad enough. But, what really bugs me, is that some software cannot be installed unless you uninstall the old version. I tried to install the new version of Virtual PC and I got this message since I had Microsoft Virtual PC 2004 installed already:

Error 1714. The older version of Microsoft Virtual PC 2007 cannot be removed.

I was considering using RegMon to see which registry keys the VPC2007 setup uses when I found the Windows Installer CleanUp Utility. It does not uninstall the application as such, it just removes it from the list of applications that Windows thinks is installed. Ugly, but it fixed the problem for me.

Select the software you want to "uninstall" from the list, click Remove and hope for the best:

Monday, October 22, 2007


DateTime is not supported by gregorian calendar

I got this "new" exception when I was consuming one RSS feed:

System.FormatException was unhandled
 Message="The DateTime represented by the string is not supported in calendar System.Globalization.GregorianCalendar."
      at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
      at System.DateTime.Parse(String s)

System.DateTime.Parse chocked on this input date 2007-09-13T24:28:51Z

Forcing the current culture to System.Globalization.CultureInfo.InvariantCulture did not help so I ended up with this ugly hack:
 dateString = dateString.Replace("T24:", "T00:")

Let me know if you find a cleaner solution.

Friday, October 19, 2007


When MSDE is better than 2005

Believe it or not, I downgraded from SQL Server 2005 Express to MSDE and got a drastic performance improvement:

  • 6.0 seconds average call time with SQL Server 2005 Express 15/10

  • 1.9 seconds average call time with MSDE 18/10

The DB is identical in terms of data and indexes. The only difference is the SQL engine. I am still not 110% sure why, but as far as I can tell it is due to the different ways MSDE and SQL Server 2005 Express limits performance on my particular hardware. Or rather, lack of hardware, as I am hosting everything on a Virtual Server.

Until January this year I hosted my mail and blogs at home on a PC. It has been a valuable experience as I have learned a lot about hosting a service 24x7. But after almost 3 years I decided to host my mail and blog at a hosting provider. Aruba has a basic Virtual Server at 12 euro a month with Win2k3 64 bit, 8 CPUs, 3GB of disk, 512 MB of ram that is more than enough or me. But not for SQL Server 2005 apparently…

SQL Server 2005 Express limits performance to one physical CPU. This gives good performance on multi-core or hyperthreading CPUs. But, in the case of my Virtual Server I believe it is only using 1 of the 8 available CPUs becoming a bottleneck. MSDE, on the other hand, does not have a CPU limit the workload governor starts slowing down the database engine when more than eight operations are actively running at the same time. Which means that SQL Server 2000 Desktop Engine (MSDE 2000) is significantly faster than SQL Server 2005 Express on my “hardware“.

At least I believe this is the cause as I cannot think of any reason why my blog is suddenly 3 times faster than it used to be (after a few long nights downgrading by hand).

Thursday, October 18, 2007


How to display a top level window in .NET without making it active

For the poGmail program I needed a way to display a semi transparent alert window in the corner of the screen that was on top of all the other windows without giving it focus. .NET supports transparent windows but the forms are always brought to the front and given the input focus when you call .Show(). This is not nice when you are working, as whatever you write goes to the alert window instead of the current window.

The class below uses interop to modify the form so it does not get activated when you show it. You can call it from the constructor of the form like this: 


using System;

using System.Windows.Forms;

using System.Runtime.InteropServices;


namespace NoFocusWindow


    class WindowUtils



        extern public static bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);


        public const int HWND_TOPMOST = -1; // 0xffff

        public const int SWP_NOSIZE = 1; // 0x0001

        public const int SWP_NOMOVE = 2; // 0x0002        

        public const int SWP_NOACTIVATE = 16; // 0x0010

        public const int SWP_SHOWWINDOW = 64; // 0x0040        


        public static void SetWindowTopMostWithoutFocus(IntPtr handle)



                 (IntPtr)HWND_TOPMOST, 0, 0, 0, 0,




        public static void SetWindowTopMostWithoutFocus(Control ctrl)







Based on this class

Monday, October 15, 2007


poGmail: A Gmail notifier for the Pocket PC (beta)

This is the first time I am releasing a beta with some known issues...
I have decided to do it to cover as wide a range of Pocket PC/Windows Mobile devices as possible. I am using it on my Windows Mobile 5.0 Phone Edition device but I am sure there are problems with other versions and I would like to find and fix them.

You can download the latest version at the poGmail home page.

Installation instructions:

  • Install .NET Compact Framework 2.0 if you don't have it already

  • Copy the .CAB file to your device (via Active Sync or a memory card)

  • Run the .CAB.

  • Run poGmail and configure accounts and the download schedule

The setup program installs:

  • The Gmail client program (installed in the programs menu as poGmail)

  • The "today screen" plugin

The Gmail client uses the same configuration file as the PC version so you can copy it from the PC to the Pocket PC (\program files\poGmail) if you do not want to re-enter all the data on the pocket pc.

Known issues from beta testers:

  • The "today screen" plugin does not automatically show up after the installation. You have to  Click Start, Settings, Today, the "Items" tab then OK. Or you can soft reset your device.

  • The buttons do not work on the HTC Touch. I do not know if it applies to all Windows Mobile 6.0 devices.

  • Screen orientation. I have not added support for landscape mode yet

The unread mails are displayed using the file poGmailTemplate.htm as a template. Feel free to "customize" it as you want. Make a cool template and I will include it in the download.

Please let me know if you find any bugs and I will do my best to fix them

Sunday, September 30, 2007


SocketProxy 1.5

I have just released SocketProxy version 1.5 in the download section. The server stays the same but I have made changes to the Socket Proxy client configuration:

  • Automatic proxy configuration by client IP. Changes to the client IP is detected live so there is no need to restart the client .

  • New parameters for tuning performance.

  • Moved configuration from app.config to a .xml file in the same directory as the client. This makes the configuration easier to read and you can make changes on the fly as the file is parsed on each incoming connection.

Thursday, September 27, 2007


poGmail: feeding of Gmail

It took me forever to give birth to my February 2006 but soon realized that it would be a huge job as .NET CF is missing a lot of the features used by the Gmail API. Fixing some of the bugs in the API and using the Mono  source as a reference, I first got a version working on the PPC a couple a weeks ago.

Or at least I thought it did. It works perfectly on the PC but it frequently fails with a https error on the devices I have tried (iPaq 4150 and iPaq rw6815):

 _HResult -2146233079 int
 InnerException {"Procedura di convalida con il certificato remoto non riuscita."} System.Exception {System.Net.WebException}
 Message "Procedura di convalida con il certificato remoto non riuscita." string
 StackTrace "in System.Net.SslConnectionState.PerformClientHandShake()\r\nin System.Net.Connection.connect()…

A program that only works when the sun is shining is not worth releasing so I put it on the shelf until Michele reminded me of the RSS feature in gmail.

Eureka! Why suffer the risks of the Gmail API web scraping when I can use an official RSS feed that does everything for me?

I threw away the old code and implemented the first release of poGmail this weekend. It is simple and small (64kb) and implements the features I need:

  • Zero installation; just run the .exe. It creates a XML configuration file in the same directory as the .exe the first time you run it. Copy them both on a USB key to use it from anywhere :-)

  • Hold the mouse cursor over the notification window to pause the notifications

  • Click the subject in the notification window to read the mail

  • Automatic selection of proxy based on the current IP. Use a regular expression like 192.168.* if you are using DHCP.

  • It works with Google hosted domains

It is free so use it if you like it and let me know if you have any suggested improvements or find any bugs.

Almost all the code is shared between the Pocket PC and PC projects so the only hurdle left is integrating a .NET CF 2.0 project on the Today Screen on Windows Mobile. This article by Microsoft has a complete wrapper system based on Embedded VC 4.0 but it is fairly complex so I think I will code a lighter version.

Thanks cuzZle for giving poGmail a try and finding the first bugs!


poGmail: a free Gmail notifier for PC and Pocket PC that supports multiple gmail accounts

The Google Gmail Notifier only supports one gmail account. This is a problem for me as I have different gmail accounts for my blogs and domains.

So, I implemented a basic Gmail notifier that has the features I need:

  • Zero installation; just run the .exe. It creates a XML configuration file in the same directory as the .exe the first time you run it.
  • Hold the mouse cursor over the notification window to pause the notifications
  • Click the subject in the notification window to read the mail
  • Automatic selection of proxy based on your current IP. You can specify your full client IP in the proxy configuration window or use a regular expression to configure a partial IP if you use DHCP for example. Example 192.168.*
  • It works with Google hosted domains

Let me know if you find any bugs or have any suggested improvements.

You can download poGmail here. It requires .NET 2.0

Version history:

  • Fixed a problem when adding new accounts
  • Fixed a problem when editing an existing proxy
  • Aligned config file with Pocket PC version. Minor bug fixes.
  • Fixed crash if “Display interval” was set to 0. Thanks Matteo.
  • Fixed a problem where the client would crash if the “Check interval” was set to 0. Thanks Greg.

= Pocket PC version =

The Gmail client uses the same configuration file as the PC version so you can copy it from the PC to the Pocket PC (\program files\poGmail) if you do not want to re-enter all the data on the pocket pc.

Download the Pocket PC files and:

  • Copy all files in the .zip to a directory of your choice on the Windows Mobile. The application works fine from a memory card, but the Today screen plugin only works if installed on the device.
  • Run poGmail.exe and open the configuration dialog

    • Select the days you want poGmail to automatically check for new mail

Version history:

  • Monday to Friday is set as the default schedule for checking mails. The Today Screen plugin shows the mail status via the icon (white=ok, red=error)
  • The account configuration form did not work correctly. Thanks Chris.

Monday, September 17, 2007


Fix Windows Live Mail beta 0x8DE00002 error

I have used Windows Live Mail Desktop beta for almost one year without any serious problems. Synchronizing with Hotmail stopped working recently and gave me this error:

Unable to poll for new messages on your HTTP server. There is an error synchronizing your mail account. Please verify your account has been configured correctly by first accessing your mail on the web. Server: '', Protocol: HTTPMail, Server Response: 'Client is requesting a deprecated version of the service. User should upgrade to the newest version of the client', Port: 80, Secure(SSL): No, Server Error: 4109, Error Number: 0x8DE00002

The problem was, for once, pretty clear from the error message: Client is requesting a deprecated version of the service. User should upgrade to the newest version of the client I tried many times but Windows Update did not find a new version.

It turns out it is a "feature" unless your regional settings is set to EN-US. You can try to modify your settings or download the latest client (V12.0.1184) here which fixes the problem

Warning: Windows Live Mail will move your mail to your documents folder even if you, like me, have it stored somewhere else. It took well over half an hour to start the first time as it imported all my old mails but after that it works pretty fast.

Warning 2: This version has problems with some POP3 mail providers. It works OK with the providers I use but YMMV.


Free UGISS event 3/10: Road to Katmai - SQL Server 2008

UGISS, the Italian SQL Server Users Group, is organizing a free event with Microsoft 3/10 Road to Katmai - SQL Server 2008 [Italian] in Milano. I have attended several of the other UGISS events and I highly recommend them.

Morning Agenda:

  • SQL Server 2008 Public CTP - Data Platform Overview (Speaker: Davide Mauri)

  • Database & Time-Dependent Data - Parte 2 (Speaker: Gianluca Hotz)

Afternoon DBA Track:

  • SQL Server 2008 Public CTP - Novità per gli amministratori (Speaker: Gianluca Hotz)

  • Monitoring & Testing Tools (Speaker: Davide Mauri)

  • TBD

Afternoon Developer Track:

  • SQL Server 2008 Public CTP - Novità per gli sviluppatori (Speaker: Andrea Benedetti)

  • Advanced SQLCLR: ricerca di testi simili (Speaker: Marcello Poletti)

  • SQL Server 2005 Compact Edition: Advanced Concepts (Speaker: Marco Frontini)

Wednesday, August 29, 2007


.NET libraries for writing your own messenger bot

I do not use Instant Messaging as much as some of my friends but I can imagine several services that would be useful via IM. There are endless opportunities when you consider that IM can offer push as well as pull services.

It looks like I am not the only one as there are several open source .NET libraries for working with Microsoft Messenger:

  • DotMSN 2.0 supports the MSNP9 protocol.

  • MSNPSharp extends DotMSN 2.0 with support for the MSNP11 protocol.

I am busy working on several other hobby projects at the moment but I would love to put together a IM bot later this year. What kind of services you would like to access via IM?


Real PreAuthenticate for .NET Web Services

.NET Web Service clients do not send authentication details with the requests so you get a traffic pattern like this

Request 1:

Client: GET someUrl
Server: 401 WWW-Authenticate Basic
Client: GET with Authorization header
Server: 200 OK

Request 2:

Client: GET someUrl
Server: 401 WWW-Authenticate Basic
Client: GET with Authorization header
Server: 200 OK

The PreAuthenticate property improves the situation if you make many repeated calls to a web service.

Request 1:

Client: GET someUrl
Server: 401 WWW-Authenticate Basic
Client: GET with Authorization header
Server: 200 OK

Request 2:

Client: GET someUrl with Authorization header
Server: 200 OK

The first request does not contain the Authorization header but the subsequent requests do. I do not like this feature as the systems I work on usually make one single web service request per client request so I always get 401 errors.

You can fix the problem by manually inserting the Authorization header in the requests. Do not modify the Web Service client generated by Visual Studio as you will loose your changes if you update the Web Reference.  Extend the Web Service client instead and override the GetWebRequest method:

public class WSTestPreAuthenticate : WSTest


    protected override System.Net.WebRequest GetWebRequest(Uri uri)


        HttpWebRequest request;

        request = (HttpWebRequest)base.GetWebRequest(uri);


        if (PreAuthenticate)


            NetworkCredential networkCredentials =

                Credentials.GetCredential(uri, "Basic");



            if (networkCredentials != null)


                byte[] credentialBuffer = new UTF8Encoding().GetBytes(

                    networkCredentials.UserName + ":" +


                request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(credentialBuffer);



        return request;



The change above means that PreAuthentication works as it should since it always sends the Authorization header

Request 1:

Client: GET someUrl with Authorization header
Server: 200 OK

The client has to set the PreAuthenticate header and any custom credentials:

WSTestPreAuthenticate test = new WSTestPreAuthenticate ();

test.PreAuthenticate = true;

test.Url = "http://localhost/WSTest/WSTest.asmx";

test.Credentials =

new System.Net.NetworkCredential("user", "password");

int ret = test.Method("test");

Tuesday, August 28, 2007


Performance problem with ADO, stored procedures, BLOBs and SQL Server

There is a know bug in ADO that causes horrible performance with ADO if you insert a BLOB via stored procedure. Working on a (almost) real time import of data I noticed that importing blobs took forever….

I did the right thing and used stored procedures for all data access. In this case it was a mistake as it took several minutes to insert a small blob of a few hundred KB.

I ended up with the workaround below. It is ugly but the least “dirty” solution I found:

 set oCon = CreateObject("ADODB.Connection")
oCon.ConnectionString = CONNECTION_STRONG
Set oCmd = CreateObject("ADODB.Command")
set oCmd.ActiveConnection = oCon
oCmd.CommandType = adCmdStoredProc
oCmd.CommandText = "usp_insert_item"
oCmd.Parameters("@whatever").value = somedataHre
oCmd.Parameters("@PageData").value = "dummy"
 'The stored procedure returns the ID of the new record as newID
Set oRS = oCmd.Execute
BinaryID = oRS("newID")

'Update the binary data field
set oRS = CreateObject("ADODB.Recordset")
oRS.CursorLocation = 3
oRS.CursorType = 1
oRS.LockType = 2
set oRS.ActiveConnection = oCon
oRS.Open "select BlobField from TheTable where ID=" & BinaryID
oRS.Fields("BlogField").Value = TheBinaryData

Set oRS = Nothing
Set oCmd = Nothing
set oCon = Nothing

Friday, August 24, 2007


The Sun BlackBox

Wouldn't it be fantastic if the Sun BlackBox could be used in emergency situations like this photo(shop?) shows:

But, using them for Red Cross emergencies is not feasible today as the BlackBox is hungry:

  • Cooling water supply: 60 gallons (~230 liters) per minute of cold water at 13 degrees Celsius which means a large coldwater supply or a small water supply with a serious cooler

  • Dual 600 amp feeds power feeds

  • High bandwidth internet connection

Pretty hard to find in emergency situations, in Africa or elsewhere.

It is no wonder the box is hungry considering the possible configurations:

  • A single Project Blackbox could accommodate 250 Sun Fire T1000 servers with the CoolThreads technology with 2000 cores and 8000 simultaneous threads.

  • A single Project Blackbox could accommodate 250 x64-based servers with 1000 cores.

  • A single Project Blackbox could provide as much as 1.5 petabytes of disk storage or 2 petabytes of energy-efficient tape storage.

  • A single Project Blackbox could provide 7 terabytes of memory.

  • A single Project Blackbox could handle up to 10,000 simultaneous desktop users. 

  • A single Project Blackbox currently has sufficient power and cooling to support 200 kilowatts of rackmounted equipment.

Ignoring the humanitarian benefits it is still an interesting concept for some companies due to its benefits:

  • The black box gives a lot of computing power considering its size

  • It is quick to deploy (just plug in the water, internet connection and power)

  • It is cheaper than building your own data center

  • It gives a 20% improvement in energy saving compared to normal data centers

You can get a look inside the box and more info at YouTube:

Via SciAm August 2007 [pages 74-77]


Sometimes you just have to say NO!

Saying NO is important many times in life. Kids have to learn limits, you have to say NO to leave time for yourself and your family but you also have to say NO at work, especially if you are a consultant.

Being a consultant does not mean that you should Con & insult but help the client reach the best possible solution. It is just too tempting to go with the flow and use XML and open source for everything. It is especially important that architects have "the balls" to say NO when clients/colleagues make requests that do not make any sense. I am the first to admit that saying YES is the simplest option to make "the problem" go away but you will pay for it in the long run.

Gartner estimates that:

Trough 2011, enterprises will waste $100bn buying the wrong networking technologies and services. Enterprises are missing out on opportunities to build a network that would put them at a competitive advantage. Instead, they follow outdated design practices and collectively will waste at least $100bn in the next five years.

Add the cost for using the wrong development technologies and architectures and you get a mind boggling number.

Just saying NO does not work unless you are an authority figure (so people trust whatever you say) so it is better to teach/guide people to reach the right conclusion themselves. I am not saying it is easy, but having kids to “practice on” daily helps :-)

Thursday, August 23, 2007


Notte di fiaba - Riva del Garda 23/8-26/8

Notte di Fiaba takes place in Riva del Garda 23/8-26/8. This years theme is "Pippi Calzelunghe". I cannot attend as I  will be working this weekend so please let me know what you think of it if you go.

This picture is from 2005 when the theme was “The wizard of Oz“:

It starts today and continues until Sunday. You can find the program here.


WebProxy.Credentials does not work when KeepAlive = false in .NET 1.1

While working on the next version of SocketProxy I came along a strange issue with Proxy NetworkCredentials not working.

This is the code:

System.Net.WebProxy uplinkProxy;               


uplinkProxy = new System.Net.WebProxy(txtProxy.Text);

uplinkProxy.Credentials = new System.Net.NetworkCredential(txtUser.Text, txtPassword.Text);                                         


System.Net.HttpWebRequest request = (HttpWebRequest) WebRequest.Create(txtSite.Text);


request.Proxy = uplinkProxy; 


System.Net.HttpWebResponse response = (HttpWebResponse) request.GetResponse();     


Using WireShark (ex Ethereal) I noticed that my proxy authentication was not passed:

Proxy-Connection: Close


HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )
Proxy-Authenticate: Negotiate
Proxy-Authenticate: Kerberos
Proxy-Authenticate: NTLM
Proxy-Authenticate: Basic realm="..."

The interesting thing is that it works fine with HTTPS which is why I did not notice the problem earlier.


Proxy-Authorization: Negotiate TlRMT...==


HTTP/1.1 407 Proxy Authentication Required ( Access is denied.  )
Proxy-Authenticate: Negotiate TlRMT..=
Content-Length: 0    

Automatic second request:

Proxy-Authorization: Negotiate TlRMT...=

Second reply

HTTP/1.1 200 Connection established
Connection: Keep-Alive
Proxy-Connection: Keep-Alive

Set KeepAlive to true and it works since the .NET client automaticlly makes two requests, just like .NET 2.0 does:

First request:

Proxy-Authorization: Negotiate TlRMT...==


HTTP/1.1 407 Proxy Authentication Required ( Access is denied.  )
Proxy-Authenticate: Negotiate TlRMTV...=
Connection: Keep-Alive 

Automatic second request:

Proxy-Authorization: Negotiate TlRMTV...=

Second reply

HTTP/1.1 200 OK
Connection: Keep-Alive

Wednesday, August 22, 2007


Windows Update error 0x80072EFD and proxy scripts

Windows Update failed on my PC earlier this week with error 0x80072EFD.  It is a very generic error that just means that the Windows Update client did not receive a response from the Windows Update Web site.

Microsoft KB article #836941 explains the steps that normally resolve the error but it did not work for me. In my case it was caused the Proxy auto configuration configuration script I am using.

The PAC script works grand when browsing but Windows Update refuses to work. Temporarily disabling the PAC script and configuring a static proxy works.

The proxy script below is based on one I got from Michele. It has the following features:

  • Disables ads in Live Messenger and Live mail by sending requests for the host to a proxy that does not exist :-)

  • Uses direct internet access from home

  • Supports different proxy configurations for several clients (I have changed the real IPs and hosts)
// Configure it as file://c:/scripts/proxy.pac
function FindProxyForURL(url, host)
// Set if (true) to show debug messages
if (false)
if (host == "" || host == "localhost")
return "DIRECT";
// Disable Live Messenger/Mail ads by pointing to proxy that does not exist
if (host == "")
return "PROXY";
// Home Network
if (isInNet(myIpAddress(), "", ""))
return "DIRECT";
// Client 1. Direct access to local network and to Exchange server
if (isInNet(myIpAddress(), "", ""))
if ((isInNet(host, "", ""))||(host == ""))
return "DIRECT";
return "PROXY";

// Client 2
if (isInNet(myIpAddress(), "", ""))
if (isInNet(host, "", ""))
return "DIRECT";
return "PROXY";
   // N other clients here..

// Anything else goes directly
return "DIRECT";

A quick intro to the functions/variables used in the script:

  • The host variable tells the script which site I am accessing

  • myIpAddress() returns my ip address which changes according to my location

  • I match my ip address against a subnet using isInNet() to know if I am at home, in the office or on site at a client

  • The function returns the string “DIRECT“ if the host can be reached directly otherwise it returns “PROXY ip-or-host:port“

More info on how Windows Update works with proxies here:

Tuesday, August 21, 2007


The technology behind Google

I am sure you already know about Google Labs, but if you are into technology you have to have a check out the papers written by Googlers. There is something for everyone:

  • Algorithms and Theory (33)

  • Artificial Intelligence and Data Mining (21)

  • Audio, Video, and Image Processing (18)

  • Distributed Systems and Parallel Computing (47)

  • Human-Computer Interaction (9)

  • Hypertext and the Web (11)

  • Information Retrieval (22)

  • Machine Learning (38)

  • Natural Language Processing (20)

  • Science (7)

  • Security, Cryptography, and Privacy (12)

  • Software Engineering (10)

I recently read and learned a lot from these papers:

  • Google File System: how Google stores peta byte upon peta byte of data in a redundant and distributed system 

  • BigTable: Distributed storage of structured data

  • MapReduce If you think multi threaded programming is hard, you should try parallel computing

It is a shame that Microsoft does not have something similar at

Saturday, August 18, 2007


MonoDevelop - .NET development on Linux, Solaris, Mac OS X (and Windows)

Mono has gone a long way since Miguel de Icaza started work on it in 2001. It can run binaries produced by Visual Studio and it has C# and VB.NET compilers. Mono is still working on full .NET 2.0 support but they have a lot of interesting features in the Mono namespace:

  • Gtk#: Bindings for the popular Gtk+ GUI toolkit for UNIX and Windows systems. Other bindings are available: Diacanvas-Sharp and MrProject.
  • #ZipLib: A library to manipulate various kinds of compressed files and archives (Zip and tar).
  • Tao Framework: bindings for OpenGL
  • Mono.Directory.LDAP / Novell.Directory.LDAP: LDAP access for .NET apps.
  • Mono.Data: We ship support for PostgreSQL, MySQL, Firebird, Sybase ASE, IBM DB2, SQLite, Microsoft SQL Server, Oracle, and ODBC data sources.
  • Mono.Cairo: Bindings for the Cairo rendering engine (Our System.Drawing is implemented on top of this).
  • Mono.Posix / Mono.UNIX: Bindings for building POSIX applications using C#.
  • Mono.Remoting.Channels.Unix: Unix socket based remoting
  • Mono.Security: Enhanced security and crypto framework
  • Mono.Math: BigInteger and Prime number generation
  • Mono.Http: Support for creating custom, embedded HTTP servers and common HTTP handlers for your applications.
  • Mono.XML: Extended support for XML
  • Managed.Windows.Forms (aka System.Windows.Forms): A complete and cross platform, System.Drawing based Winforms implementation.
  • Remoting.CORBA: A CORBA implementation for Mono.
  • Ginzu: An implementation on top of Remoting for the ICE stack

You can try it on Windows or download a Vmware image with Mono 1.2.4 installed on openSUSE 10.2

Earlier this month they also released Monodevelop 0.15 which has all the features you would expect from a modern development IDE like code completion, projects and add-in support:

I spend my time developing for Windows these days but it is great to see that support for .NET is growing on other platforms as well. Mono supports embedded http servers and http handlers but it would be great to see a .NET cross platform application server.

[Update: made some small formatting changes]

Thursday, August 16, 2007


A simple queue using tables in Microsoft SQL Server

I needed a fast and reliable queue in SQL when running some distributed tests but I did not find anything that suited my needs so I put together the simple system below. My main requirements were:

  • support hundreds of parallel readers and writers

  • each request in the queue must only be returned to one reader

  • make it easy to monitor the performance of my readers and writers.

It consists of two stored procedures:

  • usp_Request_push adds one requst to the queue (RequestsQueue table)

  • usp_Request_pop returns one request from the queue and moves it to the RequestsCompleted table

The RequestsCompleted table is optional but I added it for several reasons:

  • Track all requests to verify that my client does not "loose" messages. Any record in RequestsCompleted with a "RemovedDate" but a NULL "CompletedDate" got lost somewhere.

  • To calculate statistics like average time before the message was removed from the queue and average time before the request was completed by the client.


CREATE TABLE [dbo].[RequestsQueue](

      [id] [uniqueidentifier] NOT NULL

CONSTRAINT [DF_RequestsQueue_id] 

DEFAULT (newid()),

      [request] [varchar](512) NOT NULL,

      [InsertedDate] [datetime] NOT NULL

CONSTRAINT [DF_RequestsQueue_InsertedDate] 

DEFAULT (getdate()),



      [id] ASC




CREATE TABLE [dbo].[RequestsCompleted](

      [id] [uniqueidentifier] NOT NULL

CONSTRAINT [DF_RequestsCompleted_id] 

DEFAULT (newid()),

      [request] [varchar](512) NOT NULL,

      [InsertedDate] [datetime] NOT NULL

CONSTRAINT [DF_RequestsCompleted_InsertedDate] 

DEFAULT (getdate()),

      [RemovedDate] [datetime] NOT NULL

CONSTRAINT [DF_RequestsCompleted_RemovedDate] 

DEFAULT (getdate()),

      [CompletedDate] [datetime] NULL



Stored procedures

CREATE PROCEDURE [dbo].[usp_Request_Pop] 




@request varchar(512),

@id uniqueidentifier,

@InsertedDate datetime



    The queue works like this:

    - Get the first record in the queue     

    - "Move" the recor to the RequestCompleted table

    - return the request to the caller


    We use a locking cursor so the same record cannot be

    returned to two different clients    





      set @id=null

begin transaction

      DECLARE Stack_Cursor CURSOR FOR

            SELECT TOP 1 id, request, InsertedDate

            FROM RequestsQueue with (ROWLOCK, FASTFIRSTROW, XLOCK)           


      OPEN Stack_Cursor;


      FETCH NEXT FROM Stack_Cursor INTO @id, @request, @InsertedDate

      IF @@FETCH_STATUS = 0


            delete RequestsQueue where current of Stack_Cursor         



      CLOSE Stack_Cursor;

      DEALLOCATE Stack_Cursor;

commit transaction     


if not @id is null


    -- OPTIONAL store to the Completed table.

      insert into RequestsCompleted (id, request, insertedDate)

            values (@id, @request, @InsertedDate)


      -- return data to caller

      select @id as id, @request as request, @InsertedDate as InsertedDate





CREATE PROCEDURE [dbo].[usp_Request_Push]

@request varchar(512)




   insert into RequestsQueue(request) values (@request)



Note: The queue is not guaranteed to be FIFO as the select statement does not sort the records in any way. It is normally FIFO as SQL Server appends records in tables that do not have a clustered index.