Skip to content

Instantly share code, notes, and snippets.

@brandonsheppard
brandonsheppard / gist:74e203d1e25a8af20255
Created July 6, 2014 23:26
Standard Neto Shipping Calculator
<div class="panel panel-default" id="shipbox">
<div class="panel-heading">
<h3 class="panel-title">Calculate Shipping</h3>
</div>
<div class="panel-body">
<div class="row btn-stack">
<div class="col-xs-12 col-md-3">
<input type="number" name="input" id="n_qty" value="[@qty@]" size="2" class="form-control" placeholder="Qty">
</div>
<div class="col-xs-12 col-md-3">
@brandonsheppard
brandonsheppard / worker.js
Created May 31, 2020 00:14
Redirect to naked domain — Cloudflare Worker
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const pageURL = new URL(request.url);
return Response.redirect(`${pageURL.protocol}//${String(pageURL.host).substring(4)}${pageURL.pathname}${pageURL.search}`)
}
@brandonsheppard
brandonsheppard / how.md
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
brandonsheppard / 1custom.md
Last active March 21, 2019 23:16
Setup basic geoIP

This is the correct way to do this

<script src="//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js" type="text/javascript"></script>
<script type="text/javascript">
	var queryCountry = (function () {
		var onSuccess = function (geoipResponse) {
			var popupstatus = $.cookie('popupstatus')
			var country = geoipResponse.country.iso_code
 if(popupstatus != 'popped' &amp;&amp; country != 'AU'){
@brandonsheppard
brandonsheppard / gist:89476f18fbb6a3f4c6ed0190e2e28395
Created March 18, 2019 06:34
Find all cached sub-pages in web.archive.org
https://web.archive.org/web/*/URL/*

e.g.,

https://web.archive.org/web/*/https://github.com/NetoECommerce/Skeletal/*
@brandonsheppard
brandonsheppard / gist:8e9b40a4be8462e0c68452adc4835404
Created November 12, 2018 21:04
Conditional format — highlight last month
=date(year(edate(today(),-1)),MONTH(edate(today(),-1)),1)
// assumes date in cell is the 1st
@brandonsheppard
brandonsheppard / custom.js
Last active October 10, 2018 23:57
Query the location of a customer with MaxMind and produce a popup
// If country is AU, do nothing.
// If country is NZ, a NZ-specific pop-up
// If any other country (not AU or NZ), a generic international pop-up
var nzPopup = function() {
// Code to pop up the NZ popup
};
var internationalPopup = function() {
// Code for everyone else
};
@brandonsheppard
brandonsheppard / gist:932bb2c5d5090f0fe4c6
Last active January 15, 2018 04:56
Check if a category has an image using B@SE
[%set [@hasimage@]%][%asset_url type:'content' id:'[@content_id@]' default:''/%][%/set%]
[%if [@hasimage@]%][%asset_url type:'content' id:'[@content_id@]' default:''/%][%/if%]
@brandonsheppard
brandonsheppard / how.md
Last active December 28, 2017 04:55
Format release notes MD from JSON.

formatNotes()

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
brandonsheppard / how.md
Created December 28, 2017 04:51
Generate chronological version number based on previous version number

generateVersionNumber()

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.

i.e.