Skip to content

Instantly share code, notes, and snippets.

@seankearney
seankearney / OutputMultipleFiles.tt
Last active May 1, 2018 13:23
This TDS Code Generation template is an example of how you can generate a multiple files that contains a single class in each.
<#@ template language="C#" hostSpecific="true" #>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="HedgehogDevelopment.SitecoreProject.VSIP.CodeGeneration.Models" #>
<#@ parameter name="Model" type="HedgehogDevelopment.SitecoreProject.VSIP.CodeGeneration.Models.SitecoreItem" #>
<#@ parameter name="DefaultNamespace" type="System.String" #>
<#
/************************************************************
@kamsar
kamsar / ServiceCollectionExtensions.cs
Last active January 12, 2020 14:24
Automatically register controllers with Sitecore 8.2 IoC container
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Web.Mvc;
using Microsoft.Extensions.DependencyInjection;
@kamsar
kamsar / anexample.ps1
Last active October 18, 2023 14:27
Generate trusted local SSL cert for Solr
# Usage:
# This script is designed to be run after you have Solr running locally without SSL
# It will generate a trusted, self-signed certificate for LOCAL DEV (this must be modified for production)
# Notes: The keystore must be under server/etc on Solr root, and MUST be named solr-ssl.keystore.jks
# The cert will be added to locally trusted certs, so no security warnings in browsers
# You must still reconfigure Solr to use the keystore and restart it after running this script
#
# THIS SCRIPT REQUIRES WINDOWS 10 (for the SSL trust); without 10 remove the lines around trusting the cert.
@cassidydotdk
cassidydotdk / gulp-config.js
Last active January 31, 2023 15:49
Task to build and publish a .SLN file from gulp using "msbuild" instead of "gulp-msbuild". Version 16.0 for VS2019, use 15.0 for VS2017.
module.exports = function () {
var config = {
websiteRoot: "C:\\inetpub\\wwwroot\\sc911.sc",
sitecoreLibraries: "C:\\inetpub\\wwwroot\\sc911.sc\\bin",
hostName: "http://sc911.sc",
solutionName: "sc911",
buildConfiguration: "Debug",
runCleanBuilds: false,
toolsVersion: "16.0"
}
@IvanLieckens
IvanLieckens / JssFieldsExtender.cs
Created June 4, 2019 07:56
Sitecore JSS GraphQL schema extension to output fields in JSS format
using GraphQL.Types;
using Newtonsoft.Json;
using Sitecore.Configuration;
using Sitecore.Data.Items;
using Sitecore.Data.Fields;
using Sitecore.Diagnostics;
using Sitecore.LayoutService.Serialization.FieldSerializers;
using Sitecore.LayoutService.Serialization.ItemSerializers;
using Sitecore.LayoutService.Serialization.Pipelines.GetFieldSerializer;
using Sitecore.Services.GraphQL.Content.GraphTypes;
@michaellwest
michaellwest / CleanupBlobData.sql
Created September 24, 2019 16:03
Cleanup orphaned blob data using SSMS. When Sitecore runs this process it may timeout otherwise.
DECLARE @BlobID uniqueidentifier;
SELECT @BlobID = '{FF8A2D01-8A77-4F1B-A966-65806993CD31}';
WITH [BlobFields] ([fieldid])
AS (SELECT [sharedfields].[itemid]
FROM [sharedfields]
WHERE [sharedfields].[fieldid] = @BlobID
AND [sharedfields].[value] = 1
UNION
SELECT [versionedfields].[itemid]
@auzick
auzick / LinkExtensions.cs
Created November 10, 2020 13:11
Sitecore SXA Scriban extension to expose the innards of a link field
using Scriban.Runtime;
using Sitecore.Data.Fields;
using Sitecore.Data.Items;
using Sitecore.XA.Foundation.Abstractions;
using Sitecore.XA.Foundation.Scriban.Pipelines.GenerateScribanContext;
using System;
using Example.ScribanExtensions.Model;
namespace Example.ScribanExtensions.Pipelines
{
@Antonytm
Antonytm / JssFieldsExtender.cs
Last active August 3, 2022 20:47 — forked from IvanLieckens/JssFieldsExtender.cs
Sitecore JSS GraphQL schema extension to output fields in JSS format
using GraphQL.Types;
using Newtonsoft.Json;
using Sitecore.Configuration;
using Sitecore.Data.Items;
using Sitecore.Data.Fields;
using Sitecore.Diagnostics;
using Sitecore.LayoutService.Serialization.FieldSerializers;
using Sitecore.LayoutService.Serialization.ItemSerializers;
using Sitecore.LayoutService.Serialization.Pipelines.GetFieldSerializer;
using Sitecore.Services.GraphQL.Content.GraphTypes;
@Antonytm
Antonytm / pre-commit.sh
Created August 27, 2022 10:59
Pre-commit Git hook that validates Sitecore serialization
#!/bin/sh
# Pre-commit Git hook
# It runs Sitecore CLI Serialization check
# And doesn't allow to perform commit if serialization is broken
validate=$(dotnet sitecore ser validate)
regex_errors="Errors were detected"
count=$(echo "${validate}" | grep -c "${regex_errors}")
if test $count -gt 0
then
echo "Sitecore serialization errors were detected"
@michaellwest
michaellwest / CurlCMError.ps1
Created January 16, 2023 21:01
Curl the home page when the CM reports unhealthy. For use with Sitecore and Docker.
$containers = docker ps -a --format "table {{.Names}}"
$container = $containers | ConvertFrom-Csv | Where-Object { $_.NAMES -match "-cm" } | Select-Object -First 1 -ExpandProperty NAMES
docker exec $container curl http://cm