Skip to content

Instantly share code, notes, and snippets.

View glcheetham's full-sized avatar

glcheetham glcheetham

View GitHub Profile
@glcheetham
glcheetham / gist:dfe7e29c841dc1e53942
Last active March 1, 2016 15:32
Umbraco Image Pagination Concept Explain
@{
@* Pagination Logic *@
var postsPerPage = 5;
var allPosts = Model.Content.GetPropertyValue<string>("images").Split(',');
allPosts.ToList().ForEach(i => i = Umbraco.TypedMedia(i));
var totalPages = Math.Ceiling((double)(allPosts.Count() / (double)postsPerPage));
var currentPageNo = int.Parse(Request.QueryString["p"] ?? "1");
@glcheetham
glcheetham / package-umbraco-for-deployment.md
Created April 5, 2016 12:16
How to package an Umbraco site for deployment

How to package an Umbraco site for deployment

Files to include in the package

Steps to take after installing the package

eg. what to modify in web.config

@glcheetham
glcheetham / dont-panic.html
Created April 29, 2016 19:55
A witty random-gif "service unavailable" placeholder
<!DOCTYPE>
<html>
<head>
<title>Service Moved</title>
<style>
body {
font-family: "Lucida Console", Monaco, monospace;
}
</style>
</head>
@glcheetham
glcheetham / react-component-strategy-pattern.js
Last active May 20, 2016 19:23
React component using strategy pattern instead of switch
// React componey using the strategy pattern instead of switch
import React from 'react'
const Registration extends React.Component {
constructor(props) {
super(props)
}
render() {
@glcheetham
glcheetham / UmbracoApplication.cs
Created May 27, 2016 21:01
Umbraco DI Composition Root
using Autofac;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;
using Umbraco.Core;
using Umbraco.Core.Services;
namespace MyApplication
@glcheetham
glcheetham / MyContentService.cs
Created May 27, 2016 21:17
Class that we can inject an Umbraco IContentService into
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
namespace MyApp.Services
{
@glcheetham
glcheetham / UmbracoApplication.cs
Last active May 27, 2016 21:35
UmbracoApplication with components registered in the DI container
using Autofac;
using Autofac.Integration.Mvc;
using Autofac.Integration.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;
using MyApp.Services;
using MyApp.Services.Interfaces;
@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 / 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>