Skip to content

Instantly share code, notes, and snippets.

@ThatRendle
ThatRendle / 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
@ThatRendle
ThatRendle / 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() {
@ThatRendle
ThatRendle / 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));
});
@ThatRendle
ThatRendle / CheckQueueRoutes.cs
Created August 6, 2014 14:10
Route-validating Assertion
public class CheckQueueRoutes : RouteMarchBase<QueueController>
{
[Fact]
public void MatchesDeleteMessagePath()
{
AssertRoute("api/testaccount/queue/delete/testqueue/testid?pop=testpop",
ctrl => ctrl.Delete("testaccount", "testqueue", "testid", "testpop", null));
}
}
@ThatRendle
ThatRendle / trashTheForm.js
Created July 17, 2014 14:52
Trash ASPX server-side form for SPA pages
// Requires jQuery
$(function() {
var $theForm = $("#theForm"), contents = $theForm.contents();
$theForm.after(contents);
});
module SgDirectives {
declare function marked(source: string): string;
function syncHeights(source: HTMLElement, target: HTMLElement) {
var syncHeight = () => target.style.height = source.offsetHeight + "px";
syncHeight();
source.addEventListener("mouseup", syncHeight);
}
function link(scope: ng.IScope, jelem: ng.IAugmentedJQuery) {
@ThatRendle
ThatRendle / command.ts
Created June 12, 2014 15:20
ICommand-ish pattern for AngularJS
module Zudio.System {
var trueFunc = ()=> true;
export class Command {
public cssClass: string;
public canExecute: () => boolean;
public show: () => boolean;
constructor(cssClass: string, public text: string, public execute: Function, canExecute?: () => boolean, show?: () => boolean) {
this.cssClass = "icon-" + cssClass;
this.canExecute = canExecute || trueFunc;
this.show = show || trueFunc;
@ThatRendle
ThatRendle / teaser.cs
Created June 4, 2014 14:21
Simple.Data v2 teaser
class Tease
{
private readonly dynamic _db = Database.Open();
public async void DoSomeStuff()
{
// Async by default
Customer customer = await _db.Customers.Get(42).WithOrders();
// Batch operations
@ThatRendle
ThatRendle / 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);
}
@ThatRendle
ThatRendle / abstract.md
Created May 6, 2014 10:21
AngularJS & TypeScript talk abstract

AngularJS is Google's answer to client-side JavaScript MVC application development.

TypeScript is Microsoft's answer to working large, complex JavaScript code-bases. It adds static typing and supports features from next-generation JavaScript, such as classes and modules.

Put them together and you get something a bit like WPF-style MVVM, but better. This talk will introduce AngularJS and TypeScript, and show how to combine them effectively to build real browser-based applications.