Skip to content

Instantly share code, notes, and snippets.

View robearlam's full-sized avatar

Rob Earlam robearlam

View GitHub Profile
@robearlam
robearlam / Pipeline-httpRequestBegin.config
Last active April 15, 2017 01:19
Sitecore Multisite 404, 500 & Robots.txt
<httpRequestBegin>
<processor type="Sitecore.MultisiteHttpModule.NotFound.NotFoundHandler, Sitecore.MultisiteHttpModule" patch:after="processor[@type='Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel']" />
</httpRequestBegin>
@robearlam
robearlam / Revolver-bind.cs
Last active April 15, 2017 01:31
Extending Sitecore Revolver to remove old versions.
bind RevolverExtensions.TrimVersions,RevolverExtensions tv
@robearlam
robearlam / RenamePlaceholders.cs
Created April 15, 2017 03:21
Extending Sitecore Revolver to bulk update placeholder names
private const string RecursiveSwitch = "-r";
private const string RenderingElementName = "r";
private const string RenderingsFieldName = "__renderings";
private const string DeviceElementName = "d";
private const string PlaceholderAttributeName = "ph";
private Context _context;
private bool _recursive;
private string _oldPlaceHolderName;
private string _newPlaceHolderName;
@robearlam
robearlam / HtmlCacheClearer.config
Created April 15, 2017 03:26
Customsing the Sitecore HTML cache clearer
<settings>
<!--
A pipe separated list of content ID's. When a publish occurs if the item
being published is one of these items,
or a child of one of these items then the HTML cache isn't cleared.
-->
<setting name="CustomHtmlCacheClearer.IgnoreItems" value="/sitecore/content"/>
</settings>
<events>
@robearlam
robearlam / customrule.cs
Created April 15, 2017 03:31
List all Sitecore contacts that have completed a goal
public class HasContactCompletedGoal<T> : TypedQueryableStringOperatorCondition<T, IndexedContact> where T : VisitorRuleContext<IndexedContact>
{
private const string IndexField = "Contact.CompletedGoals";
private const string ContainsOperatorId = "{2E67477C-440C-4BCA-A358-3D29AED89F47}";
public HasContactCompletedGoal()
{
OperatorId = ContainsOperatorId;
}
@robearlam
robearlam / ConnectionStrings.config
Last active April 15, 2017 07:37
Editing Sitecore Azure ARM Templates - Part 2 - Building the WebDeploy package
<?xml version="1.0" encoding="utf-8"?>
<connectionStrings>
<!--
Sitecore connection strings.
All database connections for Sitecore are configured here.
-->
<add name="core" connectionString="user id=user;password=password;Data Source=(server);Database=Sitecore_Core"/>
<add name="web" connectionString="user id=user;password=password;Data Source=(server);Database=Sitecore_Web"/>
<add name="analytics" connectionString="mongodb://localhost/Sitecore_analytics"/>
<add name="tracking.live" connectionString="mongodb://localhost/Sitecore_tracking_live"/>
@robearlam
robearlam / azuredeploy-variables-new.json
Last active April 15, 2017 23:42
Editing Sitecore Azure ARM Templates - Part 3 - Editing the ARM Template
"sessionMongoDbConnStrTidy": "[trim(parameters('session.mongodb.connectionstring'))]",
@robearlam
robearlam / PlugIn.Habitat.CommerceAuthoring-1.0.0.json
Last active March 18, 2018 00:49
Sitecore XC9, Data Isolation & Artifact Stores
{
"$type": "Sitecore.Commerce.Core.CommerceEnvironment, Sitecore.Commerce.Core",
"ArtifactStoreId": "78A1EA61-1F37-42A7-AC89-9A3F46D60CA5",
"Components": {
"$type": "System.Collections.Generic.List`1[[Sitecore.Commerce.Core.Component, Sitecore.Commerce.Core]], mscorlib",
"$values": [{
"$type": "Sitecore.Commerce.Plugin.ManagedLists.ListMembershipsComponent, Sitecore.Commerce.Plugin.ManagedLists",
"Memberships": {
"$type": "System.Collections.Generic.List`1[[System.String, mscorlib]], mscorlib",
"$values": ["CommerceEnvironments"]
@robearlam
robearlam / Dockerfile
Last active August 11, 2019 02:57
Using VSCode to debug a .NETCore application running inside a Docker container
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.sln .
COPY myapp/*.csproj ./myapp/
RUN dotnet restore
# copy everything else and build app
COPY myapp/. ./myapp/
@robearlam
robearlam / dockergist.ps1
Created November 20, 2019 15:55
Get Internal IP for all running Docker containers on Windows
(docker ps -q | ForEach-Object { docker inspect $_ --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}} {{ .Name }}' }).replace('/','')