Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View pmunin's full-sized avatar

Philipp Munin pmunin

View GitHub Profile
@pmunin
pmunin / index.js
Last active March 29, 2022 02:45 — forked from zkat/index.js
npx is cool
#!/usr/bin/env node
console.log('yay gist')
@pmunin
pmunin / convert-2jpg.bat
Last active December 20, 2022 15:17
Script allowing to Sort double sided scanned files. Requires Node.js 10+ to be installed and convert files (pdj->jpg)
node %~dp0convert-2jpg.js %*
pause
@pmunin
pmunin / DictionaryDynamicWrapper.cs
Created September 3, 2019 18:39
Dynamic wrapper for Dictonary
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
public class DynamicDictionaryWrapper<TValue> : DynamicObject
{
/// <summary>
/// Instance of object passed in
@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
@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 / 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 / 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 / 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 / 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
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Caching{
[Table(DbCacheService.TableName)]
public class CachedValue
{
[Key]