Skip to content

Instantly share code, notes, and snippets.

View hermanussen's full-sized avatar

Robin Hermanussen hermanussen

View GitHub Profile
@michaellwest
michaellwest / CurlCMError.ps1
Created January 16, 2023 21:01
Curl the home page when the CM reports unhealthy. For use with Sitecore and Docker.
$containers = docker ps -a --format "table {{.Names}}"
$container = $containers | ConvertFrom-Csv | Where-Object { $_.NAMES -match "-cm" } | Select-Object -First 1 -ExpandProperty NAMES
docker exec $container curl http://cm
@dolphinspired
dolphinspired / FunctionContextAccessor.md
Last active May 30, 2024 16:50
FunctionContextAccessor example

IFunctionContextAccessor Implementation

This is a brief tutorial on how to create a dependency-injectable FunctionContext accessor for Azure Functions running on the dotnet-isolated runtime (.NET 5 and up). This will work very similarly to IHttpContextAccessor - it will allow you to access details about the current Function invocation and pass arbitrary values between injected services that are scoped to this invocation.

  1. Create your interface. You must include both get and set on this interface.
public interface IFunctionContextAccessor
{
 FunctionContext FunctionContext { get; set; }
@sshushliapin
sshushliapin / SitecoreUnitTestingSamples.FirstMock
Last active December 21, 2023 11:28
Switching from FakeDb to mocks
using AutoFixture;
using AutoFixture.Kernel;
using AutoFixture.Xunit2;
using NSubstitute;
using Sitecore.Data;
using Sitecore.Data.Items;
using Xunit;
namespace SitecoreUnitTestingSamples
{
@dylanyoung-dev
dylanyoung-dev / gulpfile.js
Created April 30, 2018 14:14
Gulp Leprechaun Build Task
var gulp = require("gulp");
var exec = require("child_process").exec;
// Run Leprechaun to Code Generate Models
gulp.task('_Code-Generation', function(x) {
exec('.\\Tools\Leprechaun-1.0.0\\Leprechaun.console.exe /c .\\src\\Leprechaun.config', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
x(err);
});
@grimzy
grimzy / git-pull-all
Created September 15, 2017 02:15
Git pull all remote branches
#!/usr/bin/env bash
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
@Sup3rc4l1fr4g1l1571c3xp14l1d0c10u5
Sup3rc4l1fr4g1l1571c3xp14l1d0c10u5 / TopologicalSort.cs
Created June 18, 2016 15:15
Topological Sorting (Kahn's algorithm) implemented in C#
using System;
using System.Collections.Generic;
using System.Linq;
namespace TopologicalSort {
static class Program {
static void Main() {
//
// digraph G {
// "7" -> "11"