Skip to content

Instantly share code, notes, and snippets.


Thomas Morris tcmorris

View GitHub Profile
tcmorris / github-action-nodejs.yml
Created Aug 20, 2020
Example GitHub Action for building with node.js
View github-action-nodejs.yml
name: Build node.js
on: [push]
runs-on: ubuntu-latest
tcmorris / github-action-dotnet.yml
Created Aug 20, 2020
Example GitHub Action for building and deploying a .NET Core app to Azure.
View github-action-dotnet.yml
name: Build and deploy to Azure
on: [push]
PROJECT_DIR: yourapp/path
AZURE_WEBAPP_NAME: yourapp-name
View CustomMigrationEventHandler
public class CustomMigrationEventHandler : ApplicationEventHandler
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
// check target version
var rawTargetVersion = ConfigurationManager.AppSettings["app:MigrationVersion"] ?? "1.0.0";
var targetVersion = SemVersion.Parse(rawTargetVersion);
if (targetVersion != null)
tcmorris / archive.html
Last active Jul 2, 2017
Example events listing in Jekyll
View archive.html
{% include events.html previous=true year="2017" %}
tcmorris / MediaEventHandler.cs
Last active Jun 15, 2017
Event Handler for checking media uploads in Umbraco
View MediaEventHandler.cs
/// <summary>
/// MediaEventHandler
/// Will hook into the MediaService saving event and apply some custom logic to ensure we have a valid media file.
/// </summary>
public class MediaEventHandler : ApplicationEventHandler
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
MediaService.Saving += MediaService_Saving;
View RegexPatterns.cs
public static class RegexPatterns
public const string Postcode = "^(GIR 0AA|gir 0aa|[A-PR-UWYZa-pr-uwyz]([0-9]{1,2}|([A-HK-Ya-hk-y][0-9]|[A-HK-Ya-hk-y][0-9]([0-9]|[ABEHMNPRV-Yabehmnprv-y]))|[0-9][A-HJKPS-UWa-hjkps-uw]) {0,1}[0-9][ABD-HJLNP-UW-Zabd-hjlnp-uw-z]{2})$";
public const string EmailAddress = "^[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z0-9-]{2,63}$";
tcmorris / deploy.targets
Last active Aug 29, 2015
MSBuild targets for config transforms. Will pick up any *.config in root or config folder per environment and also allows for machine specific transforms.
View deploy.targets
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="">
<UsingTask TaskName="TransformXml" AssemblyFile=".\Deploy\Microsoft.Web.Publishing.Tasks.dll" />
<ConfigFiles Include=".\*.$(Environment).config;.\config\*.$(Environment).config">
<ConfigFiles Include=".\*.$(COMPUTERNAME).config;.\config\*.$(COMPUTERNAME).config">
tcmorris / redirect
Last active Aug 29, 2015
Using a custom domain for accessing umbraco
View redirect
<!-- Restrict access to Umbraco -->
<rule name="Restrict access" stopProcessing="true">
<match url="umbraco(?!/Surface/)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTP_HOST}" matchType="Pattern" pattern=""
ignoreCase="true" negate="true" />
<action type="Redirect" url="/not-found" appendQueryString="false" />
tcmorris / X-Robots-Tag
Last active Aug 29, 2015
Pages should not show in search results, links should not be followed and images should not be indexed.
View X-Robots-Tag
Avoid search engines (Google, Yahoo, etc) indexing website's content
This method is preferred to using robots.txt, which may still cause your site to
show in search engine result pages even if you have set to disallow.
tcmorris / PageNotFoundContentFinder.cs
Created Dec 16, 2014
Page not found content finder for Umbraco
View PageNotFoundContentFinder.cs
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Web;
using Umbraco.Web.Routing;
public class PageNotFoundContentFinder : IContentFinder
public bool TryFindContent(PublishedContentRequest request)
You can’t perform that action at this time.