Skip to content

Instantly share code, notes, and snippets.

View richardszalay's full-sized avatar

Richard Szalay richardszalay

View GitHub Profile
@richardszalay
richardszalay / extract-policy.js
Created December 5, 2016 21:49
Extract policy document as text in AWS
document.querySelector('#policy_document .ace_scroller').innerText
@richardszalay
richardszalay / Copy-EC2SecurityGroupIngress.ps1
Created February 21, 2017 06:03
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 / PositionFixedNavBar-SC-Ext.js
Created March 24, 2017 04:35
Positioning a fixed header below the Sitecore Experience Editor ribbon
// 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)
@richardszalay
richardszalay / Reset-BashPassword.ps1
Last active December 3, 2020 08:38
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 / Win10-16257-Console-Colors.reg
Created August 3, 2017 04:43
Applies the default console colors added in Windows 10 16256 (https://blogs.msdn.microsoft.com/commandline/2017/08/02/updating-the-windows-console-colors/) to older versions of Windows
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
@richardszalay
richardszalay / Test-SitecoreAssemblyList.ps1
Last active December 29, 2017 21:48
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
@richardszalay
richardszalay / Update-SitecorePackages.ps1
Created February 26, 2018 00:15
Update Sitecore NuGet packages
# 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 / Invoke-SitecoreCommerceBootstrap.psm1
Last active April 9, 2018 01:10
Invoke-SitecoreCommerceBootstrap
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 / DiagnosticBlock.cs
Created May 15, 2018 03:55
DiagnosticBlock for Sitecore Commerce
/**
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
)
<#
**Prototype**
Updates the properties of one or more Sitecore Commerce policies in a policy set or environment json file.
# Patch all policies from another file
Patch-SitecoreCommercePolicySet -Path "path\to\policy.json" -SourcePath "path\to\source.json"
# Patch a specific policy from another file
Patch-SitecoreCommercePolicySet -Path "path\to\policy.json" -SourcePath "path\to\source.json" -PolicyType "Fully.Qualified.Type, With.Assembly.But.Spaces.Are.Ignored"