Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Szalay richardszalay

View GitHub Profile
@richardszalay
richardszalay / DiagnosticBlock.cs
Created May 15, 2018
DiagnosticBlock for Sitecore Commerce
View DiagnosticBlock.cs
/**
This block is designed to assist with diagnosing data/pipeline issues within Sitecore
Example:
services.Sitecore().Pipelines(config => config
.ConfigurePipeline<ICalculateSellableItemSellPricePipeline>(builder => builder
.Add<DiagnosticBlock<SellableItem>>("Before CalculateSellableItemListPriceBlock").Before<CalculateSellableItemSellPriceBlock>(),
order: 1001
)
View Invoke-SitecoreCommerceBootstrap.psm1
function Invoke-SitecoreCommerceBootstrap {
param(
[string]$Username = "sitecore\admin",
[string]$Password = "b",
[string]$IdentityServer = "https://localhost:5050",
[string]$OpsServer = "https://localhost:5015"
)
$ErrorActionPreference = "Stop"
@richardszalay
richardszalay / Update-SitecorePackages.ps1
Created Feb 26, 2018
Update Sitecore NuGet packages
View Update-SitecorePackages.ps1
# Updates from a specific version to avoid conflicting names ("Sitecore.Framework", "Sitecore.Ship", etc)
$SourceVersion = "9.0.171002"
# Does late filtering to avoid redundant upgrades for packages that have already been upgrades as dependencies. Big time saver
Get-Package | `
Where-Object { $_.Id -like "Sitecore.*" } | `
Foreach-Object {
$id = $_.Id
if ((Get-Package -ProjectName $_.ProjectName) | ?{ $_.Id -eq $id -and $_.Version -eq $SourceVersion}) {
Update-Package -Id $_.Id -ProjectName $_.ProjectName -Version HighestPatch # Use HighestMinor for a full point release
@richardszalay
richardszalay / Test-SitecoreAssemblyList.ps1
Last active Dec 29, 2017
Test-SitecoreAssemblyList.ps1
View Test-SitecoreAssemblyList.ps1
<#
.SYNOPSIS
Validates a Sitecore "Assembly list" (from dev.sitecore.net) against a folder
.PARAMETER AssemblyList
The assembly list text file downloaded from dev.sitecore.net
.PARAMETER AssemblyFolder
The folder containing the Sitecore assemblies to validate
.PARAMETER CheckFileVersion
If set, also verifies the file version. Requires loading the assembly, so should be invoked in an isolated powershell environment
.NOTES
View Win10-16257-Console-Colors.reg
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Console]
"ColorTable00"=dword:000c0c0c
"ColorTable01"=dword:00da3700
"ColorTable02"=dword:000ea113
"ColorTable03"=dword:00dd963a
"ColorTable04"=dword:001f0fc5
"ColorTable05"=dword:00981788
"ColorTable06"=dword:00009cc1
View Reset-BashPassword.ps1
# Resets the password for the default LXSS / WSL bash user, based on https://askubuntu.com/a/808425/697555
$lxssUsername = (Get-ItemProperty HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss).DefaultUsername
lxrun /setdefaultuser root
bash -c "passwd $lxssUsername"
lxrun /setdefaultuser $lxssUsername
@richardszalay
richardszalay / PositionFixedNavBar-SC-Ext.js
Created Mar 24, 2017
Positioning a fixed header below the Sitecore Experience Editor ribbon
View PositionFixedNavBar-SC-Ext.js
// Repositions a position-fixed header so that it always appears under the SC experience editor ribbon
// includes added support for the Sitecore Extensions Chrome extension and its support for hiding the ribbon entirely
define(["sitecore"], function (Sitecore) {
return {
priority: 50,
execute: function (context) {
// TODO: Change this CSS selector to suit your application
var FIXED_NAV_SELECTOR = 'nav';
// the 'cross piece' is a blank div that is sized to match the iframe content (where the actual ribbon is)
View Copy-EC2SecurityGroupIngress.ps1
<#
.SYNOPSIS
Copies all EC2 Security Group rules from one IP range to one or more other ranges, optionally removing the original IP's rules
.DESCRIPTION
Copies all EC2 Security Group rules from one IP range to one or more other ranges, optionally removing the original IP's rules
.PARAMETER Region
The AWS Region to apply the changes to
.PARAMETER CurrentIpRange
The IP Address or CIDR Range that should be used as a template when copying rules
.PARAMETER NewIpRanges
@richardszalay
richardszalay / extract-policy.js
Created Dec 5, 2016
Extract policy document as text in AWS
View extract-policy.js
document.querySelector('#policy_document .ace_scroller').innerText
@richardszalay
richardszalay / .bashrc
Last active Oct 18, 2016
Creating a Build-Once Deployment Pipeline
View .bashrc
# https://github.com/fastlane/fastlane/issues/488
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# If not using rvm (which will set this for you)
export GEM_HOME=~/.gems
export PATH=$PATH:~/.gems/bin