Skip to content

Instantly share code, notes, and snippets.

Working from home

Sam Harwell sharwell

Working from home
View GitHub Profile
sharwell / !
Last active April 23, 2020 18:38
Windows Error Reporting
View !

Capturing heap dumps for investigating crashes

The following commands demonstrate a registry configuration that collects local heap dumps when a process crashes. Software developers can add these keys for processes they work on to help provide actionable data in the event of a crash during use.

Each command in the samples places the captured heap dumps in a folder C:\CrashDumps. The command can be modified before execution to use a different location.

🔗 Collecting User-Mode Dumps (Windows Dev Center)

View check-key.ps1
[string]$Build = $null
function Get-PublicKeyToken() {
param([string]$assembly = $null)
if ($assembly) {
$bytes = $null
sharwell / SoftLayerIdentityProvider.cs
Created August 12, 2014 19:03
SoftLayer Identity Provider Example (WIP)
View SoftLayerIdentityProvider.cs
namespace net.openstack.Providers.SoftLayer
using System;
using System.Linq;
using net.openstack.Core.Caching;
using net.openstack.Core.Domain;
using net.openstack.Core.Providers;
using net.openstack.Providers.Rackspace;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
sharwell / $
Last active April 3, 2022 14:41
C# Code Snippets
View $

C# Code Snippets

This is a collection of custom C# code snippets which I use on a regular basis.

Snippet Summary

Shortcut Name Description
bf Backing field comment Insert an XML documentation comment for the backing field for a property.
ceb Contract end contract block Emits a Contract.EndContractBlock() statement.
sharwell / Test.cs
Created April 20, 2014 18:16
Reversing an RFC 6570 URI Template
View Test.cs
namespace Testing.Rfc6570
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rackspace.Net;
public class SampleTest
sharwell / Program.cs
Created April 1, 2014 11:24
TreePatternTest in C#
View Program.cs
namespace TreePatternTest
using System;
using System.Collections.Generic;
using Antlr4.Runtime;
using Antlr4.Runtime.Tree;
using Antlr4.Runtime.Tree.Pattern;
class Program
sharwell /
Created March 8, 2014 03:00
Case insensitive input stream for ANTLR 4
* [The "BSD license"]
* Copyright (c) 2012 Terence Parr
* Copyright (c) 2012 Sam Harwell
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
sharwell / CaseInsensitiveStringStream.cs
Created February 19, 2014 05:10
Case-insensitive ANTLRStringStream for ANTLR 3
View CaseInsensitiveStringStream.cs
using Antlr.Runtime;
public class CaseInsensitiveStringStream : ANTLRStringStream
// the string used for lookahead (performance improvement by not having to call Char.ToLowerInvariant())
private readonly string _lastring;
public CaseInsensitiveStringStream(string input, string sourceName)
: base(input, sourceName)
sharwell / FunnyCalls.cs
Created January 29, 2014 18:36
The assertions in the test method all pass. Read carefully :)
View FunnyCalls.cs
public void TestCalls()
FooDerived foo = new FooDerived();
Func<int> method = foo.Bar;
Assert.AreEqual(1, method());
method = foo.FooBar();
Assert.AreEqual(1, method());
sharwell / Wrapping.cs
Created January 29, 2014 17:24
Infinite loop, or clean wrapper?
View Wrapping.cs
static class Helper
public static T WrapCall<T>(Func<T> func)
Console.WriteLine("Calling function");
return func();
class Foo