Skip to content

Instantly share code, notes, and snippets.

@markrendle
markrendle / ObsoleteLoggingInterceptor.cs
Last active Jun 10, 2020
gRPC Interceptor to check for an X-Obsolete header
View ObsoleteLoggingInterceptor.cs
internal class ObsoleteLoggingInterceptor : Interceptor
{
private readonly ILogger<ObsoleteLoggingInterceptor> _logger;
public ObsoleteLoggingInterceptor(ILogger<ObsoleteLoggingInterceptor> logger)
{
_logger = logger;
}
public override AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(TRequest request,
@markrendle
markrendle / Program.cs
Created Apr 14, 2020
Get server URLs in .NET Core 3.1 app
View Program.cs
public static async Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
var task = host.RunAsync();
var serverAddresses = host.Services.GetRequiredService<IServer>()
.Features
.Get<IServerAddressesFeature>();
View keybase.md

Keybase proof

I hereby claim:

  • I am markrendle on github.
  • I am rendle (https://keybase.io/rendle) on keybase.
  • I have a public key ASDQ0O3lbZRJvt1ZVJW5eOADbKKANZ3TNvT8kAoZq7Ox7go

To claim this, I am signing this object:

@markrendle
markrendle / Program.cs
Created Jul 24, 2019
IndentedTextWriter Async Fail
View Program.cs
using System.CodeDom.Compiler;
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace IndentFail
{
class Program
{
static async Task Main(string[] args)
@markrendle
markrendle / Client.cs
Last active Jun 7, 2019
.NET Core 3.0 gRPC code
View Client.cs
using Greet;
using Grpc.Core;
namespace ClientApp
{
class Program
{
static async Task Main(string[] args)
{
var channel = new Channel("localhost:50051",
@markrendle
markrendle / ChannelsQueue.cs
Last active Apr 29, 2019
Better implementation of ChannelsQueue
View ChannelsQueue.cs
public class ChannelsQueue : IJobQueue<Action>
{
private ChannelWriter<Action> _writer;
public ChannelsQueue()
{
var channel = Channel.CreateUnbounded<Action>();
var reader = channel.Reader;
_writer = channel.Writer;
View Squares.cs
public static class Squares
{
public static int Square(int i) => i * i;
public static int SumOfSquares(int i) => Enumerable.Range(1, i).Select(Square).Sum();
}
@markrendle
markrendle / IXmlSerializable.cs
Last active Mar 2, 2018
SXmlSerializable shape for fixing Jon Skeet's problems in C# 9.0
View IXmlSerializable.cs
/*
The IXmlSerializable interface assumes the mutability of the type the implements it.
Now we have readonly structs, that's not a valid assumption. Ideally, there'd be a static
method that returned a new instance of the type, but you can't have static methods on
interfaces, because reasons.
*/
[Deprecated]
public interface IXmlSerializable
View PS1.sh
export PS1='\n[\e[0;32m\u@\h\e[m \e[1;33m\w\e[m\e[0;31m$(__git_ps1 " (%s)")\e[m]\n\$ '
@markrendle
markrendle / bio.md
Created Apr 4, 2017
Mark's Bio for conferences and such
View bio.md

Mark is the founder and CTO of RendleLabs, a software development consulting company. He works with new and emerging technologies, and shares his experience with teams and organisations looking to adopt those technologies for their projects. Currently Mark specializes in .NET Core and helps teams get up to speed with the wider ecosystem opened up by this cross-platform version of .NET; things like Linux, Docker, microservice architectures and so on. Mark also contributes to various open source projects, and speaks at conferences and user groups around the world. He is a Microsoft Azure MVP and a Docker Captain. In his spare time, he enjoys gaming, watching movies, and putting off writing his (probably best-selling) book.

You can’t perform that action at this time.