Skip to content

Instantly share code, notes, and snippets.

View kshyju's full-sized avatar

Shyju Krishnankutty kshyju

View GitHub Profile
@kshyju
kshyju / STJ-JsonConverterTests
Last active April 26, 2021 20:38
Tests for Custom JsonConverter to handle arrays in non valid format
public sealed class Person
{
public string FullName { get; set; }
[JsonConverter(typeof(VehiclesArrayConverter))]
public List<Vehicle>? Vehicles { get; set; }
public string[] Aliases { get; set; }
}
@kshyju
kshyju / Blog2021LinqIntersectAnyUsageSample.cs
Last active May 15, 2021 19:25
Blog-2021_05_15_LINQIntersectAny
IEnumerable<string> first = new[] {"one", "two", "three","four","five","six","seven","eight"};
IEnumerable<string> second = new[] { "two", "three"};
var matchFound = first.Intersect(second, StringComparer.OrdinalIgnoreCase).Any();
@kshyju
kshyju / gist:3a0aacf2e5185e6932a1a16693ca6dd2
Created December 11, 2021 01:46 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@kshyju
kshyju / StringEqualsBenchmarks-Results.MD
Created April 22, 2022 21:31
StringEqualsBenchmarks
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.22530
Unknown processor
.NET SDK=6.0.202
  [Host]     : .NET 5.0.16 (5.0.1622.16705), X64 RyuJIT
  DefaultJob : .NET 5.0.16 (5.0.1622.16705), X64 RyuJIT

@kshyju
kshyju / ExceptionHandlingMiddleware.cs
Created May 16, 2022 03:13
Blog-2022_05_15_FunctionsMiddlewareApis
public class ExceptionHandlingMiddleware : IFunctionsWorkerMiddleware
{
private readonly ILogger<ExceptionHandlingMiddleware> _logger;
public ExceptionHandlingMiddleware(ILogger<ExceptionHandlingMiddleware> logger)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public async Task Invoke(FunctionContext context, FunctionExecutionDelegate next)
@kshyju
kshyju / ControlStatementsBenchmarkResult.MD
Last active June 15, 2022 23:20
Benchmark results of IF-ELSE vs Switch statement
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.25141
Intel Xeon CPU E5-1650 v4 3.60GHz, 1 CPU, 12 logical and 6 physical cores
.NET SDK=6.0.300
  [Host]     : .NET 5.0.17 (5.0.1722.21314), X64 RyuJIT
  DefaultJob : .NET 5.0.17 (5.0.1722.21314), X64 RyuJIT

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleAppNetFr481
{
internal class Program
{
@kshyju
kshyju / EnumBenchMarkResults.MD
Created August 12, 2022 23:26
Enum benchmarks tp get enum value string
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.22000
11th Gen Intel Core i7-1185G7 3.00GHz, 1 CPU, 8 logical and 4 physical cores
.NET SDK=7.0.100-preview.7.22377.5
  [Host]     : .NET 6.0.8 (6.0.822.36306), X64 RyuJIT
  DefaultJob : .NET 6.0.8 (6.0.822.36306), X64 RyuJIT

@kshyju
kshyju / CollectionBenchmarks.cs
Last active September 21, 2022 16:53
HashSet constructor vs autogrow benchmarks
[MemoryDiagnoser]
public class CollectionBenchmarks
{
string[] items = new string[] { "hello", "world", "some", "and", "one" };
[Benchmark]
public HashSet<string> AutoGrow()
{
var tpas = new HashSet<string>();
foreach (var tpa in items)
@kshyju
kshyju / V4NetFxcsproj.cs
Last active October 16, 2022 19:31
Blog2022AzureFunctionsV1toV4Migration
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.10.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" />