Skip to content

Instantly share code, notes, and snippets.

View Restuta's full-sized avatar
🦄
Hacking fast and slow.

Anton Vynogradenko Restuta

🦄
Hacking fast and slow.
View GitHub Profile
@Restuta
Restuta / setup-git-ex.ps1
Created April 27, 2012 20:33
Adds GitExtensions support to the git bash
$os=Get-WMIObject win32_operatingsystem
if ($os.OSArchitecture -eq "64-bit") {
$gitInstallationDir = "c:\Program Files (x86)\Git\"
}
else {
$gitInstallationDir = "c:\Program Files\Git\"
}
#adding git installation directory to PATH variable
@Restuta
Restuta / gist:2963076
Created June 21, 2012 00:12
Reveiw #1
#How it works:
#switch to p4 branch
#get changes from p4
## gets changelist number workspace is synced to
## gets list of changelists that is present on server and don't at my workspace
#commit change-by-change to p4 branch on behalf of corresponding users
#switch back the to previous branch
$Env:P4CHARSET = "utf8"
if ($args[0] -eq "-preview" -or $args[0] -eq "-p") {$preview = $TRUE }
@Restuta
Restuta / gist:3936035
Created October 23, 2012 01:03
Command to Event specification
using GoldMine.Core.CommandHandlers;
using GoldMine.Core.Commands;
using Machine.Specifications;
namespace GoldMine.Core.Tests.Integration.Contacts
{
public class when_sending_a_CreateTask_command : using_in_memory_cqrs_runtime
{
Because of = () =>
CommandBus.Send(new CreateTaskCommand());
@Restuta
Restuta / gist:4108845
Created November 19, 2012 03:54
BDD sintax example
[Feature]
public class Tool_usage
{
[Scenario]
public void Use_new_tool()
{
Tool tool = default(Tool);
"Given I created a new tool"._(() =>
{
tool = new Tool();
@Restuta
Restuta / gist:4115977
Created November 20, 2012 04:19
"New" test helper
//What do you thing about usage of "New" class as a test helper
var @event = new ContactCreatedEvent(Guid.NewGuid(), New.ContactDetails());
// ^^^^^^
public static class New
{
public static ContactDetails ContactDetails()
{
var contactDetails = new ContactDetails
@Restuta
Restuta / gist:4146304
Created November 26, 2012 02:44
Being The Worst #2 transcript

Being the worst #2 - Messaging basics

Introduction

Messaging was around for a long time Analogy about robotics

Prerequisites, plans to include code in different languages. Explanation of messaging on example of classes, calling methods and calling services comparison. In-memory vs world wide messaging. Remote objects.

@Restuta
Restuta / gist:4287404
Created December 14, 2012 18:15
## Being the worst #3 - Commanding your words

Being the worst #3 - Commanding your words

Introduction

Messaging vs RPC (rpc is blocking and messaging non-blocking not necessary btw, messaging could also be blocking).

Kerry explains previous episode, why messaging, what is serialization and why do we need it and what he did in terms of homework.

Importance of capturing real world things

Rinat explains that technology is completely irrelevant. Business processes and business models are more important. We are capturing some parts of the real world in words and in our case words are messages. Words is how we think, how we talk to each other. Message is something that describes intent. Examples from home work's domain.

@Restuta
Restuta / gist:4289538
Created December 14, 2012 23:23
Sublime Plugin that does auto-save of the current document when you stop typing. Can be used with LiveReload to remove the need to press Ctrl+S all the time.
import sublime, sublime_plugin, functools
class IdleWatcher(sublime_plugin.EventListener):
pending = 0
def handleTimeout(self, view):
self.pending = self.pending - 1
if self.pending == 0:
self.on_idle(view)
@Restuta
Restuta / gist:4726805
Last active December 12, 2015 06:08
prototype for easy and declarative definition of Events that should be present in the EventStore during testing of something
InsertEventsTo(EventStore)
.AggregateId(contactId, new
{
FakeEvent.ContactCreated(),
FakeEvent.TaskCreatedForContact(),
FakeEvent.EventLinkedToContact()
})
.AggregateId(TaskId, new
{
FakeEvent.TaskCreated()

The problem

In case when one command results in several events for the same AR those events could happen really fast, so DateTime.Utc.Now returns absolutely equal dates and two events get written with the same date to the EventStore. When they are queried later and sorted by EventDate the resulted order is unpredictable.

I faced this issue trying to replay events locally from our Dev db, there are two events

id: d85cd1d4-b0d0-4e7f-8d08-4b6e8638e61d, UserCreatedEvent, AggregateRootId: 42668cc6-da9e-44f1-ba05-105f55ebea34

id: 44b75b0c-cb43-482b-8b95-37b73ad1b0de, UserCredentialsCreatedEvent, AggregateRootId: 42668cc6-da9e-44f1-ba05-105f55ebea34

and they get returned in logically incorrect order UserCredentialsCreatedEvent first, since they have equal dates. I am not really sure how to solve this problem. Any thoughts?