Skip to content

Instantly share code, notes, and snippets.

@ralfw
ralfw / 01main.cs
Created January 1, 2012 15:59
Einfaches FlowDesign Beispiel - Summe und MwSt
using System;
namespace Summation
{
class MainClass
{
public static void Main (string[] args)
{
var frontend = new Frontend();
var rechenwerk = new Rechenwerk();
@ralfw
ralfw / test_wrapper.cs
Created November 5, 2012 07:50
Kata Word Wrap mit expliziten Aspekten
using System;
using System.Dynamic;
using NUnit.Framework;
namespace KataWordWrap
{
[TestFixture()]
public class test_Wrapper
{
[TestCase("word", 4, Result="word")]
@ralfw
ralfw / ParseObjects.cs
Last active December 11, 2015 10:48
Class to store objects using the parse.com REST API.
// Be sure to reference System.Web and System.Web.Extensions in your C# project
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Web;
using System.Web.Script.Serialization;
namespace parse.com
{
@ralfw
ralfw / ParseFiles.cs
Created January 22, 2013 07:49
Class to upload and delete files using the parse.com REST API.
// Be sure to reference System.Web and System.Web.Extensions in your C# project
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Web.Script.Serialization;
namespace parse.com
{
public class ParseFiles
@ralfw
ralfw / gist:5486673
Created April 30, 2013 05:03
PoMO mit zwei Pfaden durch den Code
Seite Erste_Seite_laden() {
Seite seite;
var dateiname = Dateiname_von_Kommandozeile_holen();
Zeilen_lesen(dateiname,
zeilen => {
seite = new Seite {
Überschrift = Überschrift_extrahieren(alleDatenzeilen),
Datenzeilen = Zeilen_der_ersten_Seite_selektieren(alleDatenzeilen)
};
@ralfw
ralfw / blackbox.js
Created July 6, 2013 22:23
Tic Tac Toe mit JavaScript und Eventstore Inspiriert durch Mike Bilds Vorlage: https://gist.github.com/MikeBild/5926056
var BlackBox = function() {
var self = this;
self._events = [];
self.Record = function(event) {
self._events.push(event);
self.Recorded(event);
};
@ralfw
ralfw / pipelineOf.cs
Last active January 5, 2021 22:01
Pipes and filters à la Steve Bate - but with a twist :-) Not just classes are filters, but also objects and functions.
public class PipelineOf<T> : IFilterOf<T>
{
public class Result
{
public static Result Success(T value)
{
return new Result {IsSuccess = true, Value = value};
}
public static Result Failure(Exception exception)
@ralfw
ralfw / pipeline.cs
Created September 3, 2013 10:38
Pipes and filters à la Steve Bate - but with another twist. This time the message flowing through the pipe can change its type.
public class Pipeline
{
public interface IFilter<in TIN,out TOUT>
{
TOUT Process(TIN message);
}
private readonly IList<Func<object,object>> _stages = new List<Func<object,object>>();
@ralfw
ralfw / assemblyLineFor.cs
Last active December 22, 2015 05:29
Pipes and filters à la Steve Bate. No, wait, it´s not pipes and filters anymore. It´s an assembly line processing work pieces. And you can assemble the assembly line using the + operator.
public class AssemblyLineFor<T>
{
public interface IFilter
{
T Process(T message);
}
private readonly IList<Func<T, T>> _stages = new List<Func<T, T>>();
@ralfw
ralfw / romanconverter.cs
Last active August 29, 2015 14:02
Informed TDD - JUGHH 17.6.2014
/*
* Ralf Westphal, Hamburg
* info@ralfw.de, @ralfw, http://blog.ralfw.de
*/
using System;
using System.Linq;
using System.Collections.Generic;
namespace kata
{