Mongo String Indexing part 1

misc1Overview

We have a Mongo Database and in that database we have an ‘items’ collection which has five string fields and a number of ID fields.  We’ve added 250k records to this collection and started testing the time it takes to perform various queries on these fields.  Simply adding indexes on the ID fields makes those types of queries lightning fast, however, we had a number of issues dealing with various string queries.  This is a record of our findings.

Continue reading “Mongo String Indexing part 1”

Simplify Asynchronous Calls in .NET

misc3_bgSince .Net 4.5, the async/await pattern has been a great tool to simplify asynchronous calls.  However, in WPF I frequently need to make async calls from a non-async function or event.  Often, this happens because I’m overriding a virtual function in an inherited class of a framework that I’m using and that function is synchronous.  To help with this, I created an async helper class:

Continue reading “Simplify Asynchronous Calls in .NET”

Add a Slick Angular CSV Download Link

misc2Just thought I’d share this bit of code.  It allows an angular client app to create a csv file which can be used in a downloadable link that gets created on the client, on-the-fly, which the browser sees as an attachment:

// Create a downloadable link and click it.
$scope.SubmitFileToUser = function (csvData) {
var element = angular.element(‘<a/>’);
element.attr({
href: ‘data:attachment/csv;charset=utf-8,’ + encodeURI(csvData),
target: ‘_blank’,
download: ‘export.csv’
})[0].click();
};

Update: If this doesn’t work for you, Aydin Akcasu came up with an alternative way to do it here.