Skip to content

Instantly share code, notes, and snippets.

@rvlieshout
rvlieshout / day11.nim
Created December 11, 2017 11:34
AoC 2017, Day 11, Nim
import sequtils
let
child_steps = toSeq(readLine(stdin).items)
var
cx, cy, furthest = 0
proc dist(): int = max(abs(cx), abs(cy))
@rvlieshout
rvlieshout / day11.cs
Created December 11, 2017 08:40
AoC 2017, Day 11
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Day11
{
class Program
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Day7
{
public class Node
{
public string Name { get; set; }
@rvlieshout
rvlieshout / gist:1069569
Created July 7, 2011 14:00
Adding the interceptor in the bootstrapper
service.AddInterceptor(new ValidateCommandInterceptor());
@rvlieshout
rvlieshout / gist:1069563
Created July 7, 2011 13:54
A validator
public class CreateNewNoteValidator : AbstractValidator<CreateNewNote>
{
public CreateNewNoteValidator()
{
RuleFor(command => command.NoteId).NotEqual(Guid.Empty);
RuleFor(cmd => cmd.Text).Length(1, 140);
}
}
@rvlieshout
rvlieshout / gist:1069510
Created July 7, 2011 13:32
A command decorated with the desired validator
[Validator(typeof (CreateNewNoteValidator))]
[MapsToAggregateRootConstructor("MyNotes.Domain.Note, MyNotes.Domain")]
public class CreateNewNote : CommandBase
{
public CreateNewNote() {}
public CreateNewNote(Guid noteId, string text)
{
NoteId = noteId;
Text = text;
@rvlieshout
rvlieshout / gist:1069393
Created July 7, 2011 12:21
Our implementation of ICommandServiceInterceptor to evaluate validationrules before the command gets executed
public class ValidateCommandInterceptor : ICommandServiceInterceptor
{
private readonly IValidatorFactory _factory;
private readonly ILog _logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public ValidateCommandInterceptor(IValidatorFactory validatorFactory = null)
{
_factory = validatorFactory ?? new AttributedValidatorFactory();
}
@rvlieshout
rvlieshout / gist:1001916
Created June 1, 2011 07:09
MappedCommandToAggregateRootMethodOrConstructor Execute adjustment?
/// <summary>
/// Executes the command.
/// </summary>
/// <param name="command">The command to execute.</param>
/// <returns>The aggregateroot of type <typeparamref name="TAggRoot"/> on which we executed the command.</returns>
void ICommandExecutor<TCommand>.Execute(TCommand command)
{
var factory = NcqrsEnvironment.Get<IUnitOfWorkFactory>();
using (var work = factory.CreateUnitOfWork(command.CommandIdentifier))
{