Skip to content

Instantly share code, notes, and snippets.

View yreynhout's full-sized avatar
👔
ceci n'est pas une cravate

Yves Reynhout yreynhout

👔
ceci n'est pas une cravate
View GitHub Profile
@yreynhout
yreynhout / XhtmlParser.cs
Created January 12, 2015 16:19
XhtmlParser bits
//Original technique courtesy of
//- http://scott.willeke.com
//- http://blogs.pingpoet.com/overflow/archive/2005/07/20/6607.aspx
//- https://devio.wordpress.com/2007/12/05/parsing-xhtml-with-c/
//- http://sticklebackplastic.com/post/2007/06/28/How-to-use-XmlResolver-Or-reading-an-xhtml-file-in-net.aspx
public static class XhtmlParser
{
public static XmlDocument Parse(string xhtml)
{
using (var textReader = new StringReader(xhtml))
@yreynhout
yreynhout / SampleReaction.cs
Created December 17, 2014 11:22
Sample Reactol
using Reactol;
//Fictitious scenario:
//Add an entry in the feed of a subscriber each time
//someone writes a blog post on a blog he's subscribed to.
var subscriptions = new SubscriptionRepository(/* ommitted */);
var reaction = new ReactionBuilder().
When<BlogPostWritten>(message => subscriptions.
FindForBlog(message.BlogId).
using Paramol.SqlClient;
namespace Paramol.Tests.SqlClient
{
public class ParameterCountLimitedExceeded
{
public static readonly ParameterCountLimitedExceeded Instance = new ParameterCountLimitedExceeded();
private ParameterCountLimitedExceeded() { }
using Projac;
using Paramol.SqlClient;
public namespace AliensNeverOnceAbductedMe
{
public static class PortfolioProjection
{
public static readonly SqlProjectionDescriptor Descriptor =
new SqlProjectionDescriptorBuilder("portfolio-v1")
{
public static class PlaceHolderForProjections {
public static readonly PortfolioProjection = TSql.Projection().
When<PortfolioAdded>(@event =>
TSql.NonQuery(
"INSERT INTO [Portfolio] (Id, Name) VALUES (@P1, @P2)",
new { P1 = TSql.Int(@event.Id), P2 = TSql.NVarChar(@event.Name, 40) }
).
When<PortfolioRemoved>(@event =>
TSql.NonQuery(
"DELETE FROM [Portfolio] WHERE Id = @P1",
@yreynhout
yreynhout / LunchTime.fs
Created May 28, 2014 15:17
Projac meets F#
open System;
open Projac;
type PortfolioCreated = { PortfolioId : int; Name : string }
type PhotoAddToPortfolio = { PortfolioId : int; PhotoId : int }
type PhotoRemovedFromPortfolio = { PortfolioId : int; PhotoId : int }
type PortfolioArchived = { PortfolioId : int; Name : string }
let PortfolioProjection (message:Object) =
seq {
using System;
using System.Linq;
using System.Security.Policy;
using Newtonsoft.Json;
using Raven.Client;
using Raven.Client.Embedded;
namespace FiveMinuteProject
{
public class ProjectionBuilder
@yreynhout
yreynhout / MemoryProjectionBuilder.cs
Last active August 29, 2015 14:01
Parking it here
using System;
using System.Linq;
namespace FiveMinuteProject
{
public class ProjectionBuilder<TState>
{
private readonly ProjectionHandler<TState>[] _handlers;
public ProjectionBuilder()
[TestFixture]
public class AuthorizationSpecifications
{
[Test]
public void WhoAreYouGonnaCall()
{
new AuthorizationScenario().
Given(events).
When(command).
InvokedBy(subject/identity).
@yreynhout
yreynhout / ChannelZero.cs
Last active December 3, 2015 18:33
Poor man's messaging
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace ChannelZero
{
class Program
{