Skip to content

Instantly share code, notes, and snippets.

View glcheetham's full-sized avatar

glcheetham glcheetham

View GitHub Profile
@glcheetham
glcheetham / spec.js
Created May 30, 2016 09:31
Chai object comparison (wrong)
expect({
name: 'Tiger',
species: 'Felis Catus',
favouriteSnack: 'Tuna',
schedule: {
breakfast: '08:00',
naptime: '10:00',
dinner: '12:00',
tea: '18:00'
}
@glcheetham
glcheetham / spec.js
Created May 30, 2016 09:34
Chai object comparison (right)
describe('housecat comparison', () => {
it('should let me know that both objects are the same', () => {
expect({
name: 'Tiger',
species: 'Felis Catus',
favouriteSnack: 'Tuna',
schedule: {
breakfast: '08:00',
naptime: '10:00',
@glcheetham
glcheetham / UmbracoLinqpad.cs
Last active July 23, 2016 11:27
Umbraco LINQPad CSV Import
// Helper method enumerates over and returns lines in a file
static IEnumerable<string> ReadFrom(string file)
{
string line;
using(var reader = System.IO.File.OpenText(file))
{
while((line = reader.ReadLine()) != null)
{
yield return line;
}
@glcheetham
glcheetham / Web.debug.config
Created August 8, 2016 14:33
Web.debug.config to trigger Umbraco setup
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="umbracoConfigurationStatus" value="" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
</appSettings>
</configuration>
@glcheetham
glcheetham / Web.debug.config
Created August 8, 2016 14:40
Web.debug.config if you already have Umbraco set up
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
Set your connection string in the XML snippet below
-->
<connectionStrings>
<add name="umbracoDbDSN"
@glcheetham
glcheetham / TXTFile.cshtml
Created October 2, 2016 13:00
Text File Umbraco Template
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = null;
umbraco.library.ChangeContentType("text/plain");
}
@(Model.Content.GetPropertyValue<string>("fileContent"))
@glcheetham
glcheetham / UrlRewriting.xml
Created October 2, 2016 13:25
Line to add in UrlRewriting.config to rewrite your robots.txt URL
<add name="robots-rewrite"
virtualUrl="^~/robots.txt"
destinationUrl="~/robotstxt"
/>
@glcheetham
glcheetham / XMLSitemap.cshtml
Last active October 12, 2016 16:35
Example dynamic Umbraco sitemap.xml template
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = null;
umbraco.library.ChangeContentType("text/xml");
}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
@foreach (var root in Umbraco.TypedContentAtRoot())
{
@glcheetham
glcheetham / ResourceService.cs
Created January 29, 2017 11:30
Loosely-Coupled Class Which uses APIs from UmbracoHelper
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MyProject.Models;
using Umbraco.Web;
using Our.Umbraco.Ditto;
namespace MyProject.Services
{
@glcheetham
glcheetham / Startup.cs
Created January 29, 2017 11:33
Using Inversion of Control with UmbracoHelper
builder.RegisterInstance(umbracoHelper.ContentQuery).As<ITypedPublishedContentQuery>();
builder.RegisterType<ResourceService>().As<IResourceService>();