Skip to content

Instantly share code, notes, and snippets.

View pmunin's full-sized avatar

Philipp Munin pmunin

View GitHub Profile
@pmunin
pmunin / EventAccumulator.cs
Created March 22, 2017 18:10
Event Accumulator class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace EventAccumulatorUtils
{
/// <summary>
@pmunin
pmunin / TestGraph.cs
Last active May 3, 2017 19:11
Useful for testing graph algorithms
//Latest version here: https://gist.github.com/1c20bc400beabef79f390a876758bb4e.git
using System;
using System.Collections.Generic;
using System.Linq;
namespace TestGraphUtils
{
/// <summary>
/// Useful graph builder for testing algorithms
/// </summary>
@pmunin
pmunin / ObsoleteAttributePlaceholders.cs
Last active April 11, 2017 17:01
Direct Graph Markup Language (DGML) utils
using System;
namespace System
{
internal class SerializableAttribute : Attribute
{
}
}
@pmunin
pmunin / MergeSortedEnumerables.cs
Last active May 15, 2017 05:38
Merge Sorted Enumerable
//Latest version is here: https://gist.github.com/1eef7d55a19593735b9ecc3fc6449626.git
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Collections;
using PriorityQueueUtils; //https://gist.github.com/affc23dd89950e67ece9ca3b19b9508a.git
namespace MergeSortedEnumerablesUtils
{
@pmunin
pmunin / CachingEnumerator.cs
Last active March 14, 2017 04:11
Caching enumerator, making sure source enumerator will be only iterated once
//latest version is here: https://gist.github.com/b1059488d17c52da5a732a100ba6e09f.git
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace CachingEnumeratorUtils
{
/// <summary>
/// Enumerable doing lazy caching of enumerator, to avoid generating items more than one time
@pmunin
pmunin / CartesianProduct.cs
Last active May 1, 2017 22:20
CartesianProduct extensions
//latest version is here: https://gist.github.com/7d99ff883fdf2ddfe968f6f9c57b1d4a.git
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PriorityQueueUtils; //from https://gist.github.com/affc23dd89950e67ece9ca3b19b9508a.git
using CachingEnumeratorUtils; //from https://gist.github.com/b1059488d17c52da5a732a100ba6e09f.git
@pmunin
pmunin / PriorityQueue.cs
Last active March 29, 2018 16:28
Simple .NET PriorityQueue based on SortedDictionary<TKey, Queue<TItem>> (BST) behind the scene
//Latest version is here: https://gist.github.com/affc23dd89950e67ece9ca3b19b9508a.git
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace PriorityQueueUtils
{
/// <summary>
/// Queue contract
@pmunin
pmunin / WebViewPageExtensions.cs
Last active October 19, 2016 21:02
ASP.NET MVC WebViewPageExtensions
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.WebPages;
using System.Linq;
public static class WebViewPageExtensions
{
/// <summary>
/// Functionality similar to the controller's TryUpdateModel() protected method
@pmunin
pmunin / method.snippet
Last active March 23, 2017 15:46
Visual Studio C# Snippets
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Method template</Title>
<Shortcut>method</Shortcut>
<Description>New method template</Description>
<Author>Philipp Munin</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
@pmunin
pmunin / Comparer.cs
Last active March 17, 2017 04:57
EqualityComparer helpers
//Latest version here: https://gist.github.com/b471ea36789d375069020030f600bd3e.git
using System;
using System.Collections.Generic;
namespace ComparerUtils
{
public static class Comparer
{
public static IComparer<T> From<T>(Comparison<T> compare)