Skip to content

Instantly share code, notes, and snippets.

@jen20
jen20 / EventStoreConnectionExtensions.cs
Created March 4, 2013 14:52
Quick and dirty way to hook up RX to an Event Store subscription. Emphasis on "quick" and "dirty".
static class EventStoreConnectionExtensions
{
public static Task<EventStoreRxSubscription> SubscribeToAll(this EventStoreConnection connection, bool resolveLinkTos)
{
return Task<EventStoreRxSubscription>.Factory.StartNew(() => {
var subject = new Subject<ResolvedEvent>();
var subscriptionTask = connection.SubscribeToAll(resolveLinkTos, subject.OnNext, () => subject.OnError(new SubscriptionDroppedException()));
subscriptionTask.Wait();
public class GetEventStoreEventDispatcher
{
private readonly IEventBus _eventBus;
private readonly EventStoreConnection _connection;
private bool _stopRequested;
private EventStoreAllCatchUpSubscription _subscription;
private readonly IPersistGetEventStorePosition _positionRepository;
public GetEventStoreEventDispatcher(EventStoreConnection connection, IEventBus eventBus, IPersistGetEventStorePosition positionRepository)
public class SlightlyBetterButStillNotGreatDispatcher
{
private readonly IEventStoreConnection _connection;
private readonly IPersistGetEventStorePosition _positionCheckpoint;
private readonly IPublisher _next;
private readonly Action<EventStoreCatchUpSubscription> _onLiveProcessingStarted;
private EventStoreAllCatchUpSubscription _subscription;
public SlightlyBetterButStillNotGreatDispatcher(IEventStoreConnection connection, IPersistGetEventStorePosition positionCheckpoint,
@jen20
jen20 / Constructortests.cs
Created July 27, 2013 18:37
Potential syntax for constructor testing in AggregateSource
[Test]
public void ConstructorSucceeeds()
{
var id = new ConcertId(Guid.NewGuid());
new ConstructorScenario()
.When(() => Concert.New(id))
.Then(ConcertEvents.Planned(id))
.Assert();
}
@jen20
jen20 / Clean-SvnWorkingCopy.ps1
Created November 23, 2013 19:12
Powershell function to remove unversioned items from a Subversion working copy
Function Clean-SvnWorkingCopy {
Param(
[Parameter(Mandatory=$true, Position=0, HelpMessage="Path to the repository to clean")]
[string]$repositoryPath
)
Process {
Push-Location $repositoryPath
[xml]$svnChangelist = Exec { svn status --xml }
$entries = $svnChangelist.GetElementsByTagName("entry")
@jen20
jen20 / subscribers.cs
Created December 13, 2013 12:03
From Vilnius Workshop
using System;
using System.Net;
using EventStore.ClientAPI;
using EventStore.ClientAPI.Common.Log;
using EventStore.ClientAPI.SystemData;
namespace ConsoleApplication3
{
class Program
{
@jen20
jen20 / ObservableSerialPort.cs
Last active February 3, 2016 04:05
Start of a nice Observable wrapper for serial devices for a WPF app
using System;
using System.IO;
using System.IO.Ports;
using System.Reactive.Linq;
namespace ObservableSerialPort
{
public class ObservableSerialPort : IObservable<string>
{
private readonly string _portName;
@jen20
jen20 / CharacterEllipsisButtonStyle.xaml
Created January 6, 2014 18:06
WPF style which puts character ellipsis on button contents without replacing the ContentPresenter with a TextBlock and thus losing the ability to support access keys.
<Style x:Key="CharacterEllipsisTextButtonStyle" TargetType="{x:Type Button}">
<Setter Property="FocusVisualStyle">
<Setter.Value>
<Style>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="2" SnapsToDevicePixels="True" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
@jen20
jen20 / gist:8930380
Created February 11, 2014 06:57
Binding double clicking a data grid to a ReactiveCommand
Observable.FromEventPattern<MouseButtonEventHandler, MouseButtonEventArgs>
(h => JobsGrid.MouseDoubleClick += h, h => JobsGrid.MouseDoubleClick -= h)
.InvokeCommand(this, v => v.ViewModel.GoToJob);
@jen20
jen20 / gist:9463288
Created March 10, 2014 11:19
Temporary build instructions for Event Store on OS X. Not complete or tested.
Note that this will ONLY work currently (10 March 2014) with the `dev` branch of Event Store as that has commits which fix the .csproj files to use dylibs instead of shared objects. Instructions are incomplete and untested, but there will be a working, tested script forthcoming soon!
1. Build a 64 bit mono from source (I'm on 3.8, the GC is broken in everything since 3.0.12 though (and that needs patching) but I guess if you're on OS X you're not talking production here). Assuming this is going in /opt/mono
2. Clone and build V8. Should be a simple case of:
- `make dependencies`
- `make x64.release library=shared`
- Copy the dylibs to `src/EventStore/libs/`