Code Snippets
Async Parallel
static Task ParallelForEachAsync<T> (IEnumerable<T> source, ...
AsyncHelper
public static class AsyncHelper { private static readonly TaskFactory _myTaskFact...
Authentik NPM Redirect with Websocket support
# Increase buffer size for large headers # This is needed only if you get 'upstream sent too b...
Batching with LINQ
static IEnumerable<IEnumerable<T>> Batch<T>(this IEnumerable<T> source, int batchSize) { ...
Build project with SourceGenerator on linux
Add Microsoft.Net.Compilers.Toolset package to the project that references the source generator.
Change file encoding with linux
To get current encoding: file -i {filename} To convert it: iconv -f {sourceEncoding} -t {targe...
Docker Buildx Multi-Arch
sudo docker buildx create --use --name multi-arch-builder Usage: sudo docker buildx build --pla...
Handle Exceptions with Task.WhenAll()
var tasks = Enumerable.Range(0, 10).Select(async _ => await Task.Delay(1000)); var whenAll = Tas...
Left outer join
from leftTable in context.leftTable join rightTable in context.rightTable on leftTable.FKRight...
List iteration using span
var list = new List<int>(); foreach(var item in CollectionsMarshal.AsSpan(list)) { } On...
Load Assembly Dynamically
In order to Copy NuGet dependecies to the output folder add this to classlibrary.csproj: <CopyLo...
macOS Defaults
Auto-Resize Columns in column view defaults write com.apple.finder _FXEnableColumnAutoSizing -bo...
Mount host volumes in WSL2
Add the following to /etc/wsl.conf [automount] options = "metadata"
Optional<T>
See Attachments
RegEx in multiple files multi-line pattern
pcregrep -h -r --include=".*\.cs" -M "LogEvent\([\s\S]*?\)\;" . -h: Exclude filenames -r: rec...