Skip to content

Instantly share code, notes, and snippets.

View benmccallum's full-sized avatar

Ben McCallum benmccallum

View GitHub Profile
@benmccallum
benmccallum / MSSQL Server - Kill all processes on a DB.sql
Last active August 29, 2015 14:24
MSSQL Server - Kill all processes on a DB
USE master;
GO
ALTER DATABASE AdventureWorks
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
ALTER DATABASE AdventureWorks
SET MULTI_USER;
GO
@benmccallum
benmccallum / CSS - Vertical align.css
Created July 3, 2015 02:08
CSS - Vertical align
.parent-element {
transform-style: preserve-3d;
}
.element {
position: relative;
top: 50%;
transform: translateY(-50%);
}
@benmccallum
benmccallum / PostWFFM800Script.ashx
Created January 11, 2016 11:01
Web Forms for Marketers rev. 141217 manual fixes script
<%@ WebHandler Language="C#" Class="PostWFFM800Script" %>
using System;
using System.Linq;
using Sitecore.sitecore.admin;
using Sitecore.Data.Items;
using Sitecore.Data;
using System.Xml.Linq;
using System.Collections.Generic;
using Sitecore.SecurityModel;
@benmccallum
benmccallum / Test.ps1
Created January 31, 2016 23:21
Automate VM shutdown/startup with timezone offset
$TimezoneOffset = -6
$currentTime = (Get-Date).ToUniversalTime()
Write-Output "Runbook started"
Write-Output "Current UTC/GMT time [$($currentTime.ToString("dddd, yyyy MMM dd HH:mm:ss"))] will be checked against schedules"
Write-Output "A TimeZone offset of [$TimezoneOffset] will be used in comparisons"
$TimeRange = "29 January"
# Initialize variables
@benmccallum
benmccallum / Query.sql
Created January 31, 2016 23:21
Find all Sitecore items under /sitecore/content with $name in a field
WITH ItemsWithFullPath (id, name, fullpath)
AS
(
SELECT ID, Name, cast(name as nvarchar(max)) as fullpath
FROM [dbo].Items
WHERE ParentID = '00000000-0000-0000-0000-000000000000'
UNION ALL
SELECT i.ID, i.Name, cast((fullpath +'/' + i.name) as nvarchar(max)) as fullpath
FROM [dbo].items i
INNER JOIN ItemsWithFullPath a on i.ParentID = a.id
@benmccallum
benmccallum / ChangeSearchProvider.ps1
Last active February 15, 2016 12:43 — forked from patrickperrone/ChangeSearchProvider.ps1
This PowerShell script will change your Sitecore instance search provider from Lucene to Solr or vice versa. It can be called from a build process to do so.
Function Set-SCSearchProvider
{
param([string]$choice, [string]$rootPath)
$validInput = $true;
#test that path is valid
If (!(Test-Path -Path $rootPath))
{
Write-Host "The supplied path was invalid or inaccessible." -ForegroundColor Red;
$validInput = $false;
@benmccallum
benmccallum / Index.cshtml
Last active August 3, 2016 04:37
EPiServer - Detecting Block editing
@using EPiServer.Core
@using EPiServer.Editor
@using EPiServer.Web.Mvc.Html
@model MyWebsite.Models.BlockTypes.EmergencyNotificationBlock
<div class="card-static full">
<div class="emergency-notification">
<div class="icon @Model.AlertType.ToString().ToLower()"></div>
<div class="wrapper">
@benmccallum
benmccallum / GraphiQLDeveloperPageExtensions.cs
Created March 29, 2018 09:05
Easiest way to serve GraphiQL page in ASP.NET Core
using Microsoft.AspNetCore.Http;
using System.Net.Http;
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Extension methods for registering the GraphiQL interface middleware.
/// </summary>
public static class GraphiQLDeveloperPageExtensions
{
using System;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.Extensions.Configuration;
// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.DependencyInjection
{
public static class WebApiServiceCollectionExtensions
Param(
[string]$windowsUser,
[string]$sourceRootPath
)
yarn global add undefender
undefender "C:\Program Files\nodejs"
if (![string]::IsNullOrWhiteSpace(($windowsUser))) {