Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Wesselman nickwesselman

  • Sitecore
  • Asheville, NC
View GitHub Profile
@nickwesselman
nickwesselman / Default.cshtml
Created Aug 17, 2020
Sitecore ASP.NET Core Language Switcher Snippets
View Default.cshtml
@model LanguageSwitcherModel
@foreach (var culture in Model.SupportedCultures)
{
if (Model.CurrentUICulture.Name == culture.Name)
{
<strong>@culture.DisplayName</strong>
}
else
{
@nickwesselman
nickwesselman / test-dotnet.ps1
Created Jul 8, 2020
Docker for Windows Process Isolation Firewall Test
View test-dotnet.ps1
Param(
$isolation="process",
$port=8765
)
Write-Host "Opening incoming connections on port $port" -ForegroundColor Green
netsh advfirewall firewall add rule name="Docker Test Open Port $port" dir=in action=allow protocol=TCP localport=$port
Write-Host "Turning on firewall logging" -ForegroundColor Green
auditpol /set /subcategory:"Filtering Platform Packet Drop" /failure:enable /success:enable
@nickwesselman
nickwesselman / InteractionsAndFacets.sql
Last active Jun 12, 2020
Sitecore Analytics Queries
View InteractionsAndFacets.sql
/** Get the interactions. **/
select [InteractionId], [LastModified], [EventType], [PageUrl], [ItemLanguage], [DefinitionId], [EventText]
FROM
(SELECT TOP (1000) [InteractionId]
,[LastModified]
,[Events]
FROM [Sitecore.Xdb.Collection.Shard0].[xdb_collection].[Interactions]
UNION
SELECT TOP (1000) [InteractionId]
,[LastModified]
@nickwesselman
nickwesselman / Presentation Links.md
Last active Jan 6, 2020
Helix Patterns, Anti-Patterns, and Smells - Symposium 2019
View Presentation Links.md
@nickwesselman
nickwesselman / GenerateProducts.ps1
Last active Jun 12, 2019
Generate Random Bucket Content for Sitecore with PowerShell Extensions and RandomText.me
View GenerateProducts.ps1
$ErrorActionPreference = "Stop"
Function Get-Lorem($Minimum, $Maximum) {
# don't overrun randomtext.me
Start-Sleep -Milliseconds 300
$words = Get-Random -Minimum $Minimum -Maximum ($Maximum+1)
return ([xml](ConvertFrom-Json (Invoke-WebRequest -UseBasicParsing http://www.randomtext.me/api/lorem/h1/$words).Content).text_out).h1
}
Function Get-LoremUl($NumItems, $Minimum, $Maximum) {
@nickwesselman
nickwesselman / ProductRepository.cs
Last active Apr 27, 2019
Unit Testing Sitecore ContentSearch (LINQ to Sitecore) using Moq
View ProductRepository.cs
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Sitecore.Abstractions;
using Sitecore.ContentSearch;
using Sitecore.Data.Items;
namespace BasicCompany.Feature.Products.Services
{
public class ProductRepository : IProductRepository
@nickwesselman
nickwesselman / ConvertToNewNuget-packagesconfig.ps1
Last active Nov 6, 2019
Assists in updating an existing Sitecore Visual Studio solution to the new nuget structure for 9.1, when using packages.config style Nuget. This code is provided AS-IS, and is not supported by Sitecore.
View ConvertToNewNuget-packagesconfig.ps1
## Nuget v2 URL for the target platform, and the target marketing version
$SitecoreNuget = "https://sitecore.myget.org/F/sc-platform-9-1/api/v2"
$TargetVersion = "9.1.0"
function Add-XMLAttribute([System.Xml.XmlNode] $Node, $Name, $Value)
{
$attrib = $Node.OwnerDocument.CreateAttribute($Name)
$attrib.Value = $Value
$node.Attributes.Append($attrib)
}
@nickwesselman
nickwesselman / ConvertToNewNuget-PackageReference.ps1
Last active Apr 10, 2019
Assists in updating an existing Sitecore Visual Studio solution to the new nuget structure for 9.1, when using PackageReference style Nuget. This code is provided AS-IS, and is not supported by Sitecore.
View ConvertToNewNuget-PackageReference.ps1
## Nuget v2 URL for the target platform, and the target marketing version
$SitecoreNuget = "https://sitecore.myget.org/F/sc-platform-9-1/api/v2"
$TargetVersion = "9.1.0"
## Nuget URL to retrieve package metadata, including dependencies
$MetaPackage = "$SitecoreNuget/Packages(Id='Sitecore.Experience.Platform',Version='$TargetVersion')"
## Retrieve the package metadata from nuget (no nice way of doing this via CLI)
$PackageMetadata = [xml](Invoke-WebRequest $MetaPackage).Content
@nickwesselman
nickwesselman / Performance.Dev.config
Last active Sep 4, 2019 — forked from kamsar/Performance.Dev.config
Sitecore 9.0 Dev Performance Config
View Performance.Dev.config
<!--
A set of performance optimizations for development that vastly increase application startup time.
Should not be used in production, as they largely disable forensic diagnostics that you'd want there over fast startup time after a compile.
-->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<hooks>
<hook type="Sitecore.Diagnostics.HealthMonitorHook, Sitecore.Kernel">
<patch:delete />
@nickwesselman
nickwesselman / 01-templates.sitecore.js
Created Mar 15, 2018
Sitecore Content Import via JSS Manifest
View 01-templates.sitecore.js
export default function(manifest) {
manifest.addTemplate({
name: 'Setlist',
icon: '/~/icon/office/32x32/earth_music.png',
fields: [
{ name: 'eventDate', type: 'Date' },
{ name: 'artist', type: manifest.fieldTypes.singleLineText },
{ name: 'venue', type: manifest.fieldTypes.singleLineText },
{ name: 'location', type: manifest.fieldTypes.singleLineText },
{ name: 'description', type: manifest.fieldTypes.richText },
You can’t perform that action at this time.