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
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);
@AlbertoMonteiro
AlbertoMonteiro / js.js
Last active February 3, 2021 00:32
funretro
let boardTitle = document.querySelector('#board-name').textContent.trim();
if (!boardTitle) {
throw 'Board title does not exist. Please check if provided URL is correct.'
}
let parsedText = boardTitle + '\n\n';
let columns = document.querySelectorAll('.message-list');
columns.forEach((column) => {
const columnTitle = column.querySelector('.column-header h2').textContent.trim();
const messages = [...column.querySelectorAll('.message-main')].map(messageBody => {
const messageText = messageBody.querySelector('.message-body .text').textContent.trim();