Skip to content

Instantly share code, notes, and snippets.

@gkinsman
gkinsman / new_gist_file
Created February 21, 2017 06:24
UnhandledExceptionLogger
public static class UnhandledExceptionLogger
{
public static void Install()
{
var log = Log.ForContext(typeof(UnhandledExceptionLogger));
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
{
log.Fatal(e.ExceptionObject as Exception, "Unhandled exception caught at AppDomain boundary (terminating: {IsTerminating})", e.IsTerminating);
};
var busControl = Bus.Factory.CreateUsingRabbitMq(cfg => {
cfg.UseLog4Net();
cfg.UseApplicationInsights(_telemetryClient);
cfg.PrefetchCount = (ushort)_settings.MessageBusPrefetchCount; // 10 in our config
host = cfg.Host("rabbitcluster", config.VHost, h => {
h.UseCluster(c => prioritisedHostNames.ForEach(c.Node));
h.Username(_shardConfigProvider.Username);
h.Password(_shardConfigProvider.Password);
h.PublisherConfirmation = _publisherConfirms;
@gkinsman
gkinsman / IResult.cs
Created September 18, 2019 06:10
C# Result type
public interface IResult
{
bool WasSuccessful { get; }
string[] Errors { get; }
bool WasFailure { get; }
}
public class Result : IResult
{
public class ExceptionFingerprintEnricher : ILogEventEnricher
{
private const string ThumbprintKey = "ExceptionThumbprint";
private const string TypeKey = "ExceptionType";
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
if (logEvent.Exception == null) return;
var fingerprint = ExceptionFingerPrinter.GetFingerprint(logEvent.Exception);
@gkinsman
gkinsman / profile.ps1
Created February 21, 2020 19:21
rider from command line
function Start-Rider([string] $sln) {
& "C:\Users\george.kinsman\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\JetBrains Toolbox\Rider.lnk" $sln
}
Set-Alias -Name rider -Value Start-Rider
{
"a": {
"b": {
"c": {
"d": 43
}
}
},
"f": "hello"
}