Author Archive

Improve Wordpress permalinks in IIS7

Tuesday, May 5th, 2009

Using Wordpress on a Windows Server with IIS7 causes the permalinks to have “index.php” in the url. An example would be “http://www.smartasseses.be/index.php/2009/05/05/improve-wordpress-permalinks-in-iis7″, while this url is a valid link which will be spidered by search engines, it isn’t as esthetical as one would like.

Removing the “index.php” is rather straightforward, once you know how to. First you wan’t to add the following Web.Config to you virtual directory running the Wordpress blog. This will enable a rewriting rule in IIS7, which will rewrite every request that does not point to a physical file to “index.php”. Basicly transforming it to the way it previously worked.

<?xml version="1.0"?>
<configuration>
    <system.webServer>
      <rewrite>
        <rules>
          <rule name="Main Rule" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAll">
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
            <action type="Rewrite" url="index.php" />
          </rule>
        </rules>
      </rewrite>
    </system.webServer>
</configuration>

Once we’ve added the config we can change the permalink structure in the admin pages of Wordpress. Choose your structure and remove the “index.php” prefix, be sure to leave a slash at the beginning of the desired structure.

// Change this:
/index.php/%year%/%monthnum%/%day%/%postname%/

// To this for instance:
/%year%/%monthnum%/%day%/%postname%/

Strongly typed databinding

Monday, March 23rd, 2009

Databinding proves to be very useful in some cases, but often turns out to be a maintenance nightmare. Since it requires strings with the property names to be passed as parameters of the Binding object. When the class, where a textbox is binded to, changes over time, so do property names. But since these property names are passed around as a string, they do not raise compile errors, causing unexpected behaviour of the application.

Here’s how you can make these bindings strongly typed, causing compilation errors if the property name of a class would change. Imagine we would like to bind a textbox to the Name property of the Person class, here’s the function that is going to help us. This function has a lambda expression returning a string and receiving a Person as parameter.

public string GetPropertyName(Expression<Func<Person, string>> propertySelector)
{
   MemberExpression memberExpression = propertySelector.Body as MemberExpression;
   MemberInfo propertyInfo = memberExpression.Member;
   return propertyInfo.Name;
}

The original binding code would like this, notice the “Name” string.

m_TextEditPerson.DataBindings.Add(new Binding("Text", m_Person, "Name"));

Here’s the new binding statement.

m_TextEditPerson.DataBindings.Add(new Binding("Text", m_Person, GetPropertyName(x => x.Name)));

Breakpoints in Xcode stop firing

Wednesday, February 18th, 2009

Apple's Xcode is a nice IDE and just like every program it has its occasional quirks. Here's a tip: when all of a sudden your breakpoints stop firing, without any apparent reason, try this: Instead of following Googles advice and deselecting the "Load symbols lazily" option in the Preferences screen, (which will solve the breakpoints not hitting, I have to admit) perform a cleanup of your target. (Build – Clean All Targets) This will remove all intermediate files created during the build process and will force Xcode to process every file the next time you build, basicly a full rebuild. Xcode processes only the changed files during subsequent builds, but apparently this incremental strategy fails once in a while, with the aforementioned effect.

In the end both methods solve the problem, but I like to leave the default settings on, instead of changing them to fix some glitch in the system.

WCF Reliable Session and keep-alives

Monday, January 26th, 2009

We recently used WCF services for a monitoring application, which showed the status of business-critical systems like water/fire-detection in the datacenter, generators powering the production lines and so on. 

Instead of using a polling mechanism, we used an event-driven approach. The clients would subscribe for certain events and the server would notify the clients when these events happened. Relieving the network of excessive and possibly unneeded chatter. Because of the "business-critical" aspect of the application, we had to ensure that our communication with the server was not halted or interrupted. If something happened to the connection, the client would have to notify the user, instead of showing green lights and giving the user the impression that everything is a-ok, while all hell broke loose in the datacenter (and also destroying the PLC) for instance. Since our client would wait for events to happen and wouldn't know when the connection would have been dropped for some reason.

While working through the WCF documentation, we stumbled upon the Reliable Session which could be specified in the binding of the connection. According to the documentation a Reliable Session would send a keep-alive message after half of the Inactivity Timeout. Unfortunately the expected behaviour was not the same as the actual behaviour, the connection would go to the faulted state after 10 minutes despite configuring an Inactivity Timeout of 10 minutes. (Which should have forced a keep-alive message to be sent after 5 minutes) Eventually we came accross this blog post by Paulo Reichert, clarifying this glitch. Apparently it was supposed to work that way, but a last minute change to the Receive Timeout behaviour overrode the keep-alive behaviour. *couch* Unit Testing *couch* 

In the end we implemented our own keep-alive system in the form of a watchdog. A registry in a PLC would change every x seconds and the client would be notified of this change through an event. If our client does not detect a change of this registry for y seconds we notify the user. This ensures the connectivity between the client & server (including feedback to the user) and the proper workings of the PLC. The "keep-alive" message resets the Inactivity Timeout, prohibiting it from reaching the specified value and causing the connection to be dropped.

Setting the Receive Timeout to infinite, as suggested by Microsoft, is a work-around which does not solve the problem at a fundamental level. We sincerely hope Microsoft will fix this bug in a future release!

Welcome to our newest employee

Monday, October 20th, 2008

Sometimes, things just work out the way you wanted it to. In a world were tight deadlines, buckets of work and not enough time prevail, our newest addition to the team just walks right into the office. Behold our newest employee: Barry! Fluent in C#, years of experience with Spring.NET & NHibernate, a natural born leader, …

