Skip to content

Instantly share code, notes, and snippets.

View peteeveleigh's full-sized avatar

Pete Eveleigh peteeveleigh

View GitHub Profile
@peteeveleigh
peteeveleigh / postcodeCheck.twig
Created March 17, 2022 10:59
Get outbound part of UK postcode using Twig (handy for Craft Commerce shipping rules)
{# These are the valid UK postcode formats
according to https://ideal-postcodes.co.uk/guides/uk-postcode-format #}
{% set zipCodes = [
'AA9A 9AA',
'A9A 9AA',
'A9 9AA',
'A99 9AA',
'AA9 9AA',
'AA99 9AA'
@peteeveleigh
peteeveleigh / dates.twig
Created March 18, 2021 17:22
Twig for figuring out number of days between 2 dates minus weekends/holidays
{% set start = '2020-01-01' %}
{% set end = '2021-03-17' %}
{% set holidays = ['2020-12-25', '2020-12-26', '2021-01-01'] %}
{% set difference = date(end).diff(date(start)) %}
{% set count = 0 %}
{% for i in 0..difference.days %}
{% set thisDay = start|date_modify(i ~ 'days') %}
{% set count = count + ((thisDay|date('D') not in ['Sun','Sat']) and (thisDay|date('Y-m-d') not in holidays)) %}
@peteeveleigh
peteeveleigh / _cart-debug.twig
Created February 23, 2019 15:25 — forked from mdcpepper/_cart-debug.twig
Craft Commerce debugging template
{% if craft.config.get('devMode') %}
{% set size = 30 %}
<pre style="width:80%;margin:0 auto">
Line Items:
---------------------------------------------------
{% for lineItem in cart.lineItems %}
{{ lineItem.purchasable.title }} x {{ lineItem.qty }} {{ dump(lineItem.options) }}
{% endfor %}
@peteeveleigh
peteeveleigh / rats.twig
Created November 16, 2018 17:55
RATS sequence generator in TWIG
{#
http://mathworld.wolfram.com/RATSSequence.html
A sequence produced by the instructions "reverse, add to the original, then sort the digits." For example, after 668, the next iteration is given by
668+866=1534,
so the next term is 1345.
Applied to 1, the sequence gives 1, 2, 4, 8, 16, 77, 145, 668, 1345, 6677, 13444, 55778, 133345, 666677, 1333444, 5567777, 12333445, 66666677, 133333444, 556667777, 1233334444, 5566667777, 12333334444, 55666667777, 123333334444, 556666667777, 1233333334444,
#}
.calendar {
tbody td {
border: 1px solid #dedede;
}
&__day {
&--available {
}
@peteeveleigh
peteeveleigh / payment.html
Created November 27, 2017 14:52
Basic method for doing custom Stripe checkout form with Craft Commerce
{% if cart.paymentMethodId %}
<form method="POST" class="form" {% if cart.paymentMethod.class == 'Stripe' %}id="payment-form"{% endif %}>
<input type="hidden" name="action" value="commerce/payments/pay"/>
<input type="hidden" name="redirect" value="/checkout/complete?number={number}"/>
<input type="hidden" name="cancelUrl" value="/checkout/cancelled"/>
{{ getCsrfInput() }}
{% if errors is defined %}
@peteeveleigh
peteeveleigh / index.php
Created July 5, 2017 20:51
PHP function to determine whether or not 2 lat/lon points are within a specified distance of each other (Great Circle)
<?php
$pointA = array(
'lat' => 51.863119,
'lon' => -2.21064
);
$pointB = array(
'lat' => 51.957807,
'lon' => -2.640603
@peteeveleigh
peteeveleigh / gist:94523eac6cd0876b799cd88aba252f93
Created May 9, 2016 17:37
Sample of Google Analytics transaction tracking for ExpressionEngine and Cartthrob
ga('require', 'ecommerce'); // Load the ecommerce plug-in.
ga('ecommerce:addTransaction', {
'id': '{order_id}', // Transaction ID. Required
'affiliation': '{site_name}', // Affiliation or store name
'revenue': '{exp:cartthrob:view_formatted_number number="{order_total}" prefix="" decimals="2" dec_point="." thousands_sep="" }', // Sub Total
'shipping': '{exp:cartthrob:view_formatted_number number="{order_shipping}" prefix="" decimals="2" dec_point="." thousands_sep="" }', // Shipping
'tax': '{exp:cartthrob:view_formatted_number number="{order_tax}" prefix="" decimals="2" dec_point="." thousands_sep="" }' // Tax
});

Tiny Content Framework

About the Project

This is a tiny content strategy framework focused on goals, messages, and branding. This is not a checklist. Use what you need and scrap the rest. Rewrite it or add to it. These topics should help you get to the bottom of things with clients and other people you work with.

Contribute

There’s more to come, and I’d love to hear what you think. Give me feedback on Twitter (@nicoleslaw) or by email ([email protected]). We all benefit from sharing our ideas and creating standards. Onward.

@peteeveleigh
peteeveleigh / _prefixes.scss
Last active August 29, 2015 14:01
Sass/SCSS Mixin to create vendor prefixes on any property:value pair
/*
Mixin to add vendor prefixes to any property:value
By default prefixes for -moz and -webkit will be created
By specifying a list as the third parameter a custom list of prefixes can be made
e.g.
.cheese {
@include prefix($foo,$bar,(moz,webkit,o,ms));
}