Skip to content

Instantly share code, notes, and snippets.

@tatsumoto-ren
tatsumoto-ren / subs.md
Last active April 20, 2025 21:41
Japanese Subtitles
using System;
using System.Threading.Tasks;
namespace System.Collections.Concurrent
{
public static class ConcurrentDictionaryExtensions
{
/// <summary>
/// Provides an alternative to <see cref="ConcurrentDictionary{TKey, TValue}.GetOrAdd(TKey, Func{TKey, TValue})"/> that disposes values that implement <see cref="IDisposable"/>.
/// </summary>
@ErikEJ
ErikEJ / IQueryableExtensions.cs
Last active March 30, 2025 14:29
Replacement for EF Core .Contains, that avoids SQL Server plan cache pollution
using System.Linq.Expressions;
namespace Microsoft.EntityFrameworkCore
{
public static class IQueryableExtensions
{
public static IQueryable<TQuery> In<TKey, TQuery>(
this IQueryable<TQuery> queryable,
IEnumerable<TKey> values,
Expression<Func<TQuery, TKey>> keySelector)
@bymyslf
bymyslf / JsonPatchDocumentDiff.cs
Last active August 13, 2024 15:49
Creates a JsonPatchDocument (JSON Patch - RFC 6902) from comparing to C# objects
using Microsoft.AspNetCore.JsonPatch;
using Microsoft.AspNetCore.JsonPatch.Operations;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
//Based on this: https://blog.abodit.com/posts/2014-05-json-patch-c-implementation/
public static class JsonPatchDocumentDiff
{
namespace System.Collections.ObjectModel
{
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
@paulredmond
paulredmond / app.js
Last active September 26, 2020 15:03
Example Vue.js mixins for time
import dateMixin from './mixins/date';
// Globally
Vue.mixin(dateMixin);
@alexhayes
alexhayes / pyenv+direnv on OSX.md
Last active February 18, 2025 07:28
Awesomely easy virtualenvs on OSX using pyenv and direnv

Awesomely easy virtualenvs on OSX using pyenv and direnv

Never forget to activate that virtualenv or set that environment variable ever again...

Install

  1. Install pyenv

     brew install pyenv
    
@bradphelan
bradphelan / Maybe.cs
Created January 25, 2017 06:47
Implementation of ValidatingReactiveObject and ancillary files
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Weingartner.Lens
{
@Neccta
Neccta / gist:5b9bd2eeed29f11f5c2b
Created November 2, 2015 18:25
Returns MahApps Metro Windows for Prism 6.0 Dialogs
using System;
using System.Windows;
using MahApps.Metro.Controls;
using Prism.Interactivity.InteractionRequest;
using Prism.Interactivity;
using Demo.Desktop.Views.Dialogs;
/*
You will need to create your own default windows, you can copy the Prism default windows from
https://github.com/PrismLibrary/Prism/tree/master/Source/Wpf/Prism.Wpf/Interactivity/DefaultPopupWindows
@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;