Skip to content

Instantly share code, notes, and snippets.


Andrew Stanton-Nurse anurse

View GitHub Profile
anurse / AzureFunctionsLoggingProvider.cs
Last active Aug 14, 2018
Azure Functions Logging Provider
View AzureFunctionsLoggingProvider.cs
public static class AzureFunctionsLoggerBuilderExtensions
public static void AddAzureFunctions(this ILoggingBuilder logging, TraceWriter writer)
logging.Services.AddSingleton<ILoggerProvider, AzureFunctionsLoggerProvider>();
public class AzureFunctionsLoggerProvider : ILoggerProvider
anurse / CommandLineException.cs
Last active Aug 14, 2020
My Command Line Template
View CommandLineException.cs
using System;
using System.Runtime.Serialization;
namespace MyTool
internal class CommandLineException : Exception
public CommandLineException()
anurse /
Last active Oct 4, 2020
EventSource/EventCounters patterns
anurse / SampleMetric.cs
Last active Sep 19, 2017
Sample IMetric implementation for aggregated data.
View SampleMetric.cs
using Microsoft.Extensions.Logging;
namespace MetricsSample
internal class SampleMetric : IMetric
private object _lock = new object();
private int _count;
private double _sum;
View DynamicHubSketch.cs
// Treat Client Proxies kinda like Formatters; Hub<T> just tries to get an IClientProxyFactory<T> from DI and invokes it.
// We provide one for `dynamic` and another that can be registered as an open-generic and generated code at runtime.
// Users can provide custom implementations for anything.
public interface IClientProxy {
Task InvokeAsync(string method, params object[] args);
public interface IClientProxyFactory<T> {
T CreateProxy(IClientProxy proxy); // <-- may need some caching logic
anurse / ReadAtLeastAsync.cs
Created Sep 27, 2016
ReadAtLeastAsync Helper
View ReadAtLeastAsync.cs
using System.Threading;
using System.Threading.Tasks;
using Channels;
namespace Microsoft.Extensions.WebSockets.Internal
public static class ChannelExtensions
public static ValueTask<ReadableBuffer> ReadAtLeastAsync(this IReadableChannel input, int minimumRequiredBytes) => ReadAtLeastAsync(input, minimumRequiredBytes, CancellationToken.None);
anurse / .gitignore
Created Aug 31, 2016
WebSocket Repro Client
View .gitignore
anurse / WebsocketDecoder.ts
Last active Dec 4, 2017
WebSocket Decoder Script
View WebsocketDecoder.ts
document.writeln('<input style="width: 600px" id="hexcode" type="text" placeholder="hex values" />');
document.writeln('<button onclick="decode()">Decode</button>');
document.writeln('<div id="result" />');
var opcodes = [
View vimrc
" Update MYVIMRC
let $MYVIMRC="~/.dotfiles/vim.symlink/vimrc"
let $MYCOLORS="~/.dotfiles/vim.symlink/colorscheme.vim"
set ff=unix
" Make windows accept unixy stuff
if has('win32') || has('win64')
set runtimepath=~/.vim,$VIM/vimfiles,$VIM,$VIM/vimfiles/after,~/.vim/after
set dir=$TEMP

MSBuild Targets and Props in NuGet 3

NuGet 2.x supports the inclusion of .targets and .props files in NuGet packages. These files will be added as Imports in the csproj MSBuild file when the package is installed. For example, consider a package with the following files: