Skip to content

Instantly share code, notes, and snippets.

Ralf Westphal ralfw

Block or report user

Report or block ralfw

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
ralfw / classify.cs
Last active Jul 30, 2018
IOSP Example
View classify.cs
void Classify(string number, Action<int> onArabic, Action<string> onRoman) {
if (int.TryParse(number, out var arabicNumber))
* Note how all details about how classification works are hidden in the function Classify().
* It's not visible to the outside wheter an "if" is used or a table lookup or whatever.
ralfw / layered.cs
Last active Oct 21, 2018
Layered design vs stratified design
View layered.cs
using System;
using System.Linq;
namespace layered
class MainClass
public static void Main(string[] args) {
var data = new DataLayer();
var business = new BusinessLayer(data);
ralfw / 01 terrain generator.cs
Last active Feb 3, 2017
Diamond-Square Solution
View 01 terrain generator.cs
using System;
using System.Linq;
namespace terraingenBlog
public class TerrainGenerator {
public static void Interpolate(Terrain terrain, float offset, float amplitude) {
Interpolate(terrain, offset, amplitude, Random_numbers_between_minus_1_and_1());
ralfw / 01 Main.elm
Last active Aug 22, 2016
Tic Tac Toe in Elm
View 01 Main.elm
module Main exposing(main)
import Html exposing (Html, div, span, br, text, table, tr, td, button)
import Html.Attributes exposing (style)
import Html.App exposing (beginnerProgram)
import Html.Events exposing (onClick)
import Array exposing (Array)
import List
ralfw / Dockerfile
Created Aug 18, 2016
Roll your own Elm Docker container
View Dockerfile
# Build image with Node.js, Elm and Nginx
FROM debian:latest
# prepare
RUN apt-get -y update
RUN apt-get -y install apt-utils
# install curl,
RUN apt-get -y install curl
ralfw / game.cs
Last active Oct 8, 2018
IODA Architecture for Bowling Game Kata
View game.cs
public class Game {
private int[] rolls = new int[21];
private int currentRoll = 0;
public void roll(int pins) {
rolls[currentRoll++] = pins;
public int score() {
var frames = Detect_frames (rolls);
ralfw / ppoop.cs
Last active Sep 12, 2015
ppoop solution
View ppoop.cs
using System;
using System.Collections.Generic;
namespace ppoop
// source:
class MainClass
public static void Main (string[] args)
View gist:8b5e796f5012f549b170
using System;
using System.Windows.Forms;
using Akka.Actor;
namespace spike.akka
static class Program
static void Main()
ralfw / 01 program.cs
Last active Aug 29, 2015
Spellchecker 20150408
View 01 program.cs
namespace spellchecker
class MainClass
public static void Main (string[] args)
var dateipfade = InputReader.Input_Params_lesen (args);
var text = FileIO.Textdatei_lesen (dateipfade.Item1);
var lex = FileIO.Lexikon_lesen (dateipfade.Item2);
ralfw / 01main.groovy
Last active Aug 29, 2015
Kata Minesweeper - Ein Versuch mit Groovy
View 01main.groovy
import daten.*
import adapter.*
import domain.*
def (String spielfelddateiname, String mogelzetteldateiname) = CLIadapter.kommandozeilenparameter_lesen(args)
def spielfeldPM = Dateiadapter.lese_Spielfeld(spielfelddateiname)
def mogelzettelPM = berechne_Mogelzettel(spielfeldPM)
Dateiadapter.schreibe_Mogelzettel(mogelzetteldateiname, mogelzettelPM)
def berechne_Mogelzettel(String[] spielfeldPM) {
You can’t perform that action at this time.