Skip to content

Instantly share code, notes, and snippets.

@danielmarbach
danielmarbach / MoqToFakeItEasy.DotSettings
Last active August 23, 2023 17:05
Structural Search and Replace Pattern for Migration from Moq to FakeItEasy with Resharper
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=23B254B63645A7449313D9A6F88A5C0C/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=23B254B63645A7449313D9A6F88A5C0C/Comment/@EntryValue">Replace Mock Field with FakeItEasy</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=23B254B63645A7449313D9A6F88A5C0C/CustomPatternPlaceholder/=fieldName/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=23B254B63645A7449313D9A6F88A5C0C/CustomPatternPlaceholder/=fieldName/Properties/=CaseSensitive/@EntryIndexedValue">True</s:String>
<s:String x:Key="/Default/PatternsAndTempla
@danielmarbach
danielmarbach / HashSetComparison.cs
Last active June 26, 2023 09:16
HashSet Discussion
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Extensions;
namespace MicroBenchmarks.Hashing;
[Config(typeof(Config))]
@danielmarbach
danielmarbach / Echo.sh
Created June 1, 2023 11:09
Echo Cancellation Fedora 38
pactl list | grep -A2 'Source #' | grep 'Name: ' | cut -d" " -f2
nano ~/.config/pipewire/pipewire.conf.d/echo-cancel.conf
context.modules = [
{ name = libpipewire-module-echo-cancel
args = {
library.name = aec/libspa-aec-webrtc
monitor.mode = true
aec.args = {
@danielmarbach
danielmarbach / SafeObservableCollection
Created May 17, 2011 18:18
Thread safe observable collection
[DebuggerDisplay("Count = {Count}")]
[ComVisible(false)]
public class SafeObservableCollection<T> : ObservableCollection<T>
{
private readonly Dispatcher dispatcher;
public SafeObservableCollection()
: this(Enumerable.Empty<T>())
{
}
@danielmarbach
danielmarbach / AnExample.cs
Last active October 26, 2020 10:55
RavenMigrations Async
namespace ServiceControl.Migrations
{
using System;
using System.Threading.Tasks;
using Raven.Abstractions;
using Raven.Abstractions.Data;
using ServiceBus.Management.Infrastructure.Settings;
using ServiceControl.Contracts.Operations;
using ServiceControl.MessageFailures;
@danielmarbach
danielmarbach / ClientProxyInterceptor.cs
Created May 18, 2011 22:30
Client proxy interceptor for WCF and dynamic proxy
public class ClientProxyInterceptor : IInterceptor
{
private readonly Func<ICommunicationObject> proxyCreator;
private readonly Type typeToProxy;
private ICommunicationObject proxyInstance;
public ClientProxyInterceptor(Func<ICommunicationObject> proxyCreator, Type typeToProxy)
{
this.typeToProxy = typeToProxy;
this.proxyCreator = proxyCreator;
@danielmarbach
danielmarbach / AssemblyInfo.cs
Created July 22, 2013 17:56
My InMemory approach for unit testing and acceptance testing with NServiceBus which uses custom IBus, FluentAssertions and NUnit actions
[assembly: WithBus]
@danielmarbach
danielmarbach / Capstone1.fs
Created May 12, 2020 20:16
Some fiddling around with FSharp
open System
let petrolOfCar = 100
type Destination = Home | Office | Stadium | GasStation
let driveTo destination currentPetrol =
let remainingPetrol =
match destination with
| Home -> currentPetrol - 25
| Office -> currentPetrol - 50
| Stadium -> currentPetrol - 25
@danielmarbach
danielmarbach / nsb_raw_hacks.md
Last active March 10, 2020 07:46 — forked from SzymonPobiega/nsb_raw_hacks.md
Hacks in NServiceBus.Raw

Stuff passed via settings

Things that transport used to require that are passed via settings, not via seam:

Settings.Set("Endpoint.SendOnly", sendOnly);
Settings.Set("TypesToScan", new Type[0]);
Settings.Set("NServiceBus.Routing.EndpointName", endpointName);
Settings.Set<Conventions>(new Conventions()); //Hack for ASB
Settings.Set(new StartupDiagnosticEntries());
public static class TimeboxExtensions
{
public static async Task Timebox(this IEnumerable<Task> tasks, TimeSpan timeoutAfter, string messageWhenTimeboxReached)
{
using (var tokenSource = new CancellationTokenSource())
{
var delayTask = Task.Delay(Debugger.IsAttached ? TimeSpan.MaxValue : timeoutAfter, tokenSource.Token);
var allTasks = Task.WhenAll(tasks);
var returnedTask = await Task.WhenAny(delayTask, allTasks).ConfigureAwait(false);