Skip to content

Instantly share code, notes, and snippets.

View gertjvr's full-sized avatar

Gert Jansen van Rensburg gertjvr

View GitHub Profile
@gertjvr
gertjvr / SerilogLoggerServicesExtensions.cs
Created July 14, 2017 12:31
serilog-extensions-logging for aspnet core 2.0 preview 2
/// <summary>
/// Extends <see cref="IServiceCollection"/> with Serilog configuration methods.
/// </summary>
public static class SerilogLoggerServicesExtensions
{
/// <summary>
/// Add Serilog to the logging pipeline.
/// </summary>
/// <param name="services">The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> to add services to.</param>
/// <param name="logger">The Serilog logger; if not supplied, the static <see cref="Serilog.Log"/> will be used.</param>
@gertjvr
gertjvr / 0_reuse_code.js
Created March 14, 2017 12:03
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@gertjvr
gertjvr / macOS-yarn.lock
Created January 17, 2017 10:30
comparing yarn.lock generated from same repo on different operating systems (windows vs macOS)
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
accepts@~1.3.3:
version "1.3.3"
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.3.tgz#c3ca7434938648c3e0d9c1e328dd68b622c284ca"
dependencies:
mime-types "~2.1.11"
negotiator "0.6.1"
@gertjvr
gertjvr / CorrelationExample.cs
Last active October 14, 2022 14:28
MT3 + Serilog CorrelationId Enricher.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Threading.Tasks;
using MassTransit;
using MassTransit.Configurators;
using MassTransit.PipeBuilders;
using MassTransit.PipeConfigurators;
using MassTransit.Pipeline;
@gertjvr
gertjvr / Autofac.SignalR.md
Last active August 4, 2023 06:56
Autofac.SignalR hub scoped dependencies per instance.

SignalR generates a hub for each method invoke ie onConnected, onDisconnect or any other methods on the hub. Autofac.SignalR all hub dependencies are resolved from the root container making them singletons.

I did find another solutions https://github.com/lethek/SignalR.Extras.Autofac but this required inheriting from a special lifetimehub, retro fitting this into an large existing solution would take a lot of work an re-testing.

The solutions below allows you to scope all dependencies per hub instance.

  • Install-Package Autofac.SignalR
  • Install-Package Castle.Core

Keybase proof

I hereby claim:

  • I am gertjvr on github.
  • I am gertjvr (https://keybase.io/gertjvr) on keybase.
  • I have a public key whose fingerprint is A0CD F749 4489 EA44 44BC 65BB 077F BBDA 6174 2A01

To claim this, I am signing this object:

@gertjvr
gertjvr / PerMinuteInExcessOf.cs
Created December 10, 2015 04:54 — forked from nblumhardt/PerMinuteInExcessOf.cs
Proof of concept rate limiting filter for Serilog
using System;
using Serilog;
using Serilog.Configuration;
namespace ConsoleApplication8
{
static class Program
{
static void Main()
{
@gertjvr
gertjvr / Landlord.cs
Created October 9, 2015 00:54 — forked from sheastrickland/Landlord.cs
Landlord: The Com Destroyer. A simple utility class to wrap those nasty little devils.
using System;
using System.Runtime.InteropServices;
namespace Things
{
public static class LandLordExtensions
{
public static LandLord<TWrapped> AsDisposable<TWrapped>(this TWrapped tenant)
{
return new LandLord<TWrapped>(tenant);