Skip to content

Instantly share code, notes, and snippets.

View rickbutterfield's full-sized avatar

Rick Butterfield rickbutterfield

View GitHub Profile
public static class StringExtensionMethods
{
public static string AddHeadingAnchorsToHtml(this string html)
{
var doc = new HtmlDocument();
doc.LoadHtml(html);
// select all possible headings in the document
var headings = doc.DocumentNode.SelectNodes("//h2");
if (headings != null)
{
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Linq;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Services;
using Umbraco.Extensions;
namespace Our.Umbraco.PersonalisationGroups.Core.Providers.MemberProfileField
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseUmbraco()
.WithMiddleware(u =>
{
u.UseBackOffice();
u.UseWebsite();
})
.WithEndpoints(u =>
{
public class MovieSerivce : IMovieService
{
private readonly IAppPolicyCache _runtimeCache;
private const string MOVIES_CACHE_KEY = "Movies.API.Cache";
public MovieSerivce(AppCaches appCaches)
{
_runtimeCache = appCaches.RuntimeCache;
}
@rickbutterfield
rickbutterfield / input.scss
Created September 23, 2020 14:30
Generated by SassMeister.com.
.loop1 {
@for $i from 1 through 2 {
&-#{$i} {
width: 100%;
max-width: (100% / 12) * $i;
flex-basis: (100% / 12) * $i;
}
&-#{$i}\@sm {
@media (min-width: 768px) {
max-width: (100% / 12) * $i;
@rickbutterfield
rickbutterfield / pco.css
Last active February 9, 2020 13:36
CSS for full screen PCO timer
.LiveApp-composition--overview {
background: #000 !important;
}
.LiveApp-composition--overview-wrapper {
display: grid !important;
grid-template-rows: 1fr 2fr 3fr 2fr;
}
.LiveApp-composition--overview .LiveClock-time-wrapper {
@rickbutterfield
rickbutterfield / polyfill.js
Last active November 25, 2020 18:03
Polyfill getTotalLength support for SVG circles on iOS
/**
* Polyfill SVG path support for iOS
*/
SVGCircleElement.prototype.getTotalLength = function() {
let width = this.parentNode.clientWidth, // Get the parent node width (trying to get the current node width returns 0)
radius = width / 2, // Get the radius by dividing by 2
length = 2 * Math.PI * radius; // Get the circumference from 2πr
// Return the calculated value
return length;
@rickbutterfield
rickbutterfield / Foundation_Off_Canvas_Menu.php
Last active November 26, 2016 15:41
A custom walker to support Foundation 5's off-canvas nav in WordPress
<?php
/**
* FoundationNavWalker by rickbutterfield
* Now lives at https://github.com/rickbutterfield/FoundationNavWalker
*/
class FoundationNavWalker extends Walker_Nav_Menu {
public function start_lvl( &$output, $depth = 0, $args = array() ) {
@rickbutterfield
rickbutterfield / web.config
Last active January 12, 2018 14:03
WordPress web.config for running PHP on IIS
<configuration>
<system.webServer>
<!-- URL rewriting so it doesn't have to use index.php -->
<rewrite>
<rules>
<rule name="wordpress" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />