Transformers: Age of Extinction Guardians of the Galaxy Dawn of the Planet of the Apes


USA Vacation - Rockefeller Center USA Vacation - Central Park USA Vacation - General Tourism

Moving the users folder on Windows to another drive or partition

2014-05-06 16:34
I've seen this on several site, and I also have this written down on pieces of paper all over my office, both at home and at work, so I figure it's about time I get it somewhere more digital where I always know where I have it, as well as share this knowledge with other people who come by.

Read more

Posted in Technology | No Comments

Webservice calls hangs and gets a timeout exception

2014-03-20 12:46
Recently I encountered a problem using webservices in .Net.
At irregular intervals the code suddenly threw the following exception when calling a webservice:

System.Net.WebException: The operation has timed out

There was nothing magical in the code around the calls to the webservice where it was handled in the usual fashion:

WebserviceClass ws = new WebserviceClass();

When the code reached ws.Foo() it just waited there for over a minute before throwing the previously mentioned exception.

Since using webservices is extremely streamlined and standardized in Visual Studio I initially thought the problem had to lie somewhere else than my application, like maybe there were networking issues or the ISS server that hosted the webservice had some problems.
When troubleshooting all of the above and nothing panned out I was back to my application while scratching a hole in my head.

It turns out that when using webservices in .Net the framework can only have a maximum of two open connections to the server. My application fires off more than two requests, in addition to some scheduling tasks that run in the background of the application that also requests data from the webservice.

What was actually happening was some form of deadlock where two connections had been opened and not being closed fast enough so that my application was timing out because it just couldn't make a connection.

Thanks to Microsoft support we found the solution to be to allow more than two open connections. This can easily be done in the app.config file of the application by adding the following:

      <add address = "*" maxconnection = "10" />

Here the maximum number of connections has been increased to 10. For my application I increased it to 12, and we have never again experienced this timeout exception.

Microsoft's documentation of the app.config setting

Printing XPS files to a physical printer

2013-03-21 12:43
I had the need to programatically print an XPS file, but a couple of hours of Google searches only returned examples of how to print TO an XPS file. It was extremely difficult to find how to send a XPS file to an actual physical printer.
Eventually something turned up and the solution seemed to be the XpsDocument class.

Look at this simplified example to see how easy it turned out to be:

PrintDialog dlg = new PrintDialog();
XpsDocument xpsDoc = new XpsDocument(PATH_TO_YOUR_XPS_FILE_HERE, System.IO.FileAccess.Read);
dlg.PrintDocument(xpsDoc.GetFixedDocumentSequence().DocumentPaginator, "Document title");

As you can see, reading a XPS file and then sending the contents to a printer is not very hard at all.

Looking back at getting lost near Grand Canyon

2012-09-14 14:47
Having recently published my big Californian vacation video to YouTube I think it's time to reminisce a bit about my adventures.

As you already know from seeing the video and by photos in my photo album I went to Grand Canyon. Before traveling to the US, a colleague of mine mentioned the place where he visited Grand Canyon West and suggested I go there to.
I looked up the place on Google Maps, found the GPS coordinates and plotted those into my GPS to get driving directions.
My colleague warned me that the drive would seem a bit wrong because you would have to go onto some gravel roads, so when my GPS directed me onto a gravel road I didn't think much of it.
I did get a bit more suspicious when the gravel road got more narrow and led into some mountains. My worry reached its peak when I suddenly got to a sign that said "Only 4WD vehicles beyond this point". My GPS advised me to continue, but the sign, and the fact that I didn't have a 4WD car, advised me to turn around. What to do?!

Read more

Posted in Life, Travel | No Comments

Attention comment spammers

2012-09-12 17:44
I have now added a nofollow attribute to all links in the comments section, so spammers will no longer get increased page ranks from Google or other search engines.

For non-spammers, add the following to an anchor tag and google won't follow that link:

Posted in Technology | No Comments

For my sister

2012-09-03 16:20
My sister got married on Saturday, September 1.
There was a great party with many great speeches. I'm not claiming greatness on my own, but I will post it here (translated to English for my foreign friends) for everybody else to enjoy (for the first time, or again if you were there).
I said it many times that day, but I'll say it here again.

Congratulations to my sister and her husband!

Read more

Posted in Life | No Comments

Change image tag generated by CKEditor

2012-06-11 21:08
For a new project of mine I'm using a rich text editor called CKEditor.
This is a highly configurable editor that, unfortunately, suffers from cluttered and not easily understandable documentation.
I needed to change the generated HTML from the editor so that images that were resized not only had their size set as style attributes, but as query string variables.

So I needed this:
<img src="" style="width:150px; height:200px;" />

to be output as this:
<img src="" style="width:150px; height:200px;" />

That proved to be easier said than done, but after quite a lot of googling, asking on several forums, and getting some helpful (and some not helpful at all) replies, I finally ended up with the following:

Put the following code into CKEditor's config.js

CKEDITOR.on('instanceReady', function (ev) {
    var editor = ev.editor,
        dataProcessor = editor.dataProcessor,
        htmlFilter = dataProcessor && dataProcessor.htmlFilter;

    htmlFilter.addRules( {
        elements : {
            $ : function( element ) {
                // Output dimensions of images as width and height attributes on src
                if ( == 'img' ) {
                    var style =;
                    if (style) {
                        // Get the width from the style.
                        var match = /(?:^|\s)width\s*:\s*(\d+)px/i.exec( style ),
                            width = match && match[1];

                        // Get the height from the style.
                        match = /(?:^|\s)height\s*:\s*(\d+)px/i.exec( style );
                        var height = match && match[1];

                        var imgsrc = element.attributes.src + "?width=" + width + "&height=" + height;

                        element.attributes.src = imgsrc;
                        element.attributes['data-cke-saved-src'] = imgsrc;

This code is run whenever the CKEditor generates the actual HTML, which happens when you either view the source by clicking the "Source" button, or by performing an HTTP POST of that page.

A small warning, though. The code above will keep appending the width and height query strings for each click on the "Source" button, or for each postback, so you might want to add some extra logic to filter out the width and height query strings before appending them to the src attribute. (I might edit this post in the future with the correct syntax for that ;))

Art history lesson

2012-02-26 19:23
Art history lesson
Today my nephew got baptized. Let's not dwell on that and look at what I got him instead.
A few days ago I actually went into an art gallery and bought a piece of art. There's certainly a first time for everything! I hope the little guy will appreciate a genuine piece of art as he grows older.

What I got him was this lithograph from artist Per Krohg, son of the renowned Christian Krohg. Per originally made a series of pictures for his son Guy when he was a child. Each picture represented a letter in the alphabet. The family of artists were typical of their time and lived in France, so each picture also represented something in French.
Unfortunately the gallery didn't have the letter L, so I got the letter C (for "Collage" or "la chambre") instead because I liked the motif and it had a fitting look for a baby room. The picture is also numbered, so there are apparently 75 copies and this is number 35.
I'm interested in more information about this series, so if anybody out there can help do write me an email or a comment on this post.
Posted in Life | No Comments

Response.Redirect inside an UpdatePanel

2011-10-18 16:37
Recently I've had more and more pages displaying unexpected behaviour.
I had an UpdatePanel with a button inside it. The button's Click event performed a Response.Redirect(), but nothing happened.
The Javascript error console showed the following error message:

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

After some googling it seems that ASP.Net doesn't quite support Response.Redirect() inside UpdatePanels any more.

The solution was to make sure the button actually performed a full postback of the webpage, and not only a partial postback (as it would do because it was inside an UpdatePanel).

There are two ways of doing this. First the easy way.

<asp:UpdatePanel runat="server">
        <asp:Button ID="MyButton" runat="server" />
        <asp:PostBackTrigger ControlID="MyButton" />

Here you're basically telling the UpdatePanel that "MyButton" should perform a full postback instead of a partial one.

My problem was a bit more complicated, though, because "MyButton" was inside a GridView. This complicated things a bit, but not too much. Mainly you have to have access to the ScriptManager.

Add the OnRowDataBund event to your GridView. In this event do the following:

protected void MyGridview_RowDataBound(object sender, GridViewRowEventArgs e)
    if (e.Row.RowType == DataControlRowType.DataRow)
        Button MyButton = (Button)e.Row.FindControl("MyButton");

So instead of telling the UpdatePanel that your button should do a full postback, you're telling the ScriptManager the same thing.
Doing this in code-behind would obviously work for the first example as well.


This seems to be a recurring bug in .Net 2.0, 3.0 and 3.5, and is actually fixed in .Net 4.x.
I have successfully got a Response.Redirect() to work inside an update panel without using any of the above fixes, and only by upgrading my solution, projects and website to .Net 4.0.
Posted in .Net, Programming | 1 Comment

Samba/Winbind connection issues

2011-10-15 13:08
I recently had to reconfigure my linux (Ubuntu 10.04 LTS) servers.
I had previously used these two howto's to configure my servers.
Suddenly one of them refused to properly connect with various error messages:

# wbinfo -p
Ping to winbindd failed

# wbinfo -u
Error looking up domain users

# wbinfo -t
checking the trust secret via RPC calls failed
Could not check secret

After a week of googling I finally found the following solution, which did the trick for me.

Stop smbd, nmbd and winbindd (make sure they are really dead using ps. winbindd still lingered after I stopped the service)
Delete the linux computer from the Primary Domain Controller (using the Management Console)
Delete the secrets database (/var/lib/samba/secrets.tdb)
Join the domain again
Start the daemons (smbd, nmbd and winbindd)
Test the winbind commands to see that everything is working
Posted in Linux, Technology | 1 Comment