Count items in a Sitecore folder

A quick sql script can find any big offenders:

Sitecore tree performance from IIS logs

If you want to find out average load times for eg how long nodes take to load use the following iis log query and then filter the data in excel:

See IIS Log parser for how to run these queries.

Powershell regex

If you need to parse some content, run a regex and then select the distinct results its all pretty simple in linq. How about powershell?

If you don’t want to target the specific group then simplify the match selection:

The neat thing here is using the | syntax you can easily distinct the list prior to writing to the file.

IE11, user agent sniffing vs feature detection

I recently found a bug in curvycorners.js and IE11 – curvycorners uses user agent sniffing to detect ie browsers by looking for the presence of ‘msie’. However the IE11 user agent has changed and become far more complicated to sniff! This blog explains the changes:

User Agent sniffing seems to be a common way of detecting the browser and version in order to target code at certain browsers, however it is far from ideal. This blog gives a good overview of why it is not a good idea. It also give an overview of the alternative – feature detection

For a much more detailed blog on feature detection see:


Automating the cost calculator

I’m going to share a short example of how I automated the testing of recent piece of work and share a few tips on how to use Minion.

When I picked up this piece of work I was tasked with refactoring and updating a large area of code related to the UI, presentation and data access of a calculator widget. The internals were already heavily covered by unit tests – so I was happy I would not break any of the calculation logic, but I did need to be careful that I didn’t feed the wrong data into these various modules and that I hadn’t crossed any wires so to speak.

Of course there are a number of ways of doing this – code based integration tests are fantastic, but for this example I thought I’d write a quick browser based test. The idea is that if I capture inputs and outputs from a UI perspective before I make any changes to the code I can quick validate that I haven’t broken anything.

Below is a test script, executed by Minion to test the calculator.

I didn’t have any way to distinguish textboxes (no unique classes, and dynamically generated Id’s by asp.NET). To work round this Minion can gather a group of elements:

i.e .calculationForm input returns an array of 2 inputs.

I can specify an index to determine which input from the group I want Minion to use as its context element – easy.

Another tip is that you could also use jQuery to achieve the same effect. The code:

jQuery(‘.calculationForm input:eq(0)’)

Will do exactly the same thing.

MINION /hand-dryers/airblade-db/airblade-db.aspx

INPUT .calculationForm input 1 “1”
INPUT .calculationForm input 2 “1”
SELECT .calculationForm select @100
CLICK .calculationForm .goldBtn

VERIFY .savingValue 1 “£716.84″
OR VERIFY jQuery(‘.savingValue:eq(0)’) “£716.84″
VERIFY .savingValue 2 “£706.84″
VERIFY .savingValue 3 “£701.27″

IIS log parser

Typically information about every request that hits IIS will be written to the iis logs. For busy sites the amount of information being logged will mean these log files aren’t very readable by simply scanning the files. There is an MS tool for parsing these files:
It allows you to concoct sql like queries which then can run over a set of log files.

To run logparser, fire up a command prompt and run:

Then some examples of the specific sql files:
Number of hits per hour:

Which pages have been requested in the last N days

How many times has a specific page been requested by specific IP’s?
Note, you can filter out by ip if needs be

1 2 3 4