This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Adapted from SO answer https://stackoverflow.com/a/40491640/915147 | |
/// </summary> | |
/// <typeparam name="TEntity"></typeparam> | |
public class AsyncQueryProvider<TEntity> : IAsyncQueryProvider | |
{ | |
private readonly IQueryProvider _inner; | |
internal AsyncQueryProvider(IQueryProvider inner) => _inner = inner; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<T> ConcatTwoOrderedArray<T>(IReadOnlyList<T> first, IReadOnlyList<T> second) | |
{ | |
dynamic dynamicFirst = first, dynamicSecond = second; | |
for (int i = 0, j = 0; i < first.Count || j < second.Count;) | |
{ | |
if (i < first.Count && (j >= second.Count || dynamicFirst[i] < dynamicSecond[j])) | |
yield return first[i++]; | |
else | |
yield return second[j++]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
public static class EnumeratorExtensions | |
{ | |
public static IEnumerable<T> TakeNextUntil<T>(this IEnumerator<T> enumerator, Predicate<T> predicate) | |
{ | |
while(enumerator.MoveNext()) | |
{ | |
var item = enumerator.Current; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
public static class ReflectionUtils | |
{ | |
public static MethodInfo GetMethod<TInput, TOutput>(Expression<Func<TInput, TOutput>> methodCallExpression) => GetMethodByLambdaExpression(methodCallExpression); | |
public static MethodInfo GetMethod<TInput>(Expression<Action<TInput>> methodCallExpression) => GetMethodByLambdaExpression(methodCallExpression); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const f = a => { | |
let max = 0; | |
const getLocalMax = a => { | |
let localMax = 0, maxJ = a[0].length -1; | |
const reset = i => { | |
const size = (i+1)*(maxJ+1); | |
if(size > localMax) | |
localMax = size; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
public class Program { | |
public static void Main() { | |
var matrices = new []{ | |
new [] { | |
"11011", | |
"01101", | |
"11110", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class Program { | |
public static void Main() { | |
var matrices = new []{ | |
new [] { | |
"00000", | |
"00000", | |
"00000", | |
"00000", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description: Boxstarter Script | |
# Author: Alex Ho | |
# | |
# Install boxstarter: | |
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force | |
# | |
# You might need to set: Set-ExecutionPolicy RemoteSigned | |
# | |
# Run this boxstarter by calling the following from an **elevated** command-prompt: | |
# start http://boxstarter.org/package/nr/url?<URL-TO-RAW-GIST> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
class QueueByStacks<T> | |
{ | |
private Stack<T> _inStack, _outStack; | |
public QueueByStacks() | |
{ | |
_inStack = new Stack<T>(); | |
_outStack = new Stack<T>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<PropertyInfo> GetPropertiesWithAttributes<T, TAttr>(this object obj) | |
{ | |
return GetPropertiesWithAttributes(obj, typeof(T), typeof(TAttr)); | |
} | |
public static IEnumerable<PropertyInfo> GetPropertiesWithAttributes(this object obj, Type type, Type attrType) | |
{ | |
return type.GetProperties() | |
.Where(x => x.GetCustomAttributes(true) | |
.Any(attr => attr.GetType() == attrType) |