Skip to content

Instantly share code, notes, and snippets.

@gregoryyoung
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
@gregoryyoung
gregoryyoung / WTF
Created Mar 15, 2011
Came out of redgate ...
View WTF
C:\Users\ack\src\AutoTestExtensions>"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com" /build Obfuscation\Aut
oTest.VS.saproj
SmartAssembly v6.0.0.513
Copyright © Red Gate Software 2005-2011
Because I wanna ask you about your girlfriend. I must know who she is, or you would've told me her name.
System.NullReferenceException : Object reference not set to an instance of an object.
@gregoryyoung
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;
View gist:7677410
namespace crap
{
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
public class PartialAppPlayground
{
private static Dispatcher<IHandlerResult> _dispatcher;
@gregoryyoung
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: http://www-users.math.umd.edu/~jkolesar/mait613/floating_point_math.pdf
You will need to use a non-exact equality... How will this change your code?
@gregoryyoung
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
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 http://www.investopedia.com/articles/trading/03/080603.asp and http://en.wikipedia.org/wiki/Order_(exchange)#Stop_orders
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) => {
//dosomething
return State.Middle;
}).
InState(State.Middle).With((state, x) => {
//do something else
Send(new NextMessage(...));
return State.Ending;
}).
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;
You can’t perform that action at this time.