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 / strategy-pattern.js
Last active December 13, 2017 22:27
Strategy Pattern JS example
// Example. Let's sort the apples, pears, and oranges into the right baskets.
const fruits = ["apple", "pear", "apple", "apple", "orange", "pear", "orange", "pear", "apple"]
let appleBasket = []
let pearBasket = []
let orangeBasket = []
let strategies = []
const appleSortStrategy = (fruit) => {
@glcheetham
glcheetham / react-state-strategy-pattern.js
Created May 20, 2016 19:19
React state with strategy pattern
// Example of a React state. Manage this with Flux, Redux, black magic, etc...
import AccountFields from '../Components/AccountFields'
import SurveyFields from '../Components/SurveyFields'
import Confirmation from '../Components/Confirmation'
let pages = [
{"Title": "Account Fields", "ActiveComponent": React.createFactory(AccountFields) },
{"Title": "Survey Fields", "ActiveComponent": React.createFactory(SurveyFields) },
{"Title": "Confirmation", "ActiveComponent": React.createFactory(Confirmation) }
]
@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 / UmbracoApplication.cs
Created May 27, 2016 21:41
Umbraco IOC Implementation that works properly
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;