Skip to content

Instantly share code, notes, and snippets.

@zetroot
zetroot / MiddlewareLifetimeTests.cs
Last active August 7, 2023 21:33
Middleware lifetime tests
using FluentAssertions;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using MiddlewareApp;
using NUnit.Framework;
namespace MiddlewareAppTests;
public class AppFac : WebApplicationFactory<Program>
{

Keybase proof

I hereby claim:

  • I am zetroot on github.
  • I am zetroot (https://keybase.io/zetroot) on keybase.
  • I have a public key ASDUYE9jwOK8VdIbSC0TWAwcy4KDjRPEpPqq5CIgOaiquQo

To claim this, I am signing this object:

@zetroot
zetroot / StdOutRedirection.cs
Created September 16, 2021 11:15
Capture stdout and redirect Console to null
using System;
using System.IO;
var stdout = Console.Out;
Console.SetOut(StreamWriter.Null);
Console.WriteLine("this goes to null");
stdout.WriteLine("this goes to standart output");
Console.Out.WriteLine("and this goes to null again");
@zetroot
zetroot / gist.sh
Created May 28, 2021 10:23
Reset master to upstream
# ensures current branch is master
git checkout master
# pulls all new commits made to upstream/master
git pull upstream master
# this will delete all your local changes to master
git reset --hard upstream/master
# take care, this will delete all your changes on your forked master
@zetroot
zetroot / EnumerableAggregator.cs
Created March 11, 2021 07:50
Группировка по агрегациям
public static class EnumerableAggregator
{
private class AggregateGrouping<TKey, TElement> : IGrouping<TKey, TElement>
{
private readonly IReadOnlyList<TElement> items;
public IEnumerator<TElement> GetEnumerator() => items.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => items.GetEnumerator();
@zetroot
zetroot / NotifyDataErrorInfo.cs
Created September 21, 2020 14:06
NotifyDataErrorInfo
public class NotifyDataErrorInfo : INotifyPropertyChanged, INotifyDataErrorInfo
{
private readonly Dictionary<string, List<string>> _errorsByPropertyName = new Dictionary<string, List<string>>();
private readonly Func<IdentityUserVM, bool> PropertyUniquityValidationCallback;
private string property;
public string Property
{
get => base.UserName;
set

Глобальная установка

Все мануалы по установке с ипользованием пакетных менеджеров не работают на Raspbian и Armbian. Но тем не менее работать с net core 3.1 можно и с малины и с апельсины. Помогает установка "ручками":

curl -SL -o dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/15132a5c-f0f4-4373-8b8b-b7e70834d899/cad479dda52359ad43956471274ec932/dotnet-runtime-3.1.5-linux-arm.tar.gz
sudo mkdir -p /usr/share/dotnet
sudo tar -zxf dotnet.tar.gz -C /usr/share/dotnet
sudo ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet