Skip to content

Instantly share code, notes, and snippets.

View kant2002's full-sized avatar

Andrii Kurdiumov kant2002

View GitHub Profile
@kant2002
kant2002 / instructions.txt
Last active January 25, 2022 04:04
F# test app for reflection-free code
# one time
./build.sh
# when make changes to compiler
dotnet build src/fsharp/fsc/fsc.fsproj
# Compile test application
artifacts/bin/fsc/Debug/net5.0/fsc ../test.fs --targetprofile:netcore --target:exe --out:test.exe
dotnet test.exe
@kant2002
kant2002 / original.cs
Last active January 31, 2022 19:41
Тестирование времени в C#
void EnrichRequest(Request request)
{
var days = configurationService.GetValidDurationInDays();
request.ValidTo = request.ValidTo ?? DateTime.Now.AddDays(days);
}
// Супер легко использовать
EnrichRequest(request);
/*
@kant2002
kant2002 / sample.cs
Last active June 13, 2022 12:59
NativeAOT and DI
namespace InternalNamespace.Nested;
using Microsoft.Extensions.DependencyInjection;
class DependentTestService {}
class TestService
{
public TestService(DependentTestService dependency) {}
}
@kant2002
kant2002 / story.md
Created July 8, 2022 08:44
Why Security is hard

I have very specific view that ASP.NET Core security is probably fine, but overall industry guidelines are meh and tailored for security people. Almost all issues which I have with implementing security was due to other external factors, like:

  • lack of resources
  • Lack of training in securing solution
  • Lack of time to find proper solution
  • Lots of jargonism and abstractiosn in describing security.

My observvations applied to cases where solo-developer or team of developers responsible for implementing security for their "product". That can be devs in small, mid sized org, or teams in large orgs where security department demands some techniquest to be employed. Or even better goverment agencies which everywhere in the world underfunded and do not have enough resources for securing things.

@kant2002
kant2002 / _before.cs
Created August 10, 2022 06:33
LibraryImport Generator sample
[LibraryImport(Libraries.UxTheme)]
public static partial HRESULT DrawThemeEdge(
IntPtr hTheme,
Gdi32.HDC hdc,
int iPartId,
int iStateId,
ref RECT pDestRect,
User32.EDGE uEdge,
User32.BF uFlags,
ref RECT pContentRect);
@kant2002
kant2002 / index.mjs
Created August 30, 2022 16:53
Mokey Patching some REAL CODEZZ
import x from "./module.mjs";
import "./second.mjs";
x.log();
@kant2002
kant2002 / Program.cs
Created August 31, 2022 19:53
Windows Forms NativeAOT
Application.Run(new Form() { Text = "Hello NativeAOT!" });
@kant2002
kant2002 / program.cs
Created September 12, 2022 15:02
Funny lock
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
test x = new test();
for(var i =0; i < 10; i++)
{
var thread = new Thread(Worker);
thread.Start();
}
@kant2002
kant2002 / AvaloniaHeadlessConsoleApp.csproj
Last active November 6, 2022 14:54
Headless Avalonia
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
@kant2002
kant2002 / Program.csproj
Created November 16, 2022 05:06 — forked from seclerp/Program.csrpoj
Solution for the task "Run the Java Hello World example via both dotnet run and javac"
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.java" />
</ItemGroup>