Skip to content

Instantly share code, notes, and snippets.

Greg Young gregoryyoung

Block or report user

Report or block gregoryyoung

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
gregoryyoung / gist:7677790
Created Nov 27, 2013
command handling with same dispatcher
View gist:7677790
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace crap
using System;
using System.Collections.Generic;
using System.Data;
gregoryyoung / ProbabilityKata2
Created Jun 10, 2011
Probability Kata part 2
View ProbabilityKata2
OK so now you have implemented the kata. Your tests should look something like this:
We can say that the tests define the object "in a calculus of itself". They are not state based tests, they define how the behaviours of the object interact with each other.
To see the real value of this let's introduce some change ... I hear real system's do this occasionally. Because this is a high performance system decimal math is too slow. You now need to use floats instead.
Need help on floating point math? Check out:
You will need to use a non-exact equality... How will this change your code?
gregoryyoung / ProbabilityKata
Created Jun 10, 2011
Greg Young's Probability Kata
View ProbabilityKata
Value objects are an important concept in DDD. This kata is made both to learn value objects and to learn better ways of testing.
Write a probability value object. It should contain the following methods:
Probability CombinedWith(Probability)
Probability InverseOf()
Probability Either(Probability)
if you forget your probability math:
Either:P(A) + P(B) - P(A)P(B)
CombinedWith: P(A)P(B)
View gist:a6bc2fccdbb55be9123c3f7d34d57c54
There are no "full stack developers". Its a silly buzzword. Sadly working on kernel issues, a real time networked embedded system, or implementing a TCP stack is a different world than building an advertising website in PHP on MySQL.
Even if they did exist there are so many things to know that they would not have the depth required to actually solve an issue in any.
gregoryyoung / gist:1500720
Created Dec 20, 2011
Greg's Stop Loss Kata
View gist:1500720
Greg's Stop Loss Kata
Testing is very hard when time is involved ...
A trailing stop loss is a term used in financial trading. For a very in depth explanation you can read here and
However we do not need a huge amount of background in order to do the kata as we are going to limit the problem a bit.
The general idea is that when you buy into a stock at a price say $10. You want it to automatically get sold if the stock goes below $9 (-$1). If we use the term "trailing" that means that id the price goes up to $11 then the sell point becomes $10.
View gist:e7ea27292b83f48109b6b29c78bcb6f0
new FSMDefinition<State>().CompletesWith<Completed>().
InState(State.Initial).With((state, x) => {
return State.Middle;
InState(State.Middle).With((state, x) => {
//do something else
Send(new NextMessage(...));
return State.Ending;
gregoryyoung / gist:a3e69ed58ae066b91f1b
Created Jun 24, 2015
Event Sourcing as 3 functions.
View gist:a3e69ed58ae066b91f1b
f(events) -> state
match f(state, event) -> state
f(state, command) -> events
View gist:2f8da5a4a6aa7191c4b3
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using EventStore.ClientAPI;
using EventStore.ClientAPI.Embedded;
gregoryyoung / gist:7690486
Created Nov 28, 2013
updated to support actions to funcs
View gist:7690486
namespace crap
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
public class PartialAppPlayground
View gist:938a8945803e8c3560765dd50dff057a
commit 273e4c4bca3ff94106eb4a75dfe2f8f829f052a4
Author: Greg Young <>
Date: Mon Apr 18 15:20:14 2016 +0100
add TTL to httpsend messages
commit bc2d462fadec1d7a8e00260936e70bd73185c568
Author: James Nugent <>
Date: Mon Jul 7 11:25:36 2014 +0100
You can’t perform that action at this time.