Skip to content

Instantly share code, notes, and snippets.

@markrendle
markrendle / Gulpfile.js
Created June 25, 2015 15:59
Gulp to copy js plus minified version
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 June 3, 2015 20:22
Backwards compatibility is hard
namespace PersonApp
{
public class Person
{
public Person()
{
}
private Person(string firstName, string lastName)
@markrendle
markrendle / output.txt
Created May 28, 2015 14:53
Output from trying to build Microsoft.WindowsAzure.Storage with primary sources against DnxCore50
/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 July 3, 2022 07:56
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

using System;
namespace WizardsAndWarriors
{
public class Program
{
public static void Main(string[] args)
{
IPlayer player = new Wizard();
Console.WriteLine(player.Weapon.Damage);
@markrendle
markrendle / TaskFfs.cs
Created March 31, 2015 12:57
async/await convenience method
namespace System.Threading.Tasks
{
public static class TaskFfs
{
public static ConfiguredTaskAwaitable FFS(this Task task)
{
return task.ConfigureAwait(false);
}
}
}
@markrendle
markrendle / MITEA.license
Created March 30, 2015 10:53
The "MIT Except Apple" License
The MIT-except-Apple License (MIT-EA)
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person (except
anybody associated with Apple Inc.) obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the
Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@markrendle
markrendle / README.md
Last active August 5, 2017 13:35
Vagrantfile to run Kafka in boot2docker

Kafka in Docker in Vagrant

I'm using this Vagrantfile to run Kafka on a Windows 8.1 laptop for development purposes.

It runs the ultra-lightweight boot2docker Linux, then uses Vagrant's Docker provisioning support to spin up ZooKeeper and Kafka.

The fun bits to work out were:

  • You need to forward the ports on both Vagrant (lines 13 & 14) and Docker (the -p flag), so you can access the instance from Windows using localhost:9092
@markrendle
markrendle / Gulpfile.js
Last active August 29, 2015 14:11
Gulpfile December
/**
* Created by Mark on 15/12/2014.
*/
/* global require */
var gulp = require('gulp'),
typescript = require('gulp-tsc'),
html2js = require('gulp-ng-html2js'),
concat = require('gulp-concat');
gulp.task("typescript", function() {
@markrendle
markrendle / Startup.cs
Created September 11, 2014 11:47
This cannot be right
services.AddMvc()
.SetupOptions<MvcOptions>(options =>
{
var currentJson = options.OutputFormatters.FirstOrDefault(f => f.Instance is JsonOutputFormatter);
if (currentJson != null) options.OutputFormatters.Remove(currentJson);
options.OutputFormatters.Add(new JsonOutputFormatter(new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }, false));
});