Skip to content

Instantly share code, notes, and snippets.

@flq
flq / AsyncEnumerableStream.cs
Last active October 3, 2024 15:10
A class that is supposed to help you consume an IAsyncEnumerable<byte[]> and expose it as a Stream
#nullable enable
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Utilities;
public class AsyncEnumerableStream(IAsyncEnumerable<byte[]> source) : Stream
@flq
flq / AssemblyPoolRegistrar.cs
Last active July 8, 2021 10:23
Utility classes for named dependencies (,NET Core, C# 9)
using System;
using System.Linq;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
namespace DIPlaygroundWebApp.ServiceCollectionInfrastructure
{
public static class AssemblyPoolRegistrar
{
public static AssembliesForRegistration UseBulkRegistration(this IServiceCollection svcCollection,
@flq
flq / dotnet_snippets.txt
Created August 16, 2018 20:44
Some nice .NET snippets
.NET snippets
1. Deconstruct a regex match group collection
@flq
flq / nasties.cs
Last active December 16, 2017 12:04
Ye olde NRE from a ctor call
using System;
using System.Runtime.Remoting.Proxies;
internal class Program
{
private static void Main(string[] args)
{
var c = new CrazyObject();
Console.WriteLine(c.Hello());
Console.ReadLine();
}
@flq
flq / GetWSDLs.ps1
Created August 17, 2017 08:23
Acccess discovery service, download all WSDLs for listed services
function indent([parameter(ValueFromPipeline)]$Content)
{
$StringWriter = New-Object System.IO.StringWriter
$XmlWriter = New-Object System.XMl.XmlTextWriter $StringWriter
$xmlWriter.Formatting = "indented"
$xmlWriter.Indentation = 2
$Content.WriteContentTo($XmlWriter)
$XmlWriter.Flush()
$StringWriter.Flush()
Write-Output $StringWriter.ToString()
@flq
flq / BitempTests.fs
Last active December 16, 2016 13:15
Bitemporal code samples
module BitempTests
type TimePoint<'S> = {
recorded : int;
actual : int;
state : 'S;
}
type HistoryEntry<'S> = {
time : int;

Keybase proof

I hereby claim:

  • I am flq on github.
  • I am fquednau (https://keybase.io/fquednau) on keybase.
  • I have a public key ASDraf_OUnnhDWmgwKEoWTSV7QHQ1pjDPm0pCCSGME0ttwo

To claim this, I am signing this object:

@flq
flq / IiUnitTests.cs
Last active December 30, 2015 21:40
Gist for using NMeasure for surplus energy in atmosphere...
using System.Collections.Generic;
using Xunit;
using static NMeasure.U;
using static NMeasure.Tests.IiUnits;
namespace NMeasure.Tests
{
public class IIUnitsTests
{
public IIUnitsTests()
@flq
flq / EntryPoint.ts
Last active October 10, 2015 23:45
Gists for the blog post porting react app to tyescript
import {assign} from 'lodash'
function startModule() {
//etc.
}
global['Project'] = assign(global['Project'] || {}, {
startModule
});
@flq
flq / Permutation.hs
Last active August 29, 2015 14:23
No-frills permutation code in Haskell
module Permutation where
permutate :: [a] -> [[a]]
permutate [x1,x2] = [[x1,x2],[x2,x1]]
permutate items = concat $ map p $ getEachInFrontOnce items
where
p (x:xs) = map (\items -> [x]++items) $ permutate xs
getEachInFrontOnce items = map (putItemAtIndexToFront items) [0..length items-1]
putItemAtIndexToFront items idx = [items!!idx] ++ take idx items ++ drop (idx+1) items