Skip to content

Instantly share code, notes, and snippets.

Mark Rendle markrendle

Block or report user

Report or block markrendle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Whatever.cs
public class Whatever
{
public async Task<int> Something()
{
await Task.Delay(1).ConfigureAwait(false);
await Task.Delay(1).ConfigureAwait(true);
return 0;
}
}
@markrendle
markrendle / dockdnx.sh
Created Feb 22, 2016
Docker script to run `dnx` commands using CoreCLR
View dockdnx.sh
#! /usr/bin/env bash
WORKDIR=''
PROJECTDIR=$PWD
while [ ! -f "${PROJECTDIR}/global.json" ] ; do
WORKDIR="/$(basename $PROJECTDIR)${WORKDIR}"
PROJECTDIR=$(dirname $PROJECTDIR)
if [ $PROJECTDIR == '/' ] ; then
echo No global.json found in any parent directories. Aborting.
exit 1
@markrendle
markrendle / gulpfile.js
Created Nov 5, 2015
Pass an argument to Gulp to only run a subset of Specs
View gulpfile.js
"use strict";
const gulp = require('gulp'),
mocha = require('gulp-mocha'),
minimist = require('minimist');
const knownOptions = {
string: 'spec',
default: { spec: '*' }
};
View ClaimsPrincipalBuilder.cs
public class ClaimsPrincipalBuilder
{
public static ClaimsPrincipal FromDictionary(IDictionary<string, string> source)
{
var claims = source.Select(pair => new Claim(pair.Key, pair.Value));
var identity = new ClaimsIdentity(claims);
return new ClaimsPrincipal(identity);
}
}
View ClaimsMiddleware.cs
using System.Linq;
using Microsoft.AspNet.Builder;
namespace StealthProject.Mvc
{
public static class AuthenticationMiddleware
{
private static readonly char[] Eq = { '=' };
public static IApplicationBuilder UseHeaderClaims(this IApplicationBuilder app)
@markrendle
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'])
.pipe(hint());
});
@markrendle
markrendle / Person.cs
Created Jun 3, 2015
Backwards compatibility is hard
View Person.cs
namespace PersonApp
{
public class Person
{
public Person()
{
}
private Person(string firstName, string lastName)
@markrendle
markrendle / output.txt
Created May 28, 2015
Output from trying to build Microsoft.WindowsAzure.Storage with primary sources against DnxCore50
View output.txt
/home/mark/cloudlens/azure-storage-net/Lib/Common/RequestEventArgs.cs(59,16): error CS0246: The type or namespace name 'HttpWebRequest' could not be found (are you missing a using directive or an assembly reference?)
/home/mark/cloudlens/azure-storage-net/Lib/Common/RequestEventArgs.cs(65,16): error CS0246: The type or namespace name 'HttpWebResponse' could not be found (are you missing a using directive or an assembly reference?)
/home/mark/cloudlens/azure-storage-net/Lib/Common/RequestResult.cs(34,6): error CS0246: The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)
/home/mark/cloudlens/azure-storage-net/Lib/Common/StorageException.cs(44,6): error CS0246: The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)
/home/mark/cloudlens/azure-storage-net/Lib/Common/StorageException.cs(109,44): error CS0246: The type or namespace name 'SerializationInfo' could not be found (are
@markrendle
markrendle / explanation.md
Last active Sep 23, 2019
Why I was previously not a fan of Apache Kafka
View explanation.md

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

View WizardsAndWarriors.cs
using System;
namespace WizardsAndWarriors
{
public class Program
{
public static void Main(string[] args)
{
IPlayer player = new Wizard();
Console.WriteLine(player.Weapon.Damage);
You can’t perform that action at this time.