Skip to content

Instantly share code, notes, and snippets.

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>()
markrendle /
Last active Nov 28, 2020
Why I was previously not a fan of Apache Kafka

Update, September 2016

OK, you can pretty much ignore what I wrote below this update, because it doesn't really apply anymore.

I wrote this over a year ago, and at the time I had spent a couple of weeks trying to get Kafka 0.8 working with .NET and then Node.js with much frustration and very little success. I was rather angry. It keeps getting linked, though, and just popped up on Hacker News, so here's sort of an update, although I haven't used Kafka at all this year so I don't really have any new information.

In the end, we managed to get things working with a Node.js client, although we continued to have problems, both with our code and with managing a Kafka/Zookeeper cluster generally. What made it worse was that I did not then, and do not now, believe that Kafka was the correct solution for that particular problem at that particular company. What they were trying to achieve could have been done more simply with any number of other messaging systems, with a subscriber reading messages off and writing

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,

Keybase proof

I hereby claim:

  • I am markrendle on github.
  • I am rendle ( on keybase.
  • I have a public key ASDQ0O3lbZRJvt1ZVJW5eOADbKKANZ3TNvT8kAoZq7Ox7go

To claim this, I am signing this object:

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 / Gulpfile.js
Created Jun 25, 2015
Gulp to copy js plus minified version
View Gulpfile.js
var gulp = require('gulp'),
hint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename');
gulp.task('lint', function() {
return gulp.src(['Scripts/**/*.js'])
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 / 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 / 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.
public interface IXmlSerializable