BOF Unicode

A coworker of mine was having trouble getting a batch file to run as part of the Azure startup process. He needed to do some kind of config to the environment.

The batch file worked if he rdp’d to the machine but failed on deploy.

When we opened the file in notepad it started with three unexpected characters.

This was the BOF unicode header, a piece of nonsense that identifies the file as being unicode, but breaks a lot of older technology that tries to use it.

Hint to microsoft: either implement transparent bypass of BOF header everywhere or stop using it.

It was an easy to save the file as UTF without the BOH header.

Lucine.Net

Tutorial:

http://www.d80.co.uk/post/2011/03/29/LuceneNet-Tutorial.aspx

The basic library can be installed via NuGet

There is a simple https://github.com/ajorkowski/AzureDataCacheDirectory that should just work.

This uses the Azure Cache service to store the Lucene Indexes.

I am planning to test this on the local emulated cache to see if it works.

This is a minor update to the supplied sample (Lucene has fixed the naming conventions to confirm to C# norms):

using Lucene.Net.Analysis;
using System.IO;

using Directory = Lucene.Net.Store.Directory;
using Version = Lucene.Net.Util.Version;
using Lucene.Net.Index;
using Lucene.Net.Search;
using Lucene.Net.QueryParsers;

var fordFiesta = new Document();
fordFiesta.Add(new Field(“Id”, “1”, Field.Store.YES, Field.Index.NOT_ANALYZED));
fordFiesta.Add(new Field(“Make”, “Ford”, Field.Store.YES, Field.Index.ANALYZED));
fordFiesta.Add(new Field(“Model”, “Fiesta”, Field.Store.YES, Field.Index.ANALYZED));

var fordFocus = new Document();
fordFocus.Add(new Field(“Id”, “2”, Field.Store.YES, Field.Index.NOT_ANALYZED));
fordFocus.Add(new Field(“Make”, “Ford”, Field.Store.YES, Field.Index.ANALYZED));
fordFocus.Add(new Field(“Model”, “Focus”, Field.Store.YES, Field.Index.ANALYZED));

var vauxhallAstra = new Document();
vauxhallAstra.Add(new Field(“Id”, “3”, Field.Store.YES, Field.Index.NOT_ANALYZED));
vauxhallAstra.Add(new Field(“Make”, “Vauxhall”, Field.Store.YES, Field.Index.ANALYZED));
vauxhallAstra.Add(new Field(“Model”, “Astra”, Field.Store.YES, Field.Index.ANALYZED));

using (RAMDirectory directory = new RAMDirectory())
{
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);

var writer = new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
writer.AddDocument(fordFiesta);
writer.AddDocument(fordFocus);
writer.AddDocument(vauxhallAstra);

writer.Optimize();
writer.Close();

IndexReader indexReader = IndexReader.Open(directory, true);
using (Searcher indexSearch = new IndexSearcher(indexReader))
{
var queryParser = new QueryParser(Version.LUCENE_30, “Make”, analyzer);
var query = queryParser.Parse(“Ford”);

Console.WriteLine(“Searching for: ” + query.ToString());
TopDocs resultDocs = indexSearch.Search(query, indexReader.MaxDoc);

Console.WriteLine(“Results Found: ” + resultDocs.TotalHits);

var hits = resultDocs.ScoreDocs;
foreach (var hit in hits)
{
var documentFromSearcher = indexSearch.Doc(hit.Doc);
Console.WriteLine(documentFromSearcher.Get(“Make”) + ” ” + documentFromSearcher.Get(“Model”));
}

}
}

I have a sample app that uses the Azure Cache As A Service version:

https://github.com/chriseyre2000/Study/tree/master/azure/Lucene/

You need to supply your own cache service id and authentication string.

ITunes on Windows – Epic Design Failures

Apple are always pointed to as a company that is good at UI design.

However in reality things are somewhat different.

There are the mildly annoying problems such as the control with focus having such a subtle change of colour on the border (and no cursor) that data entry becomes much harder.

The password entry for “apple id” registration is a joke – you get the following error without having been told the password requirement:

“The password you entered is not valid. Check the password requirements and try again.”

Eventually by trial and error I was able to deduce the rules (Capital Letter + Number + Non Alpha Numeric).

Whrn you eventually get the email to confirm a request for an apple id (my wife took 5 attempts to get this to happen) it asks you to enter your apple id.

At no point are you told that this is the email address that you had supplied.

Adding a credit card fails unless you have clicked the right credit card brand image (you can infer the card type from the number).

If you have plugged your ipod in before installing itunes then you don’t get to see the ipod itself until you remove and reconnect the device.

When you change the location of where you want to store your music it will conveniently forget these changes and put them back where it wants to.

The iTunes application keeps throwing up the web browser which is confusing as hell.

Why can’t you simply treat the device as an external usb drive and allow music to be added there?

The iPod Shuffle itself is a great piece of kit.

Minimal Azure Cache in Emulator

The Azure Powershell scripts are great for small experiments:

First create a new directory and open a powershell prompt as administrator:

New-AzureServiceProject -ServiceName “CachingDemo”
New-AzureServiceProject -ServiceName “CachingDemo”
cd CachingDemo
Start-AzureEmulator -Launch

This will give you a minimal cache role running in the emulator.

This is only officially visible to other services running in the emulator.

However with the right sdk versions and config it should be available locally.

The following works for a local machine:

    dataCacheClient name=”default” useLegacyProtocol=”false”
hosts
host name=”127.255.0.0″ cachePort=”20004″
hosts
securityProperties mode=”None” protectionLevel=”None”
dataCacheClient

Assuming that the sdk version matches the caching library.

Logging Analytics

On my current project I have found an urgent need to improve the general instrumentation.

This started by adding a few useful trace statements that will show how long certain key operations will take.

Typically this will involve reading some logs (or in fact querying the WADLogsTable).

I have just realised that without some useful log reporting queries then I am just setting myself up for a lot of manual work.

Indeed on a large scale system there is no point in adding logging unless you have something that can read and display these in a useful form.

I am wonding about the analysis side. I have seen lots of articles about writing logging but very little on reading logging.

I am thinking of having a set of classes that act like reports to perform prebaked queries on WADLogs. These could expose this data as restful web services allowing other applications (powershell scripts, excel, reporting services…) to display the data.

Here is an article on logging analytics.