Skip to content

Instantly share code, notes, and snippets.

View cassidydotdk's full-sized avatar

Mark Cassidy cassidydotdk

  • Cassidy Consult
  • Kiel, Germany
View GitHub Profile
@cassidydotdk
cassidydotdk / SetupIoc.config
Created May 18, 2016 01:45
Setup Castle Windsor for Sitecore 8.1
<?xml version="1.0"?>
<configuration>
<sitecore>
<pipelines>
<initialize>
<processor type="Website.SetupIoc, Website" />
</initialize>
</pipelines>
</sitecore>
</configuration>
using System.Diagnostics;
using System.Web;
using Sitecore.Mvc.Pipelines.Response.RenderRendering;
namespace Website.Pipelines.RenderRendering
{
public class PerformanceMeasurementProcessorBegin : RenderRenderingProcessor
{
public override void Process(RenderRenderingArgs args)
{
@cassidydotdk
cassidydotdk / RenderItem.cs
Created August 11, 2016 09:03
Quickly render a Sitecore Controller Rendering, using given Item as Datasource
public virtual HtmlString RenderItem(Item item, string controller, string action)
{
Assert.ArgumentNotNull(item, "item");
Assert.ArgumentNotNullOrEmpty(controller, "controller");
Assert.ArgumentNotNullOrEmpty(action, "action");
var r = new Rendering();
r.DataSource = item.Paths.FullPath;
using (RenderingContext.EnterContext(r))
{
@cassidydotdk
cassidydotdk / gist:519dee612ca4683a18303298a429715c
Created August 15, 2016 12:26
Controller Factory Handling - Sitecore 8.1 and Castle Windsor
using System.Web.Mvc;
using Castle.Windsor;
using Sitecore.Mvc.Controllers;
using Sitecore.Mvc.Pipelines.Loader;
using Sitecore.Pipelines;
using Interfaces.Managers.Windsor;
using ControllerBuilder = System.Web.Mvc.ControllerBuilder;
namespace Website
{
public virtual Tuple<string, string> GetAdaptiveImageUrls(Item item, string imageFieldName, int maxWidth = 300)
{
Assert.IsNotNull(item, nameof(item));
Assert.IsNotNullOrEmpty(imageFieldName, nameof(imageFieldName));
ImageField imageField = item.Fields[imageFieldName];
if (imageField?.MediaItem != null /*&& imageField.MediaItem.Versions.Count > 0*/)
{
string imageUrl = HashingUtils.ProtectAssetUrl(MediaManager.GetMediaUrl(imageField.MediaItem, new MediaUrlOptions {MaxWidth = maxWidth}));
@cassidydotdk
cassidydotdk / Install-Solr.ps1
Created April 12, 2019 12:23
Install-Solr.ps1
Param(
$installFolder = "c:\solr",
$solrPort = "8721",
$solrHost = "solr",
$solrSSL = $true,
$downloadFolder = "$PSScriptRoot"
)
$solrVersion = "7.2.1"
$solrName = "solr-$solrVersion"
@cassidydotdk
cassidydotdk / gulp-config.js
Last active January 31, 2023 15:49
Task to build and publish a .SLN file from gulp using "msbuild" instead of "gulp-msbuild". Version 16.0 for VS2019, use 15.0 for VS2017.
module.exports = function () {
var config = {
websiteRoot: "C:\\inetpub\\wwwroot\\sc911.sc",
sitecoreLibraries: "C:\\inetpub\\wwwroot\\sc911.sc\\bin",
hostName: "http://sc911.sc",
solutionName: "sc911",
buildConfiguration: "Debug",
runCleanBuilds: false,
toolsVersion: "16.0"
}
@cassidydotdk
cassidydotdk / Gulpfile.js
Last active July 1, 2019 22:30
Managing Unicorn targetDataStore in Gulp pipeline
var rename = require('gulp-rename');
var replace = require('gulp-replace');
...
gulp.task("B04-Sync-Unicorn",
function(callback) {
console.log("Executing Unicorn Sync");
gulp.src([path.resolve(config.websiteRoot + '/App_Config/Include/zzz/Unicorn.TargetDataStore.config.EDITME')])
@cassidydotdk
cassidydotdk / Setup Unicorn in Docker.txt
Last active September 27, 2019 19:22
How to configure Unicorn with a volume mapping for your CM server Docker container
How to set up Unicorn in your Docker container
Since all writing to Unicorn files happens inside the container, and the container is now linked to .\unicorn,
all you need to do is ensure that .\unicorn is included under source control.
This gets even better if you use Transparent Sync.
- Create your VM as normal, get Windows installed and so on
- Power the VM down, to "Off" state
- On the HOST pc, execute the following 2 commands from an elevated Powershell prompt
Set-VMProcessor -VMName "Name of your VM" -ExposeVirtualizationExtensions $true
Get-VMNetworkAdapter -VMName "Name of your VM" | Set-VMNetworkAdapter -MacAddressSpoofing On
- Start up the VM again
- Inside the VM, execute the following command from an elevated Powershell prompt