Skip to content

Instantly share code, notes, and snippets.

View glcheetham's full-sized avatar

glcheetham glcheetham

View GitHub Profile
@glcheetham
glcheetham / javascript-uk-number-plate-validation.md
Last active March 6, 2024 12:59 — forked from danielrbradley/uk-number-plate-validation.md
Javascript Regular Expression to Validate UK Number Plates

Javascript Regular Expression to Validate UK Number Plates

Regular Expression

Works in jQuery, React, Angular, Javascript es6 and es5

(^[A-Z]{2}[0-9]{2}\s?[A-Z]{3}$)|(^[A-Z][0-9]{1,3}[A-Z]{3}$)|(^[A-Z]{3}[0-9]{1,3}[A-Z]$)|(^[0-9]{1,4}[A-Z]{1,2}$)|(^[0-9]{1,3}[A-Z]{1,3}$)|(^[A-Z]{1,2}[0-9]{1,4}$)|(^[A-Z]{1,3}[0-9]{1,3}$)

Source information

Forked from here but updated to work in JavaScript, and added an optional space

@glcheetham
glcheetham / App.jsx
Created October 7, 2017 11:51
JSX Bootstrap 3 Kitchen Sink
const KitchenSink = () => (<div classNameName="App">
<div className="navbar navbar-default navbar-static-top">
<div className="container">
<div className="navbar-header">
<button type="button" className="navbar-toggle" data-toggle="collapse" data-target=".header-collapse">
<span className="sr-only">Toggle navigation</span> <span className="icon-bar"></span> <span className="icon-bar"></span> <span className="icon-bar"></span>
</button>
<a className="navbar-brand" href="#">Kitchen Sink</a>
</div>
@glcheetham
glcheetham / Example.cs
Created January 29, 2017 11:39
Example instantiation of loosely-coupled class which depends on UmbracoHelper
var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
// Or from any other environment that comes with UmbracoHelper already available https://our.umbraco.org/documentation/reference/querying/umbracohelper/
// UmbracoHelper.ContentQuery implements the ITypedContentQuery interface
var resourceService = new ResourceService(umbracoHelper.ContentQuery);
@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>();
@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 / 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 / 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 / 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 / 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 / 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>