Skip to content

Instantly share code, notes, and snippets.

View pmunin's full-sized avatar

Philipp Munin pmunin

View GitHub Profile
@pmunin
pmunin / angular-koWith.js
Created October 28, 2015 00:40
Analogy of KnockoutJs With directive for AngularJs
// Analogy of KnockoutJs With directive http://knockoutjs.com/documentation/with-binding.html
// Implementation is based on that one: http://stackoverflow.com/questions/17300814/the-with-binding-of-knockoutjs-in-angularjs
myAngularApp
.directive('koWith', function () {
return {
restrict: 'A',
scope: true,
controller: function ($scope, $attrs, $parse) {
var ScopePropertyDesc = function (prop) {
var self = this;
@pmunin
pmunin / LinkedListExtensions.cs
Last active January 12, 2016 03:49
Extension for working with LinkedList<T>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// Extensions for LinkedList, allowing to enumerate nodes.
/// Latest version is here: https://gist.github.com/pmunin/d8cb8b39513b33e31cae
/// </summary>
@pmunin
pmunin / DbContextQueryExtension.cs
Last active January 21, 2016 20:21
DbContextQueryExtension allows to query data from DbContext (EntityFramework 5+)
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.Entity;
using System.Data.Entity.Core.Objects;
using System.Data.Entity.Infrastructure;
using System.Linq;
@pmunin
pmunin / ReaderWriterLockByKey.cs
Last active January 22, 2016 01:14
ReaderWriterLockByKey - allows to apply thread safety and read/write/upgrade locking by key to any dictionary-like object. Internally it uses ConcurrentDictionary and ReaderWriterLock (not ReaderWriterLockerSlim yet). Does not need disposing, unlike ReaderWriterLockerSlim.
using System;
using System.Threading;
using System.Collections.Concurrent;
using System.Collections.Generic;
/// <summary>
/// Thread safe readWriteLocker by key
/// Latest version here: https://gist.github.com/pmunin/2e48f13dc8f6673752a2
/// ReaderWriterLockByKey - allows to apply thread safety and read/write/upgrade locking by key to any dictionary-like object.
/// Internally it uses ConcurrentDictionary and ReaderWriterLock (not ReaderWriterLockerSlim yet).
@pmunin
pmunin / AggregateManyExtensions.cs
Last active February 27, 2016 01:28
Aggregate several accumulators within one enumerator run
using System;
using System.Collections;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// IEnumerable extension that allows to aggregate multiple accumulators within single enumerator run
@pmunin
pmunin / ConfigFileContext.cs
Created March 22, 2016 14:51
.NET Tests .config loader
using System;
using System.Configuration;
using System.Linq;
using System.Reflection;
namespace {MyProject}_Tests
{
public abstract class ConfigFileContext : IDisposable
{
public static ConfigFileContext Change(string path)
@pmunin
pmunin / XNodeSerializationExtensions.cs
Created March 22, 2016 20:28
.NET Xml Serialization Extensions
using System;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
public static class XNodeSerializationExtensions
{
static string GetXmlRootName(XNode xml)
{
@pmunin
pmunin / WebAppHostHelper.cs
Last active April 11, 2016 15:25
helpers for ASP.NET, ASP.NET MVC app server side testing
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Hosting;
@pmunin
pmunin / ObjectAnnotation.cs
Created April 25, 2016 15:27
Allows to create annotation (dynamically linked objects/wrappers)
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace ObjectAnnotation
{
@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