Skip to content

Instantly share code, notes, and snippets.

@murven
murven / test.csproj
Created July 9, 2016 00:29
Generate web.config file and other config files from a base file and XSLT transforms
<Target Name="BeforeBuild">
<TransformXml Source="Web.base.config" Transform="Web.$(Configuration).config" Destination="Web.config" />
<TransformXml Source="config\FileSystemProviders.base.config" Transform="config\FileSystemProviders.$(Configuration).config" Destination="config\FileSystemProviders.config" />
</Target>
@murven
murven / execute-sql-scripts-in-current-folder.ps1
Last active March 31, 2020 16:56
Execute all scripts in a folder (PowerShell)
function Rename-Script-File ($sourceFile, $targetFile)
{
If ((Test-Path $targetFile) -and (Test-Path $sourceFile))
{
Remove-Item $targetFile
}
If (Test-Path $sourceFile)
{
Rename-Item $sourceFile $targetFile
}
@murven
murven / publish-current-item.ps1
Created April 26, 2016 15:52
Publish current item in sitecore powershell console
Get-Item . | Publish-Item -Recurse -PublishMode Full
@murven
murven / project.csproj
Created April 26, 2016 15:19
Exclude files from deployment
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
<ExcludeFilesFromDeployment>File1.aspx;Folder2\File2.aspx</ExcludeFilesFromDeployment>
<ExcludeFilesFromDeployment>**\.svn\**\*.*</ExcludeFilesFromDeployment>
<ExcludeFoldersFromDeployment>Folder1;Folder2\Folder2a</ExcludeFoldersFromDeployment>
</PropertyGroup>
@murven
murven / Write-Renderings.ps1
Last active April 6, 2016 22:10
Sitecore PowerShell Script to show renderings per content item
$targetFileName = 'c:\temp\ItemRenderings.txt'
function Show-Rendering
{
param ($renderingItem)
$renderingName = $renderingItem.Name
$renderingId = $renderingItem.Id
$placeholderName = $renderingItem.Placeholder
"Rendering Item: $renderingId | $renderingName | $placeholderName" | Out-File $targetFileName -Append
}
$devices = [Sitecore.Configuration.Factory]::GetDatabase("master").Resources.Devices.GetAll()
@murven
murven / project.csproj
Created March 15, 2016 01:14
Include all Unicorn files in the project in a single content tag in csproj file
<Content Include="Sitecore_Data\Unicorn\Default Configuration\\**\*.yml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@murven
murven / vsdiffmerge.ps1
Created March 11, 2016 09:32
Visual Studio 2015 Diff Tool
& 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\vsdiffmerge' "file1.txt" "file2.txt"
@murven
murven / Master.cshtml
Created March 8, 2016 18:52
Sitecore Master Layout
@using Sitecore.Mvc.Presentation
@using Sitecore.Mvc
@model RenderingModel
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
@murven
murven / gist:a629784004ba072405f9
Created May 27, 2015 17:33
ASP.NET list all cookies
<% foreach (var key in Request.Cookies.AllKeys)
{
Response.Write(string.Format("Key:{0}|Value:{1}|\r\n", key, Request.Cookies[key].Value));
} %>
@murven
murven / DependencyObjectExtensions.cs
Created January 16, 2012 23:16
WPF - Dependency object extensions
public static class DependencyObjectExtensions
{
/// <summary>
/// Creates a new instance of the same type and copies all properties and values.
/// </summary>
/// <typeparam name="T">A type that extends DependencyObject</typeparam>
/// <param name="source"></param>
/// <returns>A new instance that represents a copy of the properties and values of the original instance.</returns>