Skip to content

Instantly share code, notes, and snippets.

View Shazwazza's full-sized avatar

Shannon Deminick Shazwazza

View GitHub Profile
@Shazwazza
Shazwazza / CultureIsoCodeFieldNameMatchExpression.cs
Last active May 7, 2021 17:36
ExamineX Dynamic Language Analyzer Value Type
/// <summary>
/// Borrowed From Umbraco Source. Matches a culture iso name suffix
/// </summary>
/// <remarks>
/// myFieldName_en-us will match the "en-us"
/// </remarks>
public static readonly Regex CultureIsoCodeFieldNameMatchExpression = new Regex("^([_\\w]+)_([a-z]{2}-[a-z0-9]{2,4})$", RegexOptions.Compiled);
@Shazwazza
Shazwazza / FlowingExecutionContext-AsyncLocal.cs
Last active August 12, 2021 15:42
Flowing ExecutionContext
// These tests show the various ways to spawn child threads
// and in what scenarios the value in the AsyncLocal or
// logical CallContext will flow to the child threads.
// All of the below test results are identical if you
// use the old CallContext.LogicalSetData CallContext.LogicalGetData
void Main()
{
// Set the AsyncLocal value and we'll see where this flows
@Shazwazza
Shazwazza / IProductService.cs
Created September 26, 2019 13:43
Example of creating a custom lucene index in Umbraco 8
/// <summary>
/// Custom service to work with products
/// </summary>
public interface IProductService
{
IEnumerable<Product> GetAll();
}
@Shazwazza
Shazwazza / CheckAndFixPaths.sql
Last active November 16, 2022 11:05
Checks and fixes invalid path data in umbracoNode table
-- NOTES:
-- The COMMIT TRANSACTION is commented out at the bottom.
-- Running this script as-is will produce a report of problems if any are found.
-- If no problems are found, nothing is reported.
-- To commit the changes, uncomment the COMMIT TRANSACTION and comment out ROLLBACK TRANSACTION.
-- Once committed, re-run the script and no errors should be detected.
-- This is a SQL port of the c# code: https://github.com/umbraco/Umbraco-CMS/pull/7907/files#diff-83e79f7101cd6797ca42ad8ed07f5835R480
-- By default is this execute for MEDIA but you should execute it for CONTENT too, to do that
-- see the SQL statement below that does this WHERE nodeObjectType = @mediaObjectType and change it
-- to WHERE nodeObjectType = @contentObjectType
@Shazwazza
Shazwazza / gist:7147978
Last active June 11, 2023 10:34
How to inspect assemblies before including them in your application with reflection
public class PackageBinaryInspector : MarshalByRefObject
{
/// <summary>
/// Entry point to call from your code
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="dllPath"></param>
/// <param name="errorReport"></param>
/// <returns></returns>
/// <remarks>