Skip to content

Instantly share code, notes, and snippets.

View pmunin's full-sized avatar
🏠
Working from home

Philipp Munin pmunin

🏠
Working from home
View GitHub Profile
@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 / 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 / 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
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Caching{
[Table(DbCacheService.TableName)]
public class CachedValue
{
[Key]
@pmunin
pmunin / config-MacOS.bat
Created December 8, 2018 16:17
Installing macOs on VirtualBox for Windows
cd C:\Program Files\Oracle\VirtualBox
VBoxManage modifyvm "MacOS" --cpuid-set 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "MacOS" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "MacOS" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "MacOS" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "MacOS" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "MacOS" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
VBoxManage setextradata "MacOS" VBoxInternal2/EfiGopMode 4
pause
@pmunin
pmunin / FormattableStringExtensions.cs
Created March 4, 2019 21:31
C# FormattableStringExtensions.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
public static class FormattableStringExtensions
{
public static FormattableString AsFormattable(this string str) {
return FormattableStringFactory.Create(str);
@pmunin
pmunin / AsyncLock.cs
Created March 22, 2019 19:30
AsyncLock
using System;
using System.Threading;
using System.Threading.Tasks;
namespace AsyncLockExtensions
{
/// <summary>
/// Virtual critical section for async function.
/// Monitor.Enter/Exit and lock{} does not work for async methods and cause deadlocks and exceptions. AsyncLock solves these issues. Implementation copied from Microsoft.EntityFrameworkCore.Internal.AsyncLock (.nuget\packages\microsoft.entityframeworkcore\2.1.4\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll)
/// <seealso cref="https://github.com/neosmart/AsyncLock"/>
@pmunin
pmunin / EnumerablePartitionExtension.cs
Last active September 19, 2020 02:29
C# Enumerable extension for Partitioning also know as Pagination- allows to split enumerable into partitions of specified max size
using System.Linq;
public static class EnumerablePartitionExtensions{
/// <summary>
/// Generate lazy partitions for enumerable
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="items">source items to create partitions from</param>
@pmunin
pmunin / FormattableStringExtensions.cs
Last active May 29, 2019 00:42
FormattableStringExtensions C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace FormattableStrings
{
public static class FormattableStringExtensions
{
@pmunin
pmunin / WeakMapExtensions.cs
Created August 5, 2019 16:52
WeakMapExtensions
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace WeakMap
{
/// <summary>
/// Allows to link additional properties to any objects by weakly linking a dictionary for any object.
/// Weakly means the dictionary exists in memory only as long as object it linked to is still stored in memory