Skip to content

Instantly share code, notes, and snippets.

View nickwesselman's full-sized avatar

Nick Wesselman nickwesselman

View GitHub Profile
@nickwesselman
nickwesselman / dark-robo-jam.txt
Last active February 11, 2022 03:59
Sonic Pi Shares
use_bpm 90
cut = 120
live_loop :met do
sleep 1
end
live_loop :kick, sync: :met do
@nickwesselman
nickwesselman / Program.cs
Last active October 27, 2021 20:53
.NET 6 System.Text.Json.Nodes and System.Text.Json source generation, with top-level statements
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
/*
Testing out .NET 6 JSON DOM for "late binding" of models to a document with unknown structure.
Also added source generation for JSON deserialization, both for the base model and the "late bound" model.
@nickwesselman
nickwesselman / SitecoreOptions.cs
Created August 31, 2021 13:27
Sitecore ASP.NET Core Multisite
public class SitecoreOptions
{
public static readonly string Key = "Sitecore";
public Uri InstanceUri { get; set; }
public string LayoutServicePath { get; set; } = "/sitecore/api/layout/render/jss";
public string DefaultSiteName { get; set; }
public string ApiKey { get; set; }
public Uri RenderingHostUri { get; set; }
public bool EnableExperienceEditor { get; set; }
@nickwesselman
nickwesselman / GrpcService.cs
Created April 10, 2021 21:56
Read from a multiplexed stream provided by Docker.DotNet for container logs. In parallel, read from the multiplexed streams using a StreamReader and write to the gRPC response. Currently this isn't working -- the gRPC call never returns.
public override async Task StreamContainerLogs(StreamContainerLogsRequest request, IServerStreamWriter<StreamContainerLogsResponse> responseStream, ServerCallContext context)
{
const int bufferSize = 81920;
var streamTask = DockerClient.Containers.GetContainerLogsAsync(request.Id, false, new ContainerLogsParameters
{
Follow = true,
Tail = "500",
ShowStdout = true,
ShowStderr = true
@nickwesselman
nickwesselman / questions.md
Last active October 28, 2020 18:31
Symposium 2020 Follow-up Questions: ASP.NET Core Rendering SDK

How to develop with the new ASP.NET Core rendering SDK

Follow-up Questions

Can I use Blazor?

At this time, only ASP.NET Core MVC is supported. But we are looking at Blazor support and would love to hear about customer use cases (nwe at sitecore dot net).

When referring to Blazor are you thinking of WASM or server blazor?

From our current POV, Blazor Server isn't a great option for the typical marketing website because of the risk of server disconnect.

@nickwesselman
nickwesselman / Default.cshtml
Created August 17, 2020 14:50
Sitecore ASP.NET Core Language Switcher Snippets
@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 July 8, 2020 04:51
Docker for Windows Process Isolation Firewall Test
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 June 12, 2020 12:29
Sitecore Analytics Queries
/** 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 January 6, 2020 17:15
Helix Patterns, Anti-Patterns, and Smells - Symposium 2019
@nickwesselman
nickwesselman / GenerateProducts.ps1
Last active June 12, 2019 16:08
Generate Random Bucket Content for Sitecore with PowerShell Extensions and RandomText.me
$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) {