Skip to content

Instantly share code, notes, and snippets.

@chrismoutray
chrismoutray / .NETMongoApplicationInsightsExamples.cs
Created October 21, 2021 08:27 — forked from billpratt/.NETMongoApplicationInsightsExamples.cs
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);
@chrismoutray
chrismoutray / MinimalAPIs.md
Created September 27, 2021 08:14 — forked from davidfowl/MinimalAPIs.md
Minimal APIs at a glance
@chrismoutray
chrismoutray / akka_dotNET.md
Last active March 29, 2018 21:59
Simple article on using akka .net
@chrismoutray
chrismoutray / SingletonPattern.md
Last active March 29, 2018 21:47
example Singleton implementation using Lazy object
@chrismoutray
chrismoutray / abolishSwitchStatement.md
Last active March 29, 2018 21:24
Example on using class inheritance to abolishing Switch-Case statements on a type

basic example of removing switch statement and instead using OO to have implementations that represent each type

so we don't do this!

public class Entity
{
    public string Type { get; set; }

    public int GetNewValueBasedOnType(int newValue)
    {
@chrismoutray
chrismoutray / .less
Last active October 30, 2015 10:40
less/css opacity transition examples
.wrapper {
.transition(@property: opacity, @duration: .2s, @timing: ease-in-out);
.opacity (@opacity: 1);
&.hide {
.opacity (@opacity: 0);
}
}
.wrapper {
& > * {
@chrismoutray
chrismoutray / class.cs
Last active October 29, 2015 16:01
BsonDiscriminator examples
// base class
[BsonDiscriminator(RootClass = true)]
[BsonKnownTypes(typeof(Cat), typeof(Dog))]
public abstract class Animal
{
public string id { get; set; }
public string name { get; set; }
public int age { get; set; }
}
[AllowAnonymous]
[HttpGet]
[Route("confirm-signup", Name = "ConfirmSignUpRoute")]
public async Task<IHttpActionResult> ConfirmSignUp(string userId = "", string code = "")
{
IdentityResult confirmEmailResult = await this.AppUserManager.ConfirmEmailAsync(userId, code);
if (!confirmEmailResult.Succeeded)
{
return GetErrorResult(confirmEmailResult);
@chrismoutray
chrismoutray / gist:860e1d52d1f702fd82c7
Created June 8, 2014 07:33
Uninstall all gems on Windows
Windows Powershell
-- to remove gems
gem list | %{$_.split(' ')[0]} | %{gem uninstall -Iax $_ }
-- add back important ones
gem install bundler json minitest rake rdoc
@chrismoutray
chrismoutray / list dir
Last active August 29, 2015 13:57
List files found in dir
class Program
{
static void Main(string[] args)
{
string path = args[0];
Console.WriteLine("trying path: " + path);
if (Directory.Exists(path))
Directory.GetFiles(path).ToList().ForEach(s => Console.WriteLine(s));