Skip to content

Instantly share code, notes, and snippets.

View wellingtonjhn's full-sized avatar

Wellington Nascimento wellingtonjhn

View GitHub Profile
@wellingtonjhn
wellingtonjhn / WaitUtils.cs
Created November 5, 2025 16:15
Wait until some action is done or until timeout is reached.
public static class WaitUtils
{
/// <summary>
/// Wait until some action is done or until timeout is reached.
/// <code>
/// var waitResult = await WaitUtils.WaitUntilAsync(
/// async () =>
/// {
/// // some actions
/// var result = await db.FirstOrDefault(q=> q.Status == Status.Success);
/db
/plugins
/uploads
/logs
@wellingtonjhn
wellingtonjhn / DeleteObjBinFolders.ps1
Created January 12, 2021 12:47
Delete Obj and Bin folders recursively
# PowerShell script that recursively deletes all 'bin' and 'obj' (or any other specified) folders inside current folder
$CurrentPath = (Get-Location -PSProvider FileSystem).ProviderPath
# recursively get all folders matching given includes, except ignored folders
$FoldersToRemove = Get-ChildItem .\ -include bin,obj -Recurse | where {$_ -notmatch '_tools' -and $_ -notmatch '_build'} | foreach {$_.fullname}
# recursively get all folders matching given includes
$AllFolders = Get-ChildItem .\ -include bin,obj -Recurse | foreach {$_.fullname}
@wellingtonjhn
wellingtonjhn / sonarqube-docker-compose.yml
Created March 30, 2020 17:23 — forked from Warchant/sonarqube-docker-compose.yml
docker-compose file to setup production-ready sonarqube
version: "3"
services:
sonarqube:
image: sonarqube
expose:
- 9000
ports:
- "127.0.0.1:9000:9000"
networks:
@wellingtonjhn
wellingtonjhn / LinqExtensions.cs
Created February 25, 2020 17:43 — forked from johnazariah/LinqExtensions.cs
Maybe Monad in C#
public static partial class LinqExtensions
{
public static Maybe<C> SelectMany<A, B, C>(this Maybe<A> ma, Func<A, Maybe<B>> f, Func<A, B, C> select) => ma.Bind(a => f(a).Map(b => select(a, b)));
}
public class Startup
{
// ...
public void ConfigureServices(IServiceCollection services)
{
// ...
services.AddScoped<NotificationContext>();
@wellingtonjhn
wellingtonjhn / 3.Post.ProblemDetails.ProblemDetailsExtensions.cs
Last active January 13, 2019 22:24
Problem Details Model State Behavior
public static class ProblemDetailsExtensions
{
public static IServiceCollection ConfigureProblemDetailsModelState(this IServiceCollection services)
{
return services.Configure<ApiBehaviorOptions>(options =>
{
options.InvalidModelStateResponseFactory = context =>
{
var problemDetails = new ValidationProblemDetails(context.ModelState)
{
@wellingtonjhn
wellingtonjhn / 1.Post.ProblemDetails.ProblemDetailsExtensions.cs
Last active November 5, 2022 15:24
Problem Details Exception Handler
public static class ProblemDetailsExtensions
{
public static void UseProblemDetailsExceptionHandler(this IApplicationBuilder app, ILoggerFactory loggerFactory)
{
app.UseExceptionHandler(builder =>
{
builder.Run(async context =>
{
var exceptionHandlerFeature = context.Features.Get<IExceptionHandlerFeature>();
public class NotificationFilter : IAsyncResultFilter
{
private readonly NotificationContext _notificationContext;
public NotificationFilter(NotificationContext notificationContext)
{
_notificationContext = notificationContext;
}
public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
@wellingtonjhn
wellingtonjhn / 8.Post.DomainNotification.CustomersController.cs
Last active September 24, 2019 21:41
Controller with MediatR command
[Route("api/[controller]")]
[ApiController]
public class CustomersController : ControllerBase
{
private readonly IMediator _mediator;
public CustomersController(IMediator mediator)
{
_mediator = mediator;
}