Skip to content

Instantly share code, notes, and snippets.

View dsolovay's full-sized avatar

Dan Solovay dsolovay

View GitHub Profile
using System;
using NSubstitute;
using Sitecore.Data;
using Sitecore.Events;
using Sitecore.FakeDb;
using TestableHandler.Handlers;
using TestableHandler.Wrappers;
using Xunit;
namespace TestableHandler.UnitTests
@dsolovay
dsolovay / SampleLayout.aspx
Last active July 24, 2017 09:23
SampleLayout.ascx that displays in memory automation states.
<%@ Import Namespace="Sitecore.Analytics"%>
<%@ Import Namespace="Sitecore.Analytics.Automation.Data"%>
<%@ Import Namespace="Sitecore.Analytics.Automation.MarketingAutomation"%>
<%@ Import Namespace="Sitecore.Data"%>
<%@ Page Language="c#" Inherits="System.Web.UI.Page" CodePage="65001" %>
<%@ Register TagPrefix="sc" Namespace="Sitecore.Web.UI.WebControls" Assembly="Sitecore.Kernel" %>
<%@ OutputCache Location="None" VaryByParam="none" %>
<!DOCTYPE html>
<script runat="server">
@dsolovay
dsolovay / CascadeField.cs
Last active August 29, 2015 14:21
FakeDB Samples
using Sitecore.Data.Items;
using Sitecore.Data.Query;
namespace fakedb.Layout.Sublayouts
{
public class CascadeField
{
private readonly string _fieldName;
public CascadeField(string fieldName)
@dsolovay
dsolovay / AutofacConfig.cs
Last active August 29, 2015 14:21
Sitecore TDD with Glass
using System;
using System.Reflection;
using System.Web.Mvc;
using Autofac;
using Autofac.Integration.Mvc;
using Glass.Mapper.Sc;
namespace AutofacDemo
{
public class AutofacConfig
@dsolovay
dsolovay / Life.fs
Last active August 29, 2015 14:01
Simple Life implementation in F#
let rec MakeRow (length: int) (value: int) =
if length=0 then []
else value :: MakeRow (length - 1) value
let rec MakeGrid (n: int) (rowMaker) =
if n=0 then []
else rowMaker :: MakeGrid (n - 1) rowMaker
let MakeLifeGrid x = MakeGrid x (MakeRow x 0)
@dsolovay
dsolovay / SOLR and Autofac.md
Last active December 31, 2015 15:39
Issue wiring up SOLR + MVC + Autofac

#Issue

SOLR code requires this:

 new AutoFacSolrStartUp(new ContainerBuilder()).Initialize();

The Initialize method does not expose the container, but instead wraps in a ServiceLocator:

 ServiceLocator.SetLocatorProvider((ServiceLocatorProvider) (() => (IServiceLocator) new AutofacServiceLocator((IComponentContext) this.container)));
@dsolovay
dsolovay / gist:1037200
Created June 21, 2011 03:47
Git tips and tricks
Is git status running slow? It should take more than a second or two. Try running "git gc" (garbage collect) to speed things up.