Skip to content

Instantly share code, notes, and snippets.

@saulm314
saulm314 / Wrap.cs
Created October 20, 2025 22:19
Struct Wrap
// MIT License: https://gist.github.com/saulm314/bf4c6cd9e4a9b045b52ad123a80a5c39
public readonly record struct Wrap<T>(T Value)
{
public static implicit operator Wrap<T>(T value) => new(value);
public static implicit operator Wrap<T>?(T? value) => value is null ? null : new(value);
}
@saulm314
saulm314 / JsonContentException.cs
Last active November 15, 2025 06:03
NewtonSoft.Json Utils
// MIT License: https://gist.github.com/saulm314/91f0d83ce1a931b5086169e17b6e4eb0
using System;
public abstract class JsonContentException(string? message) : Exception(message)
{
public class Empty() : JsonContentException("base JSON object { } not found");
public class PropertyNotFound(string path, string propertyName)
: JsonContentException($"JSON property {path.Dereference(propertyName)} not found".AddPathWarning())
@saulm314
saulm314 / PngCompressor.cs
Last active September 8, 2025 02:10
PNG compressor
// > dotnet run PngBackgroundRemover.cs
// requires .NET SDK 10+
// MIT License: https://gist.github.com/saulm314/11e21fea1297693cd349734bc63c7a0a
#:package BigGustave@1.0.6
using BigGustave;
// configure these constants as required
const string InputPngPath = "string-base.png";
@saulm314
saulm314 / PngBackgroundRemover.cs
Last active September 8, 2025 01:43
PNG Background Remover
// > dotnet run PngBackgroundRemover.cs
// requires .NET SDK 10+
// MIT License: https://gist.github.com/saulm314/985a47c7683d0cd9429f8a2938457562
#:package BigGustave@1.0.6
using BigGustave;
// configure these constants as required
const string InputPngPath = "string-base.png";