Skip to content

Instantly share code, notes, and snippets.

@bic742
bic742 / SearchQuery.cs
Last active August 15, 2023 12:04
Extended Sitecore SearchQuery to support sorting and more complex search criteria
using GraphQL.Types;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.Linq;
using Sitecore.ContentSearch.Linq.Utilities;
using Sitecore.ContentSearch.Utilities;
using Sitecore.Data;
using Sitecore.Data.Managers;
using Sitecore.Globalization;
using Sitecore.Services.GraphQL.Content.GraphTypes.ContentSearch;
using Sitecore.Services.GraphQL.GraphTypes.Connections;
@iImagineApps
iImagineApps / gist:b92416f1a4547f0bd27d0b70f561c73f
Created June 9, 2020 15:55
This script is a rough version. It downloads all images for an indicated location by finding all fields of type Image in the child items. This needs to be parameterized to pass in starting location and language.
############
# Author: Rich Rosiak
#
# This script gets all images for a given content location in language en
#
# Function ZipItems copied from item:
# /sitecore/system/Modules/PowerShell/Script Library/SPE/Maintenance/Media Library Maintenance/Content Editor/Context Menu/Download
# and then customized
############
function ZipItems( $zipArchive, $items )
@vtml
vtml / Sitecore-ImageResizing-EdgeWorker
Last active April 30, 2020 02:40
CloudFlare Image Resizing Edge Worker for Sitecore
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
/**
* Fetch and log a request
* @param {Request} request
*/
async function handleRequest(request) {
// Parse request URL to get access to query string
@adoprog
adoprog / docker-acr.ps1
Created March 24, 2020 20:16
Compare local Docker images with the ones in Azure Container Registry (ACR)
$registry = "%registry name here, i.e. myregistry%"
$repositories = docker images --digests | % { $_ -replace " +", "," } | convertfrom-csv | where { $_.REPOSITORY.StartsWith($registry) } | group REPOSITORY
Write-Output "Found $($repositories.Count) local repositories from $($registry) registry"
foreach ($group in $repositories) {
$repository = $group.Name.Split('/')[1]
$remoteData = az acr repository show-tags -n $registry --repository $repository --detail | convertfrom-json
foreach ($localRepo in $group.Group) {
$localRepo | Add-Member -NotePropertyName REPO -NotePropertyValue $repository
@jdhitsolutions
jdhitsolutions / ShortLocation-Prompt.ps1
Created January 3, 2020 16:26
A PowerShell prompt function to truncate your current location.
Function prompt {
$location = $executionContext.SessionState.Path.CurrentLocation.path
#what is the maximum length of the path before you begin truncating?
$len = 33
if ($location.length -gt $len) {
#split on the path delimiter which might be different on non-Windows platforms
@JeffDarchuk
JeffDarchuk / Get-UnicornModel.ps1
Created December 27, 2019 14:53
Unicorn scanner to alert on potential errors in unicorn configurations
param(
[string] $path
)
function Expand-Tokens{
param(
[string] $configName,
[string] $path
)
$root = $configName.Split(".")
if ($root.Length -ge 1){
public class ClearEdgeCacheHandler
{
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private const string LastUpdateTimeKey = "ItemsPublishedEventHandler_LastUpdateTimeKey";
public void ItemsPublished(object sender, EventArgs args)
{
var now = DateTime.UtcNow;
var database = Factory.GetDatabase("web");
var fromDate = database.PropertyStore.GetDateValue(LastUpdateTimeKey, DateTime.MinValue.ToUniversalTime());
public class CacheControlProcessor : CacheControl
{
protected override void RunCacheControl(ActionExecutedArgs args)
{
Assert.IsNotNull(args, "args != null");
if (Sitecore.Context.Item != null)
{
if (HasRequestMethodGet(args) && DoesntHaveQuerystrings(args))
{
@cassidydotdk
cassidydotdk / Setup Unicorn in Docker.txt
Last active September 27, 2019 19:22
How to configure Unicorn with a volume mapping for your CM server Docker container
How to set up Unicorn in your Docker container
Since all writing to Unicorn files happens inside the container, and the container is now linked to .\unicorn,
all you need to do is ensure that .\unicorn is included under source control.
This gets even better if you use Transparent Sync.
@mikaelnet
mikaelnet / Broken links Report.ps1
Created August 21, 2019 12:31
Updated Sitecore SPE Broken links Report