Skip to content

Instantly share code, notes, and snippets.

View harshbaid's full-sized avatar

Harsh Baid harshbaid

View GitHub Profile
@harshbaid
harshbaid / ResetTemplates.ps1
Created February 22, 2024 15:16
Bulk operation to reset specific field on template standard values
$baseTemplateId = "{20427F7C-8B5E-4799-A282-05376D978999}"
function IsTemplateStandardValue([Sitecore.Data.Items.Item]$item)
{
$flag = $false
$hasScriptTemplate = Test-BaseTemplate -Item $item -Template $baseTemplateId
if ($hasScriptTemplate -and $item.Name -eq "__Standard Values")
{
$flag = $true
}
@harshbaid
harshbaid / cleanup.git.folder.bat
Created May 1, 2023 21:28
Cleans up disk space taken by .git folder.
git remote prune origin && git repack && git prune-packed && git reflog expire --expire=1.month.ago && git gc --aggressive
@harshbaid
harshbaid / Sitecore.Geolocation.SQLQuery.sql
Created February 17, 2023 16:24
SQL query to see processed locations data in Sitecore analytics
select count(*) from [xdb_processing_pools].[InteractionLiveProcessingPool]
select * from [xdb_processing_pools].[InteractionLiveProcessingPool]
select top 10 * from [cad_prod_Xdb.Collection.Shard0].[xdb_collection].InteractionFacets order by LastModified desc
@harshbaid
harshbaid / Command.File.Operations.txt
Created August 5, 2021 15:16
A quick way to delete all files with a certain name pattern in Windows
dir 404.*.txt /a /b /s
del 404.*.txt /a /s
Reference: https://confidentialfiles.wordpress.com/2010/06/02/a-quick-way-to-delete-all-files-with-a-certain-name-pattern-in-windows/
@harshbaid
harshbaid / TempFolderBrowser.aspx
Created August 4, 2021 16:13 — forked from sincladk/TempFolderBrowser.aspx
Sitecore Temp Folder Browser
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Sitecore Temp Folder Browser</title>
<link rel="Stylesheet" type="text/css" href="/sitecore/shell/themes/standard/default/WebFramework.css" />
<link rel="Stylesheet" type="text/css" href="./default.css" />
</head>
<body>
<script runat="server">
private const string TEMP_FOLDER_PATH = @"C:\inetpub\wwwroot\Sitecore\temp\";
private const int MAX_FILE_COUNT = 10;
@harshbaid
harshbaid / sxa-regenerate-optimised-assets.ps1
Created June 1, 2021 04:14 — forked from mawiseman/sxa-regenerate-optimised-assets.ps1
Sitecore SXA regenerate optimised files
# Run this script in Sitecore Powershell Extensions
# It will delete the minifed files from master and publish the deletions to web
# Next time the site is visited they should be re-generated (if they aren't check your settings http://bit.ly/2TfrcfC)
# TODO: When publishing, there might be a better way to target folders in the media library instead of the hardcoded list
$masterItems = Get-Item -Path master: -Query "/sitecore/media library//*[@@key='optimized-min']"
$webItems = Get-Item -Path web: -Query "/sitecore/media library//*[@@key='optimized-min']"
Write-Host "Master Items: $($masterItems.length)"
$props = @{
InfoTitle = "Remove workflows"
PageSize = 10000000
}
Write-Host "Starting work in the context of the 'master' database, under /Home item."
Set-Location -Path "master:/sitecore/content/<YOURNODE>"
# Set up variables
$workflowState1 = "{13FDC8BC-60B9-44E1-ADCC-CED02E0392A9}" #ID of the workflow states. DRAFT
@harshbaid
harshbaid / install-nuget-package.txt
Created September 11, 2020 19:03
Command (to run from Package Manager Console) to install NuGet package without dependencies for Sitecore 9.3 and onwards.
Command Template: Install-Package -IgnoreDependencies -ID <Package.Name> -Version <version>
Example: Install-Package -IgnoreDependencies -ID Sitecore.Kernel -Version 9.3.0 (replacement for Sitecore.Kernel.NoReferences)
@harshbaid
harshbaid / Snippet from Startup.cs
Created August 27, 2020 18:41
part of Startup.cs for auth code flow with Owin and ASP.NET
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
ClientSecret = clientSecret,
Authority = authority,
MetadataAddress = metaDataUri,
RedirectUri = redirectUri,
ResponseType = OpenIdConnectResponseType.Code,
Scope = OpenIdConnectScope.OpenId,
PostLogoutRedirectUri = postLogoutRedirectUri,
using System;
using Microsoft.Owin;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace Owin
{
using Predicate = Func<IOwinContext, bool>;
using AppFunc = Func<IDictionary<string, object>, Task>;