Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
manoj-choudhari-git / web.config.xml
Last active October 25, 2024 16:04
Set environment variable in web.config file
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\SampleNetCoreApp.dll">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
@kinetiq
kinetiq / SimpleValidator
Created October 27, 2020 21:25
Manually validate any model in .NET Core 3.1
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Ether.Validation
{
public static class SimpleValidator
{
/// <summary>
/// Validate the model and return a response, which includes any validation messages and an IsValid bit.
@michaellwest
michaellwest / ExportAccess.ps1
Created October 1, 2020 17:15
Export and Import user access using Sitecore PowerShell Extensions
# Use this report to export current access
$users = Get-User -Filter * | Where-Object { $_.Roles.Count -gt 0 }
$records = [System.Collections.ArrayList]@()
foreach($user in $users) {
$record = [PSCustomObject]@{
"Username" = $user.Name
"Roles" = ($user.Roles | Select-Object -ExpandProperty Name) -join ","
}
$records.Add($record) > $null
@michaellwest
michaellwest / CleanupTables.sql
Last active August 29, 2024 18:10
Remove entries in the Sitecore Publishing Service queue using PowerShell.
Import-Function -Name Invoke-SqlCommand
$connection = [Sitecore.Configuration.Settings]::GetConnectionString("master")
$query = @"
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_ActivationLock]
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_Data_Params_FieldIds]
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_Data_Params_Languages]
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_JobManifest]
DELETE FROM [Sitecore.Masterx].[dbo].[Publishing_JobMetadata]
@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){