Skip to content

Instantly share code, notes, and snippets.

View kmorcinek's full-sized avatar

Krzysztof Morcinek kmorcinek

View GitHub Profile
@kmorcinek
kmorcinek / Either.cs
Created June 12, 2015 09:38
Either<TSuccess, TFailure>
public class Either<TSuccess, TFailure>
{
private readonly TSuccess _success;
private readonly TFailure _failure;
private readonly bool _isSuccessful;
public bool Succeeded
{
get
{
https://docs.python.org/3/tutorial/classes.html#class-objects
from functools import reduce
http://www.artima.com/weblogs/viewpost.jsp?thread=98196
list("python")
https://docs.python.org/3/howto/functional.html
line_list = [' line 1\n', 'line 2 \n']
@kmorcinek
kmorcinek / gist:46e02fbd2e29bfaf5bc5
Last active August 29, 2015 14:23
Autofixture stuff
http://stackoverflow.com/questions/10032535/can-autofixture-execute-a-delegate-at-object-creation-time?rq=1 :
fixture.Customize<MyClass>(c => c.Without(x => x.SomeWeirdText));
public static ObjectBuilder<User> BuildUser(this Fixture f)
{
return f.Build<User>().With(u => u.IsDeleted, false); // Probably you do not want code like this, explanation in above link.
}
http://megakemp.com/2013/04/16/general-purpose-customizations-with-autofixture/ :
CookbookAutoDataAttribute
@kmorcinek
kmorcinek / race for the galaxy
Last active August 29, 2015 14:23
race for the galaxy strategies
https://linnaeus.wordpress.com/2009/01/20/rftg-fundamentals-1/
sprawdz jaka taktyke twoj przeciwnik ma (develop, military, etc). Jesli jest przewidywalny mozesz liczyc ze zagrac np Build dla ciebie.
Zbyt czesto gram karte () z minus jeden do Develop, gdy gram na Budowę Światów to nie jest mi to potrzebne.
Taktyka na wszystkie startowe.
Utracona ziemia taktyka:
@kmorcinek
kmorcinek / slownik
Created July 9, 2015 12:40
Slownik angielsko polski
second to last - przed ostatni
public static class IQueryableExtensions
{
public static IOrderedQueryable<TSource> OrderBy<TSource, TKey>(
this IQueryable<TSource> source,
Expression<Func<TSource, TKey>> keySelector,
bool isAscending)
{
if (isAscending)
{
return source.OrderBy(keySelector);
@kmorcinek
kmorcinek / AutoMapperExtensions.cs
Last active April 7, 2016 21:17
AutoMapper convenient extensions for simple mapping
public static class AutoMapperExtensions
{
/// <summary>
/// Maps properties as ignored.
/// </summary>
public static IMappingExpression<TSource, TDestination> Ignore<TSource, TDestination>(
this IMappingExpression<TSource, TDestination> map,
Expression<Func<TDestination, object>> selector)
{
map.ForMember(selector, config => config.Ignore());
@kmorcinek
kmorcinek / NegativeLong
Last active September 21, 2015 19:24
Used for integration database tests, when we want to avoid Id clashes with current DB entities. It sets long value, but every time we retrieve it we get negative value.
/// <summary>
/// Class should be used only by AutoFixture. Used for integration database tests, when we want to avoid Id clashes with current DB entities.
/// It sets long value, but every time we retrieve it we get negative value.
/// <remarks>
/// Class should be used only by <see cref="Fixture"/>, either directly by Create() method or by <see cref="AutoDataAttribute"/>.
/// </remarks>
/// </summary>
/// <example>
/// This sample shows how to use the <see cref="NegativeLongId"/> class
/// <code>