Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Stanton-Nurse anurse

View GitHub Profile
@anurse
anurse / EventSourcesAndCountersOhMy.md
Last active Oct 4, 2020
EventSource/EventCounters patterns
View EventSourcesAndCountersOhMy.md
@anurse
anurse / CommandLineException.cs
Last active Aug 14, 2020
My Command Line Template
View CommandLineException.cs
using System;
using System.Runtime.Serialization;
namespace MyTool
{
[Serializable]
internal class CommandLineException : Exception
{
public CommandLineException()
{
@anurse
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(writer);
logging.Services.AddSingleton<ILoggerProvider, AzureFunctionsLoggerProvider>();
}
}
public class AzureFunctionsLoggerProvider : ILoggerProvider
@anurse
anurse / drill
Last active Feb 2, 2018
My VIM drill
View drill
VIM Drill
=========
NEVER USE Arrows or Esc!
1. Type the following:
public class Foo {
public string Property { get; set; }
public int Property { get; set; }
@anurse
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 = [
'Continuation',
'Text',
'Binary',
'RESERVED',
'RESERVED',
@anurse
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
anurse / gist:5485124
Created Apr 29, 2013
Azure Portal Full Width
View gist:5485124
#headerbar-wrapper {
width: 100%;
margin-left: 0;
left: 0;
}
#fxshell-navpane {
left: 0;
margin-left: 0;
}
#drawer {
@anurse
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
anurse / .gitignore
Created Aug 31, 2016
WebSocket Repro Client
View .gitignore
node_modules/
You can’t perform that action at this time.