Skip to content

Instantly share code, notes, and snippets.

{
"a": {
"b": {
"c": {
"d": 43
}
}
},
"f": "hello"
}
@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
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 / 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
{
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 / 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);
};
import {customAttribute} from 'aurelia-framework';
import {autoinject} from 'aurelia-framework';
import * as $ from "jquery";
@autoinject
@customAttribute('found')
export class FoundationCustomAttribute {
constructor(private element: Element) {
}
@gkinsman
gkinsman / EnumerableOfStringParser
Created March 10, 2016 06:26
EnumerableOfStringParser
public class EnumerableOfStringParser : IValueParser
{
private readonly string _separator;
public EnumerableOfStringParser(string separator = null)
{
_separator = separator;
}
public bool CanParse(Type settingValueType)
@gkinsman
gkinsman / Program
Last active August 29, 2015 14:27
Solution to Liam's Challenge 22/08/2015
using System;
namespace SemitoneCalculator
{
public static class ToneExtensions
{
public static Tone Up(this Tone tone)
{
return tone.Name == ToneName.B
? new Tone(ToneName.C, tone.Octave + 1)
@gkinsman
gkinsman / gist:6602731
Created September 18, 2013 00:23
Slight modification of http://tomasp.net/blog/2013/tuples-in-csharp/index.html to group by not only parameter type, but name as well
(*@
Note that this is directly from his blog post on https://github.com/tpetricek/TomaspNet.Website/blob/master/source/blog/2013/tuples-in-csharp.fsx
The only minor addition is on L162:
yield [ for p in meth.GetParameters() -> p.ParameterType.ToString() + ": " + p.Name ] }
where we added the name of the parameter in the key for the grouping. Results are interesting!
Also added a Dump on L180 for LinqPad :)
*)