Skip to content

Instantly share code, notes, and snippets.

@billpratt
billpratt / .NETMongoApplicationInsightsExamples.cs
Last active October 21, 2021 08:27
Examples of how to track .NET Mongodb queries in Application Insights
class Program
{
static void Main(string[] args)
{
var telemetryClient = new TelemetryClient(new TelemetryConfiguration("APP_INSIGHTS_KEY"));
var mongoConnectionString = "mongodb://localhost:27017/test";
TrackMongoByEvents(mongoConnectionString, telemetryClient);
TrackMongoManually(mongoConnectionString, telemetryClient);
using System;
using System.Collections.Generic;
using System.IO;
using GeoAPI.Geometries;
using NetTopologySuite.Features;
using NetTopologySuite.Geometries;
using ProjNet.CoordinateSystems;
using NetTopologySuite.IO;
using System.Diagnostics;
@billpratt
billpratt / FirstMostCommonCharacter
Last active August 29, 2015 14:22
Return the most common character that appears first
public static char FirstMostCommonCharacter(string text)
{
return text
.GroupBy(c => c)
.OrderByDescending(c => c.Count())
.Where(c => c.Key != ' ') // dont include white space
.Select(c => c.Key)
.FirstOrDefault();
}