Skip to content

Instantly share code, notes, and snippets.

View AlbertoMonteiro's full-sized avatar
😎
Writting every day lines fo happy code

Alberto Monteiro AlbertoMonteiro

😎
Writting every day lines fo happy code
View GitHub Profile
@AlbertoMonteiro
AlbertoMonteiro / Program.cs
Created September 21, 2024 10:03
2005. Subtree Removal Game with Fibonacci Tree
using Spectre.Console;
for (var i = 10; i >= 1; i--)
{
AnsiConsole.MarkupLine($"Dado que n é igual a [yellow]{i:00}[/] então [blue]Alice[/] {(FibonacciTree.DoAliceWins(i) ? "[green]vence[/]" : "[red]perde[/]")}");
}
public record Node(int Value, Node? Left = null, Node? Rigth = null)
{
public static explicit operator int(Node node)
using SharpSvn;
using System.Collections.ObjectModel;
string repositoryUrl = "url_do_repositorio";
string trunkPath = "/trunk";
string tagPath = "/tags/tag_name";
using (SvnClient client = new SvnClient())
{
// Obtém os IDs dos últimos 5 commits no trunk
@AlbertoMonteiro
AlbertoMonteiro / Program.cs
Last active December 24, 2021 03:13
CustomSerializeProperty
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using System.Text.Json.Serialization;
var person = new Person("Alberto", "JobInfo", new JobInfo("CSF", "Software Architect"));
var serializeOptions = new JsonSerializerOptions();
serializeOptions.Converters.Add(new BaseInfoConverter());
@AlbertoMonteiro
AlbertoMonteiro / SampleMigration.cs
Last active December 12, 2021 03:40
SqlServerWithTemporalTablesMigrationsSqlGenerator to use Temporal Tables in migrations with .NET 5.0 and EF Core 5.0
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
using System;
namespace ConsoleApp1.Migrations
{
public partial class Initial : Migration
{
BenchmarkDotNet=v0.13.0, OS=Windows 10.0.18363.1556 (1909/November2019Update/19H2)
Intel Core i7-8665U CPU 1.90GHz (Coffee Lake), 1 CPU, 8 logical and 4 physical cores
.NET SDK=5.0.202
  [Host]     : .NET 5.0.5 (5.0.521.16609), X64 RyuJIT
  DefaultJob : .NET 5.0.5 (5.0.521.16609), X64 RyuJIT

@AlbertoMonteiro
AlbertoMonteiro / FormatarCpf.cs
Created May 15, 2021 15:17
Formatar Cpf benchmark
using BenchmarkDotNet.Attributes;
using System;
namespace RemoveLater
{
[MemoryDiagnoser]
public class FormatarCpf
{
private string _cpf;
@AlbertoMonteiro
AlbertoMonteiro / alberto-theme.psm1
Last active August 14, 2021 10:25
My powershell theme
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
@AlbertoMonteiro
AlbertoMonteiro / LargeReplace.cs
Last active April 17, 2020 22:39
Many Replaces vs Regex Replace
using BenchmarkDotNet.Attributes;
using System.IO;
using System.Text.RegularExpressions;
namespace ManyBenchmarks
{
public static class Extensions
{
public static string RegexReplace(this string str, string pattern, string replacer)
=> Regex.Replace(str, pattern, replacer);