Skip to content

Instantly share code, notes, and snippets.

View JefClaes's full-sized avatar

Jef Claes JefClaes

View GitHub Profile
@JefClaes
JefClaes / gist:5458275
Last active December 16, 2015 15:49
I do something very similar to what @tjaskula is doing. I approve!
public class ConfirmationModule : NancyModule
{
public ConfirmationModule(IBus bus)
{
Get["confirm/done"] = p =>
{
return View["ConfirmationDone"];
};
@JefClaes
JefClaes / gist:5458289
Created April 25, 2013 08:20
Also makes for clean controller tests.
[TestClass()]
public class ConfirmationModuleTest
{
private Mock<IBus> _bus;
private Browser _browser;
[TestInitialize]
public void Setup()
{
_bus = new Mock<IBus>();
@JefClaes
JefClaes / gist:6794475
Created October 2, 2013 14:16
ES Demo snippet
using System;
using System.Collections.Generic;
namespace EventSourcing
{
public class Program
{
public static void Main(string[] args)
{
var acc = new Account();
@JefClaes
JefClaes / gist:6864840
Created October 7, 2013 09:07
Constants and comments add so much value, couldn't live without them
public class Constants
{
/// <summary>
/// String containing the value "normal"
/// </summary>
public const string NORMAL_FOLDER = "normal";
/// <summary>
/// String containing the value "backup"
/// </summary>
@JefClaes
JefClaes / gist:7428657
Created November 12, 2013 10:22
Can you guess which country this is about?
What happened here was the gradual habituation of the people, little by little, to being governed by surprise; to receiving decisions deliberated in secret; to believing that the situation was so complicated that the government had to act on information which the people could not understand, or so dangerous that, even if the people could not understand it, it could not be released because of national security.
@JefClaes
JefClaes / gist:7783803
Created December 4, 2013 07:56
Hopefully you will not lose power too often.
We are told that the flush and fsync primitives are broken on some versions of Windows and Linux. This is unfortunate. It opens SQLite up to the possibility of database corruption following a power loss in the middle of a commit. However, there is nothing that SQLite can do to test for or remedy the situation. SQLite assumes that the operating system that it is running on works as advertised. If that is not quite the case, well then hopefully you will not lose power too often.
Source: http://www.sqlite.org/atomiccommit.html
@JefClaes
JefClaes / gist:8174136
Created December 29, 2013 19:56
Failing ES projection
fromAll().when({
$init: function () {
return { };
},
$any: function(state, event) {
var eventType = event.eventType;
if (state.hasOwnProperty(eventType)) {
state[eventType] += 1;
} else {
state[eventType] = 1;
@JefClaes
JefClaes / gist:8324613
Created January 8, 2014 21:03
Top 3 fiction 2013
1. http://www.amazon.co.uk/Solitude-Thomas-Cave-Georgina-Harding/dp/0747599742/ref=sr_1_1?ie=UTF8&qid=1389214927&sr=8-1&keywords=the+solitude+of+thomas+cave
2. http://www.amazon.co.uk/Walk-Wild-Side-Nelson-Algren/dp/1841956805/ref=sr_1_1?ie=UTF8&qid=1389214888&sr=8-1&keywords=A+walk+on+the+wild+side
3. http://www.amazon.co.uk/Cities-Plain-Boder-Trilogy-Border/dp/0330511203/ref=sr_1_1?ie=UTF8&qid=1389214902&sr=8-1&keywords=cities+of+the+plain
@JefClaes
JefClaes / gist:8711243
Created January 30, 2014 15:38
Why would events be published more than once?
var Config = require('../config.js').Config;
var eventstore = require('eventstore');
var storage = require('eventstore.mongodb');
var es;
var S4 = function() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
};
@JefClaes
JefClaes / gist:8975968
Last active August 29, 2015 13:56
Domain Event flavours
// Udi style w Static Domain Events
var dispatcher = new RecordingDomainEventsDispatcher();
DomainEvents.Dispatcher = dispatcher;
var customer = new Customer(new Address());
customer.Move(new Address());
Console.WriteLine("Customer moved: " + dispatcher.RecordedDomainEvent(new CustomerMoved()));