Skip to content

Instantly share code, notes, and snippets.

View NinoFloris's full-sized avatar

Nino Floris NinoFloris

View GitHub Profile
@NinoFloris
NinoFloris / code.fs
Last active November 1, 2018 14:30
OptionsFactory with func instead of new()
namespace Configuration
open System
open System.Runtime.CompilerServices
open Microsoft.Extensions.Options
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Configuration
type OptionsFactoryFromFunc<'TOptions when 'TOptions : not struct and 'TOptions : (new : unit -> 'TOptions)>
(factoryFunc: Func<'TOptions>,
@NinoFloris
NinoFloris / keybase.md
Created October 30, 2018 16:50
keybase.md

Keybase proof

I hereby claim:

  • I am NinoFloris on github.
  • I am ninofloris (https://keybase.io/ninofloris) on keybase.
  • I have a public key whose fingerprint is 0772 2EE9 8C00 2F36 922E 2C7C 622A 9882 5766 7DFB

To claim this, I am signing this object:

@NinoFloris
NinoFloris / OptionUnionConverter.fs
Created July 31, 2018 16:40
OptionUnionConverter for failure allowed conversions
// Written in 2018 by Nino Floris (mail@ninofloris.com)
//
// To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights
// to this software to the public domain worldwide. This software is distributed without any warranty.
//
// You may have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
namespace JsonConverters
@NinoFloris
NinoFloris / .cs
Created January 31, 2017 17:29
Controller action example
public class UsersController
{
[HttpGet]
public Task<IEnumerable<Many.Model>> GetMany(Many.Query query, [FromServices]IMediator mediator)
{
return mediator.SendAsync(query);
}
}
@NinoFloris
NinoFloris / .sh
Created December 19, 2016 19:34
Working sed loop command, old files are .bak
for i in *; do sed -i.bak 's/listen 443 ssl;/listen 443 ssl http2;/g' "$i"; done
@NinoFloris
NinoFloris / .cs
Created December 9, 2016 18:16
Mediator pipeline proof of concept
public delegate Task<TResponse> RequestHandlerDelegate<TResponse>(IAsyncRequest<TResponse> request);
public interface IRequestHandler<TRequest, TResponse> where TRequest : IAsyncRequest<TResponse>
{
Task<TResponse> Handle(TRequest message, RequestHandlerDelegate<TRequest, TResponse> next);
}
public class MediatorDecorator : IMediator
{
// [...]
@NinoFloris
NinoFloris / .cs
Created November 20, 2016 21:30
FastIntAsTextToStringBuilder
static unsafe void FastIntAsTextToStringBuilder(int input, StringBuilder sb)
{
const string sign = "-";
const int signSize = 1;
const int size = 15 + signSize;
var charbuf = stackalloc char[size];
var p = charbuf + size - 1;
var minDigits = 1;
@NinoFloris
NinoFloris / .cs
Created November 20, 2016 13:08
Automapper repro issue 1802
using System;
using AutoMapper;
namespace ConsoleApplication
{
public class Source
{
public Model Url { get; set; } = new Model();
}
@NinoFloris
NinoFloris / .cs
Created March 14, 2016 20:58
Map scalar values from Dapper rows to dto objects
public static class IEnumerableExtension {
public static IEnumerable<TFirst> Map<TFirst, TSecond, TKey>
(
this IEnumerable<TFirst> firstList,
Func<TFirst, TKey> firstKey,
Func<TSecond, TKey> secondKey,
Action<TFirst, IEnumerable<TSecond>> addChildren,
Func<IEnumerable<TSecond>> secondList
)
{
Response: 421 Timeout - try typing a little faster next time
Error: GnuTLS error -110: The TLS connection was non-properly terminated.
Status: Server did not properly shut down TLS connection
Error: Disconnected from server: ECONNABORTED - Connection aborted
Status: Disconnected from server