Skip to content

Instantly share code, notes, and snippets.

View iknowcodesoup's full-sized avatar
🖖
⭐ ⭐ ⭐ ⭐ ⭐

Jeff Holcombe iknowcodesoup

🖖
⭐ ⭐ ⭐ ⭐ ⭐
View GitHub Profile
@iknowcodesoup
iknowcodesoup / ObjectActivator.cs
Created October 12, 2018 02:04
dont-use-activator-createinstance-or-constructorinfo-invoke-use-compiled-lambda-expressions
namespace SView.Global
{
using System;
using System.Linq.Expressions;
using System.Reflection;
/// <summary>
/// https://vagifabilov.wordpress.com/2010/04/02/dont-use-activator-createinstance-or-constructorinfo-invoke-use-compiled-lambda-expressions/
/// </summary>
public class Activator
@iknowcodesoup
iknowcodesoup / sample_subject.cs
Created November 10, 2018 18:56
Observable subject -
/* Use with caution! http://davesexton.com/blog/post/To-Use-Subject-Or-Not-To-Use-Subject.aspx */
public class SomeClass {
private readonly Subject<int> triggerableObservable =
new Subject<int>();
public IObservable<int> TriggeredObservable => triggerableObservable.AsObservable();
private IDisposable subscription;
public SomeClass()
@iknowcodesoup
iknowcodesoup / FeatureClassNameTests.cs
Last active August 6, 2020 18:09
This is a non-tested sample of how to use TheoryData to create a unit testing setup using stubs / mocks. Have been using it for years with much success. Not sure of the original article but this one is the first hit: https://andrewlock.net/creating-strongly-typed-xunit-theory-test-data-with-theorydata/
using System;
using Moq;
using Refit;
using Xunit;
namespace Some.Kind.Of.Space
{
[Collection("Feature Name")]
[Trait("Feature Aspect", "Classification")]
public class FeatureClassNameTests
@iknowcodesoup
iknowcodesoup / StringExtentions.cs
Last active October 11, 2019 13:05
Some common extensions used over the years in some revision or another
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
namespace Extensions
{
public static class StringExtensions
{
private static readonly Regex _keyRegex = new Regex("{([^{}:]+)(?::([^{}]+))?}", RegexOptions.Compiled);
@iknowcodesoup
iknowcodesoup / MockHttpMessageHandler.cs
Created August 3, 2022 18:38
MockHttpMessageHandler
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace Namespace123
{
public class MockHttpMessageHandler : HttpMessageHandler
{
private readonly HttpResponseMessage? message;
@iknowcodesoup
iknowcodesoup / PlatformHelper.cs
Last active December 15, 2025 13:25
Windows Fully-Transparent System Backdrop (no-blur)
/*
* Copyright (c) 2025 CodeSoupCafe LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@iknowcodesoup
iknowcodesoup / gist:28980b70f5d6a41d5dcfd0ff84749f45
Created December 17, 2025 21:36
UUID/GUID Performance in PostgreSQL with C#
## UUID/GUID Performance in PostgreSQL with C#
The primary performance challenge with UUIDs as primary keys stems from **index fragmentation** caused by their random nature. This impacts both write (INSERT) and read performance (JOINs, lookups).
### Comparison Table
| Feature | Random UUID (v4 / C# `Guid.NewGuid()`) | Time-Based UUID (v7 / Sequential) | Auto-incrementing Integer (`int` / `bigint`) |
| --- | --- | --- | --- |
| **Indexing** | High fragmentation, random disk I/O | Low fragmentation, sequential disk I/O | Very efficient, sequential data storage |
| **Write Speed** | Slower due to page splits in B-tree indexes | Significantly faster inserts than v4 | Fastest write performance |