barry

Welcome to the team Barry, may the deadlines be with you.

PS: for the record, Barry is a girl!

MIX essentials

Tuesday, May 13th, 2008

A few weeks ago, the 24th of april to be exact, the Softelligent development team went to MIX essentials in Louvain-la-Neuve. The MIX essentials events are a slimmed down version of the American MIX 08 events and give an overview of what was handled on the American mainland. Luc Vandevelde was the main host and introduced the foreign and not so foreign speakers.

mix1

The event consisted of 2 tracks, one focused on development and the other on “men in suits” topics. We followed the development track which gave an introduction to Silverlight and MSN Live services and how to integrate them in your own applications.

The final keynote speaker was “Steve B” as he calls him self. The current CEO of Microsoft shared his view on IT in general and spent almost half of his time answering questions from the audience. Literally everyone was hanging on his lips, mister Ballmer is a very charismatic person. Although he didn’t perform his signature monkey dance, despite someone mentioning it during a question.

mix2

The event itself was ok, Silverlight looks pretty awesome, especially the Deep Zoom functionality. But nothing groundbraking was shown, seeing and hearing Steve B on the other hand was worth the trip anyway. I’ll probably never see someone who is richer for the rest of my life.

Minimal Lucene.Net example

Tuesday, April 15th, 2008

About a year ago we had to incorporate a Lucene.Net index in an application because we were unable to achieve acceptable speeds while performing regular SQL queries on a database. The database was a 4GB large – poorly normalised – full of NULLs – monster, which would eat our queries for breakfast and spit out time-outs in return. We had to make a Google-like search on the data spanning a lot of columns, including full-text search. Using Lucene.Net to index the searchable columns of this database enabled us to search the data within seconds and in some cases even work without the actual database. Because all the data which had to be shown as the result of the search could be extracted out of the index.

Lucene.Net has gained rapid exposure and several articles & tutorials can be found on how to implement it. Quite some time ago I made a minimal example on how to create an index and search it, I thought I’d share it, maybe it’ll help someone with his first steps in the Lucene.Net world.

The minimal Lucene.Net example creates an index of all the postal codes of Belgium (data is read from a .csv file), the postal codes can be searched and the results are shown in a list. Nothing more, nothing less.

Some extra information:

Analyzer analyzer = new StandardAnalyzer();

An analyzer is used when indexing raw text to transform it into searchable terms, removing frequently used words like “the”, “in”, “a”, “and”, “of”.

IndexWriter writer = new IndexWriter(indexFolder, analyzer, true);

An IndexWriter is used for creating and adding/removing items to/from the index, an analyzer should be specified which is used when adding data to the index.

Document document = new Document();
 
document.Add(new Field(POSTALCODECOLUMN, parts[0], Field.Store.YES, Field.Index.UN_TOKENIZED));
document.Add(new Field(CITYCOLUMN, parts[1], Field.Store.YES, Field.Index.UN_TOKENIZED));
 
writer.AddDocument(document);

A document is like a virtual record which contains the fields which are searchable. A field can be specified more than once, if a city has for some reason multiple postal codes, these can be added with the same field name and each time with a different postal code.

writer.Optimize();

After adding the documents the writer is optimized, which rewrites the entire index by merging all segment files into one file, greatly reducing the fysical size of the index and the searching speed.

The example is a VS2005 solution and uses Lucene.Net version 2.0.0.4 (included in the zip-file).

Minimal Lucene Example

Softelligent Usb-sticks

Thursday, March 27th, 2008

They have arrived, so come check us out at the next event and receive your free Softelligent goody. Available in one flavour, one size fits all: Softelligent Usb-sticks with a capacity of 1GB!

usb

Heroes happen {here}

Wednesday, March 12th, 2008

“Developers! Developers! Developers!” These words, made famous by an over-excited Steve Ballmer, are starting to live their own life. Microsoft is even dedicating an event to the developers. Besides launching Visual Studio 2008, SQL Server 2008 and Windows Server 2008, they are putting the developers in the spotlight. Because they are making the applications & programs that keep the world from crumbling down and grinding to a halt. The heroes are the developers (and not only the men in suits who sell what we make, according to Microsoft)

heroeshappenhere1

First product we saw was Windows Server 2008. I think the biggest change is the fact that instead of everything being on by default, now everything is turned off. Every component can be configured as needed, if you need a webserver you only need to install and configure that part you can even drop the interface and work only with the system from a console. An other big improvement being introduced is a very advanced and easy to use virtualisation interface which allows you to get a new server running in no time, easy deploy the same configuration on several systems, analyse your entire farm for point of failurers. For more information you can visit this article on Tom’s Hardware or the homepage on the Microsoft site.

heroeshappenhere2

Next up we visited three development sessions. One session quickly went over the new features in Visual Studio 2008, nothing new here. I think the best feature being introduced is being able to target different versions of the framework from one IDE, but everyone knew that already.

The other session was an introduction to the new web development features. Most of the time went to the integration with Ajax and some new tools, like a CSS tool to check how a certain item gets its layout and a new split view to view the markup and design at the same time.

The last session, and the best one we think, was about developing applications for Windows Vista and Office. The Microsoft Synch framework was thrown in aswell. I must say I was quite impressed. WPF really allows us Windows developers to create those nice looking applications that in the past were only available to web developers. Our own AdventureWorks application will definitaly have a frontend using this technology. For more information here’s a link to the VS 2008 homepage.

This pretty much sums it up, we all had a great time and some tasty muffins.

Yannick, Lemmy & Benny