Skip to content

Instantly share code, notes, and snippets.

View nesterenko-kv's full-sized avatar
🇺🇦
Glory to Ukraine!

Kostiantyn Nesterenko nesterenko-kv

🇺🇦
Glory to Ukraine!
View GitHub Profile
@davidfowl
davidfowl / .NET6Migration.md
Last active April 11, 2024 02:02
.NET 6 ASP.NET Core Migration
@ErikEJ
ErikEJ / IQueryableExtensions.cs
Last active February 29, 2024 12:16
Replacement for EF Core .Contains, that avoids SQL Server plan cache pollution
using System.Linq.Expressions;
namespace Microsoft.EntityFrameworkCore
{
public static class IQueryableExtensions
{
public static IQueryable<TQuery> In<TKey, TQuery>(
this IQueryable<TQuery> queryable,
IEnumerable<TKey> values,
Expression<Func<TQuery, TKey>> keySelector)
@vanbukin
vanbukin / HttpCallException.cs
Last active September 6, 2019 06:50
HttpExtensinos
using System;
namespace Infrastructure.ApiClients.Http
{
public class HttpCallException : Exception
{
public HttpCallException(int? statusCode, string message) : base(message)
{
StatusCode = statusCode;
}
@thiagomajesk
thiagomajesk / AutoFacModule.cs
Last active August 30, 2023 16:47
Generic Handlers & Commands for MediatR (+ AutoFac config)
public class GenericHandlersModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<CreateCommandHandler<Foo, CreateFooCommand>>().As<IRequestHandler<CreateFooCommand, bool>>();
builder.RegisterType<DeleteCommandHandler<Foo, DeleteFooCommand>>().As<IRequestHandler<DeleteFooCommand, bool>>();
builder.RegisterType<ListQueryHandler<Foo, ListFooQuery>>().As<IRequestHandler<ListFooQuery, IEnumerable<Foo>>>();
builder.RegisterType<UpdateCommandHandler<Foo, UpdateFooCommand>>().As<IRequestHandler<UpdateFooCommand, bool>>();
}
}
@dannyc02
dannyc02 / gist:6d42b90154d8478dc6fd
Created February 18, 2016 15:51
CQRS - generic handlers
using FluentAssertions;
using MediatR;
using NUnit.Framework;
using StructureMap.Graph;
using System;
using System.IO;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using StructureMap;
using StructureMap.Graph.Scanning;
@nickrussler
nickrussler / gist:7527851
Created November 18, 2013 13:39
Convert Date String to/from ISO 8601 respecting UTC in Java
public static String toISO8601UTC(Date date) {
TimeZone tz = TimeZone.getTimeZone("UTC");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
df.setTimeZone(tz);
return df.format(date);
}
public static Date fromISO8601UTC(String dateStr) {
TimeZone tz = TimeZone.getTimeZone("UTC");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");