Skip to content

Instantly share code, notes, and snippets.

View marcominerva's full-sized avatar
🏠
Working from home

Marco Minerva marcominerva

🏠
Working from home
View GitHub Profile
@marcominerva
marcominerva / .editorconfig
Last active March 26, 2024 13:36
.editorconfig
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true
[*]
#### Core EditorConfig Options ####
# Indentation and spacing
indent_size = 4
indent_style = space
@marcominerva
marcominerva / Slugify
Last active November 15, 2023 15:25
Slugify routes
builder.Services.AddControllers(options =>
{
options.Conventions.Add(new RouteTokenTransformerConvention(new SlugifyParameterTransformer()));
});
public class SlugifyParameterTransformer : IOutboundParameterTransformer
{
public string? TransformOutbound(object? value)
=> value is null ? null
: Regex.Replace(value.ToString()!, "([a-z])([A-Z])", "$1-$2", RegexOptions.CultureInvariant).ToLowerInvariant();
using System.Diagnostics;
using FluentValidation;
using Microsoft.AspNetCore.Mvc;
namespace MinimalApi.Filters;
public class ValidatorFilter<T>(IValidator<T> validator) : IEndpointFilter where T : class
{
public async ValueTask<object?> InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next)
{
using System.Diagnostics;
using FluentValidation;
using Microsoft.AspNetCore.Mvc;
using OperationResults.AspNetCore.Http;
namespace MinimalApi.Filters;
public class ValidatorFilter<T>(IValidator<T> validator, OperationResultOptions options) : IEndpointFilter where T : class
{
public async ValueTask<object?> InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next)
@marcominerva
marcominerva / Directory.Build.proprs
Created April 8, 2024 13:20
Reduce path in Stack Trace
<Project>
<PropertyGroup>
<PathMap>$(MSBuildThisFileDirectory)=./</PathMap>
</PropertyGroup>
</Project>
@marcominerva
marcominerva / docker-compose.yml
Created June 12, 2024 14:24
Create a PostgreSQL container with pgAdmin
version: "3.8"
services:
db:
image: postgres
container_name: local_pgdb
restart: unless-stopped
ports:
- "5432:5432"
environment:
POSTGRES_USER: pi
@marcominerva
marcominerva / MistralOcrMarkdown.cs
Last active May 8, 2025 21:52
Mistral OCR - Get markdown from PDF
using System.Net.Http.Json;
using System.Text.Json;
using System.Text.Json.Serialization;
var endpoint = "https://<endpoint>.<region>.models.ai.azure.com/";
var apiKey = "";
var inputFilePath = @""; // The path of the source PDF
var outputFilePath = @""; // The path of the destination Markdown file