Skip to content

Instantly share code, notes, and snippets.


Brandon Sheppard brandonsheppard

View GitHub Profile
brandonsheppard / worker.js
Created May 31, 2020 00:14
Redirect to naked domain — Cloudflare Worker
View worker.js
addEventListener('fetch', event => {
async function handleRequest(request) {
const pageURL = new URL(request.url);
return Response.redirect(`${pageURL.protocol}//${String(}${pageURL.pathname}${}`)
brandonsheppard /
Created September 5, 2019 23:11
Sum and search by content and date (parsed) in Google visual query language
=iferror(sum(query(Transactions!$A:$F,"select D where B contains '"&$A11&"' and A = date '"&text(F$1,"yyyy-mm-dd")&"'")))
brandonsheppard / gist:89476f18fbb6a3f4c6ed0190e2e28395
Created March 18, 2019 06:34
Find all cached sub-pages in
View gist:89476f18fbb6a3f4c6ed0190e2e28395*/URL/*

brandonsheppard / gist:8e9b40a4be8462e0c68452adc4835404
Created November 12, 2018 21:04
Conditional format — highlight last month
View gist:8e9b40a4be8462e0c68452adc4835404
// assumes date in cell is the 1st
brandonsheppard /
Last active December 28, 2017 04:55
Format release notes MD from JSON.


Pass commit data into this function to format a markdown commit note. Data structure is based on what Github's compare endpoint returns.

This is useful for generating a changelog for release notes based on git activity.

Example data:

Based on response from Github's compareCommits endpoint.

brandonsheppard /
Created December 28, 2017 04:51
Generate chronological version number based on previous version number


This function generates a date-based version number. Year + Month + Iteration

So, the first release in March 2017 will be 17.3.0

If multiple releases occur in a month, the final number will increase. Otherwise, an entirely new verion number will be generated.


brandonsheppard / demo.js
Last active November 23, 2017 23:46
Simple form event logging with Performance Web API and jQuery
View demo.js
// Run on page load
$('input').on('focus blur',function(e){
performance.mark(e.type+ ' ' +
// Run to see results
View gist:8aa77c4b061287e437a9beaec0a3b210
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
observer.observe(document.getElementById('bill_selector'), {
attributes: true,
childList: true,
characterData: true
brandonsheppard /
Created August 10, 2016 05:03
Show a modal to query the shoppers country if they aren't in Australia
<div class="modal fade" id="shipCountryModal" tabindex="-1" role="dialog" aria-labelledby="shipCountryModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form method="post" action="[@url@]">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Hello, international shopper!</h4>
<div class="modal-body">
<p>It looks like you're not shopping from Australia, where we are based&mdash;select your country below and we'll ensure you're not seeing prices which include Australia-specific taxes.</p>
brandonsheppard /
Created July 26, 2016 05:45
How to use $.nShowActivity('.nactivity')

You need to add a FontAwesome loader to this div. There are a list of options here.

You then simply need to run the function when you need the loader to display: