Skip to content

Instantly share code, notes, and snippets.

View kolesnick's full-sized avatar
⌨️
Contributing Schrödingerly

Anatoliy 'TLK' Kolesnick kolesnick

⌨️
Contributing Schrödingerly
View GitHub Profile
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using NUnit.Framework;
using static Microsoft.CodeAnalysis.CSharp.SyntaxKind;
namespace Tests
{
public static IEnumerable<TNode> UnfoldTree<TNode>(this TNode root, Func<TNode, IEnumerable<TNode>> getChildren)
{
var queue = new Queue<TNode>(new [] { root });
while (queue.Count > 0)
{
var node = queue.Dequeue();
yield return node;
foreach (var child in getChildren(node))
fromAll()
.when({
$init: function () {
return { count: 0 }; // initial state
},
$any: function (state, event) {
if (event.metadata.EventSourceId.indexOf("$") !== 0) {
state.count += 1;
}
return state;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using EventStore.ClientAPI;
using EventStore.ClientAPI.SystemData;
using Nito.AsyncEx;
using (var readTimeout = new CancellationTokenSource())
{
readTimeout.CancelAfter(this.defaultTimeout); // not used so far
currentSlice = AsyncContext.Run(
() => connection.ReadStreamEventsForwardAsync(EventsPrefix + id.FormatGuid(), nextSliceStart, batchSize, false));
}
@kolesnick
kolesnick / hg-branchowners.ps1
Created November 25, 2013 10:54
Lists Merucrial branches grouped by their owners. Requires https://github.com/kolesnick/hg-power to be installed.
hg branches | %{ $_.Split(' ')[0] } | group { hgbranchowner $_ } | %{
write $_.Name
$_.Group | write
write ''
}
@kolesnick
kolesnick / xml-comment.regex
Created July 9, 2013 10:58
Useful regexes for Visual Studio search and replace functionality
(( )+/// .*\n)+
@kolesnick
kolesnick / mspec-proxy-1arg-test.cs
Created March 6, 2012 20:26
ReSharper template for MSpec+Moq test of proxy method with 1 arg which returns data got from different entity
/*
Please remove this comment only after placing this template to ReSharper template editor.
Existance of this comment during paste will automatically align macroses in shown order.
Macroses:
$Proxy$ - ProxyName (this one is under test)
$ProxyMethod$ - ProxyMethod
$proxy$ - proxyName
$Result$ - ResultType
$Argument$ - ArgumentType (argument of method under test which is supplied to subject method)
@kolesnick
kolesnick / mspec-proxy-no-args-test.cs
Created March 6, 2012 18:54
ReSharper template for MSpec+Moq test of proxy method with no args which returns data got from different entity
/*
Please remove this comment only after placing this template to ReSharper template editor.
Existance of this comment during paste will automatically align macroses in shown order.
Macroses:
$Proxy$ - ProxyName (this one is under test)
$ProxyMethod$ - ProxyMethod
$proxy$ - proxyName
$Result$ - ResultType
$ISubject$ - SubjectName (this one produces data returned by proxy)
@kolesnick
kolesnick / mspec-equality-tests.cs
Created February 29, 2012 17:09
ReSharper template for MSpec tests of Equals method and == operator
/*
Please remove this comment only after placing this template to ReSharper template editor.
Existance of this comment during paste will automatically align macroses in shown order.
Macroses:
$Entity$ - EntityName
$entity$ - entityName
$entity_in_when_part$ - entity_name
$entities_in_when_part$ - entity_name_in_plural
$usage_of_initial_parameters_in_ctor$ - arguments of factory method supplied to constructor