Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Sam Harwell sharwell

🏠
Working from home
View GitHub Profile
@sharwell
sharwell / !ErrorReporting.md
Last active Apr 23, 2020
Windows Error Reporting
View !ErrorReporting.md

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
param(
[string]$Assembly,
[string]$ExpectedKey,
[string]$Build = $null
)
function Get-PublicKeyToken() {
param([string]$assembly = $null)
if ($assembly) {
$bytes = $null
@sharwell
sharwell / SoftLayerIdentityProvider.cs
Created Aug 12, 2014
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
sharwell / $CodeSnippets.md
Last active Sep 3, 2021
C# Code Snippets
View $CodeSnippets.md

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
sharwell / Test.cs
Created Apr 20, 2014
Reversing an RFC 6570 URI Template
View Test.cs
namespace Testing.Rfc6570
{
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rackspace.Net;
[TestClass]
public class SampleTest
{
[TestMethod]
@sharwell
sharwell / Program.cs
Created Apr 1, 2014
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
sharwell / CaseInsensitiveInputStream.java
Created Mar 8, 2014
Case insensitive input stream for ANTLR 4
View CaseInsensitiveInputStream.java
/*
* [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
sharwell / CaseInsensitiveStringStream.cs
Created Feb 19, 2014
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
sharwell / FunnyCalls.cs
Created Jan 29, 2014
The assertions in the test method all pass. Read carefully :)
View FunnyCalls.cs
[TestMethod]
public void TestCalls()
{
FooDerived foo = new FooDerived();
Func<int> method = foo.Bar;
Assert.AreEqual(1, method());
method = foo.FooBar();
Assert.AreEqual(1, method());
@sharwell
sharwell / Wrapping.cs
Created Jan 29, 2014
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