Skip to content

Instantly share code, notes, and snippets.

View jermdavis's full-sized avatar
🐱

Jeremy Davis jermdavis

🐱
View GitHub Profile
@jermdavis
jermdavis / AdvancedCache.aspx
Last active October 3, 2022 19:56
A fix to make https://briancaos.wordpress.com/2017/05/01/sitecore-caching-clear-caches-individually/ work on Sitecore 10, plus a quick hack to view the contents of each cache (for data that can be easily displayed)
<%@ page language="c#" enableeventvalidation="false" autoeventwireup="true" enableviewstate="false" %>
<%@ import namespace="System.Security.Permissions" %>
<%@ import namespace="System.Collections.Generic" %>
<%@ import namespace="System.Threading" %>
<%@ import namespace="System.Security.Principal" %>
<%@ import namespace="Newtonsoft.Json" %>
<%@ import namespace="Sitecore.Data.Items" %>
<script runat="server">
@jermdavis
jermdavis / FunctionScheduler.cs
Last active May 12, 2018 20:28
Simple scheduler class
using System;
using System.Threading;
public class FunctionScheduler
{
private int _runEveryMs;
private Action _actionToRun;
private Timer _timer = null;
private object _lock = new object();
param(
[Parameter(Mandatory=$true)]
[string]$configFolder,
[Parameter(Mandatory=$true)]
[string]$configPattern,
[Parameter(Mandatory=$true)]
[string]$currentRoles
)
function Update-ConfigFile
@jermdavis
jermdavis / DownloadFromSitecore.ps1
Last active November 23, 2021 13:30
Download files from dev.sitecore.net from the commandline - see https://blog.jermdavis.dev/posts/2017/downloading-stuff-from-dev-sitecore-net for info
param(
[Parameter(Mandatory=$true)]
[string]$url,
[Parameter(Mandatory=$true)]
[string]$target
)
function Fetch-WebsiteCredentials
{
$file = "dev.creds.xml"
@jermdavis
jermdavis / SolrInstall-SIF-Extension.psm1
Last active November 23, 2021 13:29
A Sitecore Install Framework extension to install a development instance of Solr - Further detail at: https://blog.jermdavis.dev/posts/2017/solr-installs-with-sif
##
## private functions
##
#
# If necessary, download a file and unzip it to the specified location
#
function downloadAndUnzipIfRequired
{
Param(
@jermdavis
jermdavis / Install-Solr.ps1
Last active November 23, 2021 13:30
A PowerShell script to help installing Solr as a service - See https://blog.jermdavis.dev/posts/2017/low-effort-solr-installs for details
Param(
$solrVersion = "6.6.2",
$installFolder = "c:\solr",
$solrPort = "8983",
$solrHost = "solr",
$solrSSL = $true,
$nssmVersion = "2.24",
$JREVersion = "1.8.0_151"
)
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Sitecore.FiftyOneDegrees.CloudDeviceDetection.Services;
using Sitecore.FiftyOneDegrees.CloudDeviceDetection.Settings;
using Sitecore.FiftyOneDegrees.CloudDeviceDetection.System.Wrappers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Web;
@jermdavis
jermdavis / LoggingExample.cs
Last active May 29, 2017 13:15
Pipelines with a shared logging mechanism
using System;
namespace StronglyTypedPipelines
{
public interface ILoggingPipeline
{
void RaiseMessage(IPipelineStep sender, string message, object data);
}
public abstract class LoggingPipelineStep<INPUT, OUTPUT> : IPipelineStep<INPUT, OUTPUT>
using System;
namespace StronglyTypedPipelines
{
public abstract class BasePipelineStep<INPUT, OUTPUT> : IPipelineStep<INPUT, OUTPUT>
{
public event Action<INPUT> OnInput;
public event Action<OUTPUT> OnOutput;
// note need for descendant types to implement this, not Process()
@jermdavis
jermdavis / LoopStep.cs
Created October 26, 2016 11:17
A possible looped pipeline step for processing IEnumerable<> inputs
using System.Collections.Generic;
namespace StronglyTypedPipelines
{
public class LoopStep<INPUT,OUTPUT> : IPipelineStep<IEnumerable<INPUT>, IEnumerable<OUTPUT>>
{
private IPipelineStep<INPUT, OUTPUT> _internalStep;
public LoopStep(IPipelineStep<INPUT, OUTPUT> internalStep)