Skip to content

Instantly share code, notes, and snippets.

View cajuncoding's full-sized avatar
💭
Released RepoDb.SqlServer.PagingOperations for Cursor Paging w/ SQL Server

Brandon cajuncoding

💭
Released RepoDb.SqlServer.PagingOperations for Cursor Paging w/ SQL Server
View GitHub Profile
@cajuncoding
cajuncoding / FlurlDownloadAsAsyncEnumerableExtensions.cs
Last active July 17, 2024 02:17
Flurl Extensions for Downloading Binary Data for easy Deferred streaming as AsyncEnumerable streams.
//WIP: This is an extension method for Flurl to download a Binary file direcctly into an AsyncEnumerable that that
// can then be iterated with deferred execution for streaming binary data without downloading all data into Memory OR
// needing to store in an intermediate location.
//TODO:
// - Implement IAsyncEnumerable wrapper for the Stream Reading which can then be easily chunked via Linq just as it currently is...
// - This method may run a quick HTTP GET for headers Only to check and confirm existence, and then return an AsynEnumerable wrapper with an internal Delegate that creates the Stream
// reads the bytes in buffer/chunk sizes until Zero bytes are read; this would occur inside the GetEnumerator() call...
// - Develop this as an Open Source (e.g. Gist) Flurl Extension method for Re-use and sharing!
// - Reference Flurl's DownloadFileAsync for getting a true Async stream (would happen in the Delegate when IAsyncEnumerable.GetEnumerator() is called...
@cajuncoding
cajuncoding / PublicGistLicense.txt
Created June 3, 2024 17:59
Default MIT License for all Public Gists shared in this repository by @cajuncoding
Unless specifically noted in the Gist itself, all Public Gists shared in this repository by @CajunCoding may be used
according to MIT Licensing agreement as follows:
Copyright 2024 @CajunCoding/BBernard
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:
@cajuncoding
cajuncoding / SystemTextJsonNodeMergeExtensions.cs
Last active July 12, 2024 04:36
Simple Merge process for JsonNode using System.Text.Json
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Nodes;
namespace CajunCoding
{
public static class SystemTextJsonMergeExtensions
{
@cajuncoding
cajuncoding / RegionInfoFinder.cs
Last active May 21, 2024 20:17
Simple helper to find and convert RegionInfo details using two or three letter Country Codes
using System;
using System.Globalization;
using System.Linq;
namespace CajunCoding
{
/// <summary>
/// Simple helper to find and convert RegionInfo details using two or three letter Country Codes.
/// NOTE: Inspired but fully rewritten from the Gist: https://gist.github.com/BenjaminAdams/277928c7ad291ea7aea8
/// </summary>
@cajuncoding
cajuncoding / AzureFunctionsInProcessCompressionExtensions.cs
Last active May 23, 2024 04:05
Enable Response Compression (Gzip, Brotli, Deflate) in Azure Functions In Process (Linux App Deployment)
using System;
using System.IO.Compression;
using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
namespace AzureFunctionsInProcessCompressionExtensions
{
/// <summary>
@cajuncoding
cajuncoding / IEnumerableChunkCustomExtensions.cs
Created September 22, 2023 05:51
Transform any IEnumerable set into an IAsyncEnumerable with Async Transformation in Chunks (e.g. Async stream REST/GraphQL API results in Chunks)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Channels;
using System.Threading;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
namespace CajunCoding.Async
{
@cajuncoding
cajuncoding / AsyncLazy.cs
Last active September 21, 2023 01:36
Ultra lightweight AsyncLazy<T> Wrapper for Lazy<T>
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace CajunCoding
{
/// <summary>
/// Greatly Simplified lightweight wrapper class to support improved code readability and management of
/// Async methods used in combination with Lazy&lt;T&gt; wrapper for thread safe lazy loading from a Func value factory!
/// Based on Original blogs here:
/// https://blogs.msdn.microsoft.com/pfxteam/2011/01/15/asynclazyt/
@cajuncoding
cajuncoding / LocalSettingsEnvironmentReader.cs
Last active September 14, 2023 20:35
Load the local.settings.json into Environment Variables (Very Helpful for Testing AzureFunctions)
using System;
using System.IO;
using Newtonsoft.Json.Linq;
namespace CajunCoding.Configuration
{
public static class LocalSettingsEnvironmentReader
{
/// <summary>
/// BBernard
@cajuncoding
cajuncoding / AzFuncGraphQLConsoleLoggingEventListener.cs
Last active February 2, 2024 05:06
Azure Functions Console/Stream Logger for Hot Chocolate GraphQL v13
using HotChocolate.Execution.Instrumentation;
using HotChocolate.Execution;
using System;
using System.Diagnostics;
using System.Linq;
using Aeg.Common.CSharp.CustomExtensions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using GraphQL.HotChocolate.AzureFunctions.Authorization;
using System.Security.Claims;
@cajuncoding
cajuncoding / AzFuncGraphQLRoleAuthorizationFramework.cs
Last active October 30, 2023 19:50
Simplified Role based Authorization for HotChocolate GraphQL v13 in Azure Functions
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Threading.Tasks;
using HotChocolate;
using HotChocolate.Resolvers;
using HotChocolate.Data.Projections.Context;