This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
void Return_result() | |
{ | |
Result Function() => Result.Ok(); | |
Assert.True(Function() is Ok); | |
} | |
[Fact] | |
void Return_result_value() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter zero_is_true { | |
# incoming value of 0 is mapped to $true, mapped to $false ortherwise | |
if(0 -eq $_) { | |
$true | |
} | |
else { | |
$false | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IHostBuilder CreateHostBuilder(string[] args) => | |
Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args) | |
.UseSerilog(ConfigureSerilog) | |
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>()); | |
private static void ConfigureSerilog(HostBuilderContext hostBuilderContext, LoggerConfiguration loggerConfiguration) | |
{ | |
loggerConfiguration.ReadFrom.Configuration(hostBuilderContext.Configuration); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem . | Foreach-Object { | |
# this is done foreach reg key | |
$regKey = $_; | |
# property is a list of properties of the registry key | |
$_.Property | ForEach-Object -Process { | |
[PScustomobject]@{ | |
Key =$regKey.Name | |
Property=$_ | |
# Value is returned as a complex object extsnded with sevaral PS properties. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.meziantou.net/debouncing-throttling-javascript-events-in-a-blazor-application.htm | |
Action<T> Debounce<T>(Action<T> action, TimeSpan interval) | |
{ | |
if (action == null) throw new ArgumentNullException(nameof(action)); | |
var last = 0; | |
return arg => | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://weblog.west-wind.com/posts/2021/Mar/09/Role-based-JWT-Tokens-in-ASPNET-Core | |
// create token and sign it with key | |
var signingCredentials = new SigningCredentials( | |
key: new SymmetricSecurityKey(Encoding.UTF8.GetBytes("Thats a sufficiently long key")), | |
algorithm: SecurityAlgorithms.HmacSha256); | |
var token = new JwtSecurityToken( | |
issuer:"issuer", | |
audience: "audience", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://medium.com/dev-genius/jwt-authentication-in-asp-net-core-e67dca9ae3e8 | |
var rsa = RSA.Create(); | |
var keyPair = ( | |
prv: rsa.ExportRSAPrivateKey(), | |
pub: rsa.ExportRSAPublicKey() | |
); | |
// create token and sign it with private key | |
var rsa_signer = RSA.Create(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<PropertyGroup Label="FineCodeCoverage"> | |
<Enabled>True</Enabled> | |
<Exclude> | |
[Microsoft.*]* | |
[System.*]* | |
</Exclude> | |
<Include>[*]*</Include> | |
<ExcludeByFile></ExcludeByFile> | |
<ExcludeByAttribute></ExcludeByAttribute> | |
<IncludeTestAssembly>True</IncludeTestAssembly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ClassLogger | |
{ | |
private readonly string typeName; | |
public static ClassLogger Make<T>(T instance) | |
{ | |
return new ClassLogger(typeof(T).Name); | |
} | |
public ClassLogger(string typeName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace System.Management.Automation | |
using namespace System.Collections.ObjectModel | |
function inner { | |
param( | |
[int]$Value | |
) | |
$Value | |
} |
NewerOlder