Skip to content

Instantly share code, notes, and snippets.

Andrew Stanton-Nurse anurse

View GitHub Profile
@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 / Program.cs
Created Aug 11, 2018
Easy way to debug command-line apps
View Program.cs
private static int Main(string[] args)
{
#if DEBUG
if (args.Any(a => a == "--debug"))
{
args = args.Where(a => a != "--debug").ToArray();
Console.WriteLine($"Ready for debugger to attach. Process ID: {Process.GetCurrentProcess().Id}.");
Console.WriteLine("Press ENTER to continue.");
Console.ReadLine();
}
@anurse
anurse / EventSourcesAndCountersOhMy.md
Last active Sep 27, 2018
EventSource/EventCounters patterns
View EventSourcesAndCountersOhMy.md
@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 / 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/
@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',
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
View nuget3-and-msbuild.md

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:

/
    build/
        net40/
            MyPackage.props
            MyPackage.targets
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.