Skip to content

Instantly share code, notes, and snippets.

View sharwell's full-sized avatar
🏠
Working from home

Sam Harwell sharwell

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

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)

param(
[string]$Assembly,
[string]$ExpectedKey,
[string]$Build = $null
)
function Get-PublicKeyToken() {
param([string]$assembly = $null)
if ($assembly) {
$bytes = $null
@sharwell
sharwell / SoftLayerIdentityProvider.cs
Created August 12, 2014 19:03
SoftLayer Identity Provider Example (WIP)
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 April 3, 2022 14:41
C# Code Snippets

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 April 20, 2014 18:16
Reversing an RFC 6570 URI Template
namespace Testing.Rfc6570
{
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rackspace.Net;
[TestClass]
public class SampleTest
{
[TestMethod]
@sharwell
sharwell / Program.cs
Created April 1, 2014 11:24
TreePatternTest in C#
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 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
sharwell / CaseInsensitiveStringStream.cs
Created February 19, 2014 05:10
Case-insensitive ANTLRStringStream for ANTLR 3
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 January 29, 2014 18:36
The assertions in the test method all pass. Read carefully :)
[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 January 29, 2014 17:24
Infinite loop, or clean wrapper?
static class Helper
{
public static T WrapCall<T>(Func<T> func)
{
Console.WriteLine("Calling function");
return func();
}
}
class Foo