Skip to content

Instantly share code, notes, and snippets.

@bellons91
bellons91 / collection-resize-benchmark.cs
Created July 9, 2023 13:40
Collection resize benchmark
#LINQPad optimize+
void Main()
{
var summary = BenchmarkRunner.Run<HashSetPerformance>();
}
[MemoryDiagnoser]
public class HashSetPerformance
{
[Params(100, 1000, 10000, 100_000)]
@bellons91
bellons91 / show-notification-win10.ps1
Created August 2, 2022 07:54
This PowerShell script allows you to show timed notification on your Win10 system. It can be useful to show reminders
function Show-Notification {
[cmdletbinding()]
Param (
[string]
$ToastTitle,
[string]
[parameter(ValueFromPipeline)]
$ToastText
@bellons91
bellons91 / result.md
Created May 13, 2022 09:22
This benchmark shows the performance of using Structs passed by reference vs using Classes

BenchmarkDotNet=v0.13.1, OS=Windows 10.0.18363.1500 (1909/November2019Update/19H2) Intel Core i7-8550U CPU 1.80GHz (Kaby Lake R), 1 CPU, 8 logical and 4 physical cores .NET SDK=6.0.202 [Host] : .NET 5.0.16 (5.0.1622.16705), X64 RyuJIT

Method Size Mean Error StdDev Median Gen 0 Allocated
RunClass 10 204.9 ns 3.77 ns 6.81 ns 203.4 ns 0.0899 376 B
RunStructNoRef 10 138.7 ns 2.57 ns 2.28 ns 138.7 ns 0.0229 96 B
@bellons91
bellons91 / merge-schedule.yml
Created April 29, 2022 13:41
This GitHub action merges my active PRs on the date specified in the /schedule field every Tuesday at 8AM UTC
name: Merge Schedule
on:
pull_request:
types:
- opened
- edited
schedule:
# https://crontab.guru/every-hour
- cron: 0 8 * * Tue
@bellons91
bellons91 / auto-assign-to-project.yml
Created April 28, 2022 08:50
This GitHub Action automatically assigns a task or a PR to the related Project given its Labels
name: Auto Assign to Project(s)
on:
issues:
types: [opened, labeled]
pull_request:
types: [opened, labeled]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@bellons91
bellons91 / article-creator.ps1
Created April 28, 2022 08:46
This PowerShell script automatically creates the structure for a blog article with some predefined Frontmatter fields
git checkout master
git pull
$tmpSlug = Read-Host -Prompt 'Article slug?'
$currentYear = Get-Date -Format "yyyy"
$newFolderName = $currentYear +"/" + $tmpSlug
$rootLocation = Get-Location
$placeholderImgLocation = "\assets\img_placeholder.png"
<div class="container">
<main role="main" class="pb-3">
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
<div class="container-fluid ">
Mock<HttpMessageHandler> handler = new Mock<HttpMessageHandler>();
var factory = handler.CreateClientFactory(); // it comes from Moq.Contrib.HttpClient
Mock.Get(factory).Setup(x => x.CreateClient("matrics"))
.Returns(() =>
{
var client = handler.CreateClient();
client.BaseAddress = new Uri("https://code4it.dev");
return client;
});
using System;
using System.Collections.Generic;
using System.Linq;
namespace Code4ItExamples.Extension_methods
{
public static class ExtensionMethodExamples
{
.public{
color: red;
}