Skip to content

Instantly share code, notes, and snippets.

View lkaczanowski's full-sized avatar

Łukasz Kaczanowski lkaczanowski

View GitHub Profile
@lkaczanowski
lkaczanowski / duplicate_load.md
Created December 18, 2020 14:48 — forked from swlaschin/duplicate_load.md
Example of duplicate #load

The duplicate #load problem and how to fix it

Symptom: A weird error such as:

error FS0001: This expression was expected to have type
    'FSI_0011.MyType'
but here has type
    'FSI_0012.MyType'
@lkaczanowski
lkaczanowski / UnFold.cs
Created June 19, 2020 09:31 — forked from palladin/UnFold.cs
IAsyncEnumerable UnFold
static async IAsyncEnumerable<T> UnFold<T, TAcc>(Func<TAcc, Task<(bool Next, IAsyncEnumerable<T> Values, TAcc Acc)>> f, TAcc seed)
{
var acc = seed;
var result = default((bool Next, IAsyncEnumerable<T> Values, TAcc Acc));
do
{
result = await f(acc);
await foreach (var value in result.Values)
yield return value;
@lkaczanowski
lkaczanowski / PageCalculator.cs
Created June 27, 2017 10:21
Calculator for paging
using System.Collections.Generic;
using System.Linq;
namespace PageCalculator
{
public class Page
{
public Page(int skip, int take)
{
Skip = skip;
@lkaczanowski
lkaczanowski / WindsorContainerExtensions.cs
Created June 22, 2017 14:01
Extensions for Castle Windstor ie: verifying registration of dependencies
using System;
using System.Linq;
using System.Text;
using Castle.MicroKernel;
using Castle.MicroKernel.Handlers;
using Castle.Windsor;
using Castle.Windsor.Diagnostics;
namespace Extensions
@lkaczanowski
lkaczanowski / Setup.fsx
Created April 11, 2017 12:05 — forked from ovatsus/Setup.fsx
Script to setup F# Interactive session, loading everything in the current solution
#r "System.Xml.Linq"
open System
open System.IO
open System.Xml.Linq
let script = seq {
//TODO: this currently loads fsproj's in alphabeticall order, we should instead
//build the dependencies graph of the fsproj's and load them in topological sort order
public interface IDependencyA
{
int QueryMethod(int q);
}
public interface IDependencyB
{
void CommandMethod(int c);
}
@lkaczanowski
lkaczanowski / ResharperTestingWithAutofixtureAndNUnit.DotSettings
Created February 22, 2016 15:20
Resharper teample for testing class with Autofixture and NUnit
<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/LiveTemplates/Template/=2042F55FFF64F8489A3078E18B77EF16/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=2042F55FFF64F8489A3078E18B77EF16/Shortcut/@EntryValue">test</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=2042F55FFF64F8489A3078E18B77EF16/Description/@EntryValue">Creates NUnit test</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=2042F55FFF64F8489A3078E18B77EF16/Text/@EntryValue">[Test]&#xD;
public void $MethodName$()&#xD;
{&#xD;
// assign&#xD;
$END$&#xD;
&#xD;
@lkaczanowski
lkaczanowski / AutoFixtureExtensions.cs
Last active February 17, 2016 08:10
Extensions for AutoFixture
namespace AutoFixtureExtensions
{
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.AutoMoq;
using Ploeh.AutoFixture.Kernel;
public class SpecificArgumentsConstructorQuery : IMethodQuery
{
private readonly Type[] _types;
@lkaczanowski
lkaczanowski / FluentValidationExtensions.cs
Last active January 8, 2016 11:15
Fluent Validation helper methods to get errors for specific property
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Resources;
using System.Web.Mvc;
using FluentValidation.Results;
namespace Helpers
{
@lkaczanowski
lkaczanowski / RestSharpExtensions.cs
Last active November 4, 2022 23:08
RestSharp extensions for error handling
using System;
using System.Net;
using System.Text;
using RestSharp;
namespace RestSharpExtensions
{
internal static class RestSharpExtensions
{