Skip to content

Instantly share code, notes, and snippets.

public class PredicateEqualityComparer<T> : EqualityComparer<T>
{
private readonly Func<T, T, bool> predicate;
public PredicateEqualityComparer(Func<T, T, bool> predicate)
{
this.predicate = predicate;
}
public override bool Equals(T x, T y)
public static class LinqExtensions
{
public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> source, Func<TSource, TSource, bool> predicate)
{
return source.Distinct(new PredicateEqualityComparer<TSource>(predicate));
}
public static IEnumerable<TSource> OrderBy<TSource>(this IEnumerable<TSource> source, Func<TSource, TSource, bool> predicate)
{
return source.OrderBy(new PredicateEqualityComparer<TSource>(predicate));
@alfredodev
alfredodev / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Connect es el único evento pensado para inspirar y motivar a la Élite del Desarrollo
undercover jedi
Javascript, only the good parts
Motivación y lecciones de vida de los grandes
y mucho frikismo. El evento nerd del año
Un evento para TODOS aquellos para quienes programar es una pasión, una forma de vivir.
guiados por los Master Jedis y una enseñanza práctica 100% llena de mucho, mucho código.
Tras esta Agogé, los padawan regresan de Dagobah como Lead Developers de grandes proyectos, CTOs de startups punteras e incluso managers en Silicon Valley.
que quieran disfrutar de unas horas de frikismo extremo

Avoid annotation-based dependency injection, make dependencies explicit and don't mix ioc configs with your app code.

Answer to: https://twitter.com/alexjoverm/status/895273462264213509

For starters, it's usualy unwise to couple your code to frameworks, and your are doing it in two ways here.

You are coupling your code to the framework by importing and using it in almost ALL the files. Now if you want to change the IoC library you will need to change all your files.

services.TryAddScoped<IUserValidator<ApplicationUser>, UserValidator<ApplicationUser>>();
services.TryAddScoped<IPasswordValidator<ApplicationUser>, PasswordValidator<ApplicationUser>>();
services.TryAddScoped<IPasswordHasher<ApplicationUser>, PasswordHasher<ApplicationUser>>();
services.TryAddScoped<ILookupNormalizer, UpperInvariantLookupNormalizer>();
services.TryAddScoped<IRoleValidator<IdentityRole>, RoleValidator<IdentityRole>>();
services.TryAddScoped<IdentityErrorDescriber>();
services.TryAddScoped<ISecurityStampValidator, SecurityStampValidator<ApplicationUser>>();
services.TryAddScoped<ITwoFactorSecurityStampValidator, TwoFactorSecurityStampValidator<ApplicationUser>>();
services.TryAddScoped<IUserClaimsPrincipalFactory<ApplicationUser>, UserClaimsPrincipalFactory<ApplicationUser, IdentityRole>>();
@alfredodev
alfredodev / Awsome scbcn18 talks
Created August 21, 2018 19:58
Provisional talks for scbcn18
- Case Study: Practical tools and strategies for tackling legacy practices and legacy systems in a fast-growing startup.
- A cowgirl journey
- Acercándonos a la Programación Funcional 🦄 a través de la Arquitectura Hexagonal 🎯
- Automatiza y vencerás!
- Calisthenics - Smells - SOLID - Cohesion / Cupling connecting the dots
- Clean Code, Clean Tests, Clean Life
- Communication Antipatterns and where to find them
- Continuous Deployment With Jenkins X And Kubernetes
- Creating a web browser game with websockets
- Culture. What is that? Is it edible?
set kataname = %1
dotnet new sln %kataname%
md src
dotnet new classlib %kataname% -o src
dotnet sln add src\%kataname%
md tests
dotnet new xunit %kataname%.Tests -o tests
dotnet sln add tests\%kataname%.Tests
kataname=$1
dotnet new sln -n $kataname
mkdir src
dotnet new classlib -n $kataname -o src
dotnet sln add src/$kataname.csproj
mkdir tests
dotnet new xunit -n $kataname.Tests -o tests
dotnet sln add tests/$kataname.Tests.csproj

The Roman Numeral Kata

We would like to be able to convert Arabic numbers into their Roman numeral equivalents. In the interest of simplicity, we'll only be dealing with numbers no greater than 50.

The Romans wrote their numbers using letters:

Number  Numeral
---------------
1       I       

5 V