Skip to content

Instantly share code, notes, and snippets.

@markrendle
markrendle / Squares.cs
Created March 7, 2018 10:40
Lines of code
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 March 2, 2018 18:48
SXmlSerializable shape for fixing Jon Skeet's problems in C# 9.0
/*
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
@markrendle
markrendle / PS1.sh
Created September 4, 2017 20:32
Git Prompt
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 / 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 / mylib.d.ts
Last active June 25, 2017 09:18
Add CustomEvent to lib.d.ts Window interface and global window object
interface CustomEventParams {
bubbles?: boolean;
cancelable?: boolean;
detail?: any;
}
// Extend the lib.d.ts CustomEvent interface with the proper constructor
interface CustomEvent {
new(event: string, params?: CustomEventParams);
}
@markrendle
markrendle / CorsModule.cs
Last active May 28, 2017 07:38
Very basic CORS HttpModule
using System;
using System.Web;
namespace MyOtherSite
{
public class CorsModule : IHttpModule
{
public void Init(HttpApplication application)
{
application.BeginRequest += ApplicationOnBeginRequest;
@markrendle
markrendle / Git Bash.vbs
Created November 25, 2010 17:31
Modified Git Bash to use Console2
Set AppObj = CreateObject("Shell.Application")
If WScript.Arguments.Length=1 Then
AppObj.ShellExecute "C:\Console2\Console.exe", " -t ""Git Bash"" -d """ & WScript.Arguments(0) & """"
Else
AppObj.ShellExecute "C:\Console2\Console.exe", " -t ""Git Bash"""
End If
@markrendle
markrendle / bio.md
Created April 4, 2017 20:12
Mark's Bio for conferences and such

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.

@markrendle
markrendle / 0-DEBUG-constant-in-TypeScript-with-Uglify.md
Last active February 28, 2017 09:23
Compile-time constants with TypeScript and UglifyJS

DEBUG constant in TypeScript with UglifyJS

One of the requested features in TypeScript is support for the kind of compilation constants that C#, for example, provides, where you can say

#if(DEBUG)
  MessageBox.Show(...);
#endif