Skip to content

Instantly share code, notes, and snippets.

View pmunin's full-sized avatar

Philipp Munin pmunin

View GitHub Profile
@pmunin
pmunin / ConcurrentLockDictionary.cs
Last active August 6, 2019 20:20
ReadWriteLockableValue.cs
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
namespace ConcurrentLocking
{
public class ConcurrentLockDictionary<TKey>
{
public class KeyLock
@pmunin
pmunin / EquatableExtensions.cs
Last active September 6, 2018 14:06
C# Fluent Equality Comparing
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Pmunin.Gists
{
public static class EquatableExtensions
{
@pmunin
pmunin / react-subscribe.js
Last active March 21, 2018 22:19
React Component allows to subscribe to events on mounting and unsubscribe those events on unmounting
import React from 'react'
export class Subscribe extends React.Component
{
state={
//subscriptions:[],
childrenParams:[]
}
render(){
var subscribeToItems = this.props.to instanceof Array?this.props.to : [this.props.to]
@pmunin
pmunin / js-import-all-subfolders.js
Last active March 21, 2018 16:35
Javascript import all modules of 1st level subfolders (Webpack)
//gist url: https://gist.github.com/pmunin/ae8d24d68f239528adf73177265fa838
var context = require.context('./', true, /(\.\/)[^/]+(\/)$/);
//regex to get all 1st level subfolders paths (e.g.: "./subFolder/", but not "./subFolder/subFolder/")
const subModules = {}
context.keys().forEach((filename)=>{ //e.g.: ./subFolder/
const subModule = context(filename); //same as: import * as subModule from './subFolder/'
subModules[filename]=subModule;
});
@pmunin
pmunin / vscode tasks.json
Last active August 14, 2017 02:41
vscode problemMatcher for webpack + ts-loader + tslint-loader
// Latest version here: https://gist.github.com/pmunin/8411f9772f13b7c4d3b8c39d03832760
{
"version": "2.0.0",
"tasks": [
{
"taskName": "webpack",
"command": "webpack",
"type": "shell",
"args": [
"--display-modules"
@pmunin
pmunin / CompareSetsExtensions.cs
Last active April 2, 2019 19:46
CompareSets extensions, IEnumerable<T>.CompareToSet, FullOuterJoin extension
using System;
using System.Collections.Generic;
using System.Linq;
namespace CompareSetsExtensions
{
public static class CompareSetsExtensions
{
public static IEnumerable<TResult> FullOuterJoin<TLeft, TRight, TKey, TResult>(
IEnumerable<TLeft> left,
@pmunin
pmunin / GraphAggregateTests.cs
Last active May 15, 2017 00:59
GraphAggregateUtils - Allows to aggregate node values of acyclic directed graphs, without double counting shared children nodes
using DictionaryUtils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TestGraphUtils;
using Xunit;
namespace GraphAggregateUtils
@pmunin
pmunin / !readme.md
Last active April 17, 2017 18:53
Services Utils - automatic registration using AutoFac as dependency

IoC wraps Autofac for using dynamic services

@pmunin
pmunin / WeakDelegate.cs
Created March 26, 2017 05:00
WeakDelegate (weak event handling)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace WeakDelegates
{
@pmunin
pmunin / Debouncer.cs
Last active December 20, 2022 02:03
Action Debouncer for C#
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Timers;
namespace DebounceUtils
{
/// <summary>
/// Event debouncer helps to prevent calling the same event handler too often (like mark Dirty or Invalidate)