Skip to content

Instantly share code, notes, and snippets.

View vtml's full-sized avatar

Vincent Lui vtml

View GitHub Profile
@vtml
vtml / ReflectionExtensions.cs
Last active February 5, 2021 11:07
Sitecore Super Power Friendly Dependency Injection
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
namespace Isobar.Foundation.SitecoreUtilities.Extensions
{
@vtml
vtml / ServiceCollectionExtensions.cs
Created March 19, 2019 10:25
Sitecore Super Power Friendly Dependency Injection
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web.Http.Controllers;
using System.Web.Mvc;
using Isobar.Foundation.SitecoreUtilities.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
@vtml
vtml / SomeService.cs
Created March 19, 2019 11:56
Sitecore Super Power Friendly Dependency Injection
public interface ISomeService
{
void Run(IGlassBase glassBase);
}
public class SomeService : ISomeService
{
public Run(IGlassBase glassBase)
{
// do something
@vtml
vtml / TooLazyServiceConfigurator.cs
Created March 19, 2019 12:06
Sitecore Super Power Friendly Dependency Injection
using System.IO.Abstractions;
using System.Reflection;
using FileHelpers;
using Isobar.Foundation.DependencyInjection;
using Isobar.Foundation.SitecoreUtilities.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Sitecore.DependencyInjection;
namespace Isobar.SampleProject.Infrastructure
@vtml
vtml / pipelinesPerRequest.js
Created July 5, 2019 08:47 — forked from richardszalay/pipelinesPerRequest.js
Sitecore Pipelines admin tool :: Per Request Wall Time Summary
/*
Paste this into the dev tools console on sitecore/admin/pipelines.aspx for a summary of pipeline execution time per request
*/
(function() {
function pipelinesPerRequest() {
const pipelines = Array.from(document.querySelectorAll('.groupheader')).map(el => ({
pipeline: el.querySelector("*[pln-name]").innerText,
executions: parseInt(el.querySelector('*[title="#Executions"]').innerText, 10),
wallTime: parseInt(el.querySelector('*[title="Wall Time"]').innerText.replace(/[^\d\.]/g, ''), 10)
}))
@vtml
vtml / TdsGlobal.config
Created August 24, 2019 00:43
Hedgehog Team Development for Sitecore (TDS) v5.8 Review
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CompactSitecoreItemsInProjectFile>True</CompactSitecoreItemsInProjectFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<!--
In the default configuration of the global file, the values for a configuration in the global file supersede the values
in the project configuration. This behavior can be changed by specifying a condition on the property as follows:
@vtml
vtml / HedgehogDevelopment.TDS.targets
Last active September 11, 2019 06:12
Hedgehog Team Development for Sitecore (TDS) v5.8 Review
<!-- BEGIN: changes to exclude Hedgehog DLL's during Web Deploy package generation -->
<Copy SourceFiles="$(MSBuildThisFileDirectory)HedgehogDevelopment.SitecoreProject.WebDeployClient.dll" DestinationFolder="$(_OutputPath)\Bin" Condition="'$(WebDeployPackageCodeAndItemOptions)' != 'CodeOnly' and '$(SkipHedgehogDLLs)' != 'True'" />
<Copy SourceFiles="$(MSBuildThisFileDirectory)HedgehogDevelopment.SitecoreProject.PackageInstallPostProcessor.dll" DestinationFolder="$(_OutputPath)\Bin" SkipUnchangedFiles="true" Condition="'$(WebDeployPackageCodeAndItemOptions)' != 'CodeOnly' and '$(SkipHedgehogDLLs)' != 'True'" />
<!-- END: changes to exclude Hedgehog DLL's during Web Deploy package generation -->
@vtml
vtml / RestfulV2-BasicAuth.ps1
Last active December 2, 2019 04:30
Running RestfulV2 Powershell Scripts using Basic Authentication for Sitecore Powershell Extensions 5.1 and above
<#
.SYNOPSIS
This script triggers any SPE scripts that are available to be used through the Restful V2 service. Sitecore Powershell Extensions 5.1 or above is required.
.DESCRIPTION
This script triggers any SPE scripts that are available to be used through the Restful V2 service. Sitecore Powershell Extensions 5.1 or above is required. This can be used on developer PC's, as well as during CI / CD process. RestfulV2 must be enabled in Sitecore Powershell Extensions for this to work. https://doc.sitecorepowershell.com/security
For Sitecore 9.1 and above that uses the Identity Server, Cognified.PowerShell.IdentityServer.config must be enabled. This config patch is available from SPE 5.1 and above.
@vtml
vtml / RestfulV2-QueryStringAuth.ps1
Last active December 5, 2019 06:41
Running RestfulV2 Powershell Scripts using Query String Authentication for Sitecore Powershell Extensions 5.0
<#
.SYNOPSIS
This script triggers any SPE scripts that are available to be used through the Restful V2 service. Sitecore Powershell Extensions 5.0 is required. Please use RestfulV2-BasicAuth.ps1 instead if Sitecore Powershell Extensions 5.1 or above is installed in the Sitecore Instance.
.DESCRIPTION
This script triggers any SPE scripts that are available to be used through the Restful V2 service. Sitecore Powershell Extensions 5.0 is required. Please use RestfulV2-BasicAuth.ps1 instead if Sitecore Powershell Extensions 5.1 or above is installed in the Sitecore Instance. This can be used on developer PC's, as well as during CI / CD process. RestfulV2 must be enabled in Sitecore Powershell Extensions for this to work. https://doc.sitecorepowershell.com/security
For Sitecore 9.1 and above that uses the Identity Server, Cognified.PowerShell.IdentityServer.config must be enabled. This config patch is available from SPE 5.1 and above.
@vtml
vtml / Project.SPE.config
Last active December 3, 2019 03:08
Patch to enable Sitecore Powershell Extensions Restful V2
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:env="http://www.sitecore.net/xmlconfig/env/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore>
<powershell>
<services>
<restfulv2 role:require="ContentManagement or Standalone">
<patch:attribute name="enabled">true</patch:attribute>
<authorization>
<add Permission="Allow" IdentityType="User" Identity="sitecore\CI.User" />
</authorization>