Skip to content

Instantly share code, notes, and snippets.

View skarllot's full-sized avatar
💭
I may be slow to respond.

Fabrício Godoy skarllot

💭
I may be slow to respond.
View GitHub Profile
@skarllot
skarllot / MsSqlTestBase.cs
Last active July 16, 2025 17:46
Test EF Core (Entity Framework) migrations
using DotNet.Testcontainers.Builders;
using DotNet.Testcontainers.Configurations;
using DotNet.Testcontainers.Containers;
using Microsoft.EntityFrameworkCore;
using Testcontainers.MsSql;
using Xunit;
namespace Tests;
public abstract class MsSqlTestBase : IAsyncLifetime
{
"analysisServicesServers": "as",
"apiManagementService": "apim-",
"appConfigurationStores": "appcs-",
"appManagedEnvironments": "cae-",
"appContainerApps": "ca-",
"authorizationPolicyDefinitions": "policy-",
"automationAutomationAccounts": "aa-",
"blueprintBlueprints": "bp-",
"blueprintBlueprintsArtifacts": "bpa-",
@skarllot
skarllot / windows-ntp.ps1
Created June 6, 2025 13:13
Synchronize Windows clock with NTP server
Get-TimeZone
w32tm /config /manualpeerlist:"pool.ntp.br" /syncfromflags:manual /reliable:YES /update
Restart-Service w32time
w32tm /resync
w32tm /query /peers
w32tm /query /status
@skarllot
skarllot / bash.cmd
Created April 27, 2025 19:46
Gitlab runner using Bash shell on Windows
@"C:\Program Files\Git\usr\bin\bash.exe" -l
@skarllot
skarllot / base64file.ps1
Created April 14, 2025 21:02
Convert binary file to base-64 using Powershell
$filePath = "C:\path\to\your\file.txt"
$outputPath = "C:\path\to\output\encodedFile.txt"
# Read the file content as bytes
$fileContent = [System.IO.File]::ReadAllBytes($filePath)
# Convert the byte array to a Base64 string
$base64String = [Convert]::ToBase64String($fileContent)
# Output the Base64 string to a new file
@skarllot
skarllot / GenerationDepthBehavior.cs
Created April 10, 2025 15:59
Control the depth when building fixture instances using AutoFixture
using System.Collections;
using AutoFixture.Kernel;
public class GenerationDepthBehavior : ISpecimenBuilderTransformation
{
private const int DefaultGenerationDepth = 1;
private readonly int _generationDepth;
public GenerationDepthBehavior(int generationDepth = DefaultGenerationDepth)
{
@skarllot
skarllot / MockLogger.Moq.cs
Last active June 17, 2025 19:03
Mocking ILogger
using Microsoft.Extensions.Logging;
using Moq;
public static class MockLogger
{
public static Mock<ILogger<T>> Create<T>()
{
var mock = new Mock<ILogger<T>>();
mock.Setup(l => l.IsEnabled(It.IsAny<LogLevel>())).Returns(true);
mock.Setup(x => x.BeginScope(It.IsAny<It.IsAnyType>())).Returns(Mock.Of<IDisposable>());
@skarllot
skarllot / CreateArchive.ps1
Created April 4, 2025 19:49
Create archive ignoring folders using 7-Zip
& 'C:\Program Files\7-Zip\7z.exe' a dest.zip . -r "-x!.git" "-x!.terraform"
& 'C:\Program Files\7-Zip\7z.exe' a dest.zip MyFolder\ -r -x!bin -x!obj
@skarllot
skarllot / AutoFixtureExtensions.cs
Created April 2, 2025 12:17
Set custom value for init-only properties on AutoFixture
using System.Linq.Expressions;
using AutoFixture;
public static class AutoFixtureExtensions
{
public static FixtureCustomization<T> For<T>(this Fixture fixture) => new(fixture);
public class FixtureCustomization<T>(Fixture fixture)
{
public FixtureCustomization<T> With<TProp>(Expression<Func<T, TProp>> expr, TProp value)
@skarllot
skarllot / config.toml
Created March 1, 2025 23:28
Gitlab runner configuration using Powershell on Windows
concurrent = 5
check_interval = 0
connection_max_age = "15m0s"
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "gitlab-runner01"