Skip to content

Instantly share code, notes, and snippets.

View croxton's full-sized avatar
💭
Up to my elbows, as usual

Mark Croxton croxton

💭
Up to my elbows, as usual
View GitHub Profile
@croxton
croxton / post-deploy.md
Last active June 6, 2019 17:44
Buddy Works Craft 3 post-deployment atomic deployment action

atomic-deploy-pipeline

if [ -d "releases/${execution.to_revision.revision}" ] && [ "${execution.refresh}" = "true" ]; then echo "Removing: releases/${execution.to_revision.revision}" && rm -rf releases/${execution.to_revision.revision}; fi
if [ ! -d "releases/${execution.to_revision.revision}" ]; then echo "Creating: releases/${execution.to_revision.revision}" && cp -dR deploy-cache releases/${execution.to_revision.revision}; fi
echo "Creating: persistence directories"
mkdir -p storage/craft
mkdir -p storage/cpresources
mkdir -p storage/uploads
@croxton
croxton / .env.php
Last active March 20, 2019 19:23
Craft 3 live previews across different root (or sub) domains
<?php
// In general.php define an alias:
'aliases' => [
'@baseUrl' => getenv('CRAFTENV_BASE_URL')
],
// In the CP, set the Base URL for each site to @baseUrl/
// When previewing, the CP will therefore always use the hostname the editor logged into as the base url for the preview
// (that happens with 'new' entries anyway regardless of base url, but existing entries use base url).
@croxton
croxton / critical-css-with-js.twig
Last active November 3, 2020 08:30
Inline critical CSS with JS (Craft CMS)
{% set _inline_css_block = block('_inline_css') %}
{% if _inline_css_block is not empty %}
<script>
(function() {
/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
!function(e){"use strict";var n=function(n,t,o){function i(e){return a.body?e():void setTimeout(function(){i(e)})}function r(){l.addEventListener&&l.removeEventListener("load",r),l.media=o||"all"}var d,a=e.document,l=a.createElement("link");if(t)d=t;else{var s=(a.body||a.getElementsByTagName("head")[0]).childNodes;d=s[s.length-1]}var f=a.styleSheets;l.rel="stylesheet",l.href=n,l.media="only x",i(function(){d.parentNode.insertBefore(l,t?d:d.nextSibling)});var u=function(e){for(var n=l.href,t=f.length;t--;)if(f[t].href===n)return e();setTimeout(function(){u(e)})};return l.addEventListener&&l.addEventListener("load",r),l.onloadcssdefined=u,u(r),l};"undefined"!=typeof exports?exports.loadCSS=n:e.loadCSS=n}("undefined"!=typeof global?global:this);
!function(t){"use strict";t.loadCSS||(t.loadCSS=function(){});var e=loadCSS.relpreload={
@croxton
croxton / expresso_store_uk_postcodes.txt
Created November 27, 2017 10:30
Expresso Store match specific UK postcodes
Allow shipping rules to accept regex
***************************************************************
First, change the `postcode` column in `exp_store_shipping_rules` to type varchar(255).
./Store/src/Service/ShippingService.php
Change this:
/**
@croxton
croxton / expresso_store_uk_postcodes.txt
Created November 27, 2017 10:30
Expresso Store match specific UK postcodes
Allow shipping rules to accept regex
***************************************************************
First, change the `postcode` column in `exp_store_shipping_rules` to type varchar(255).
./Store/src/Service/ShippingService.php
Change this:
/**
@croxton
croxton / craftblockwrap.twig
Last active April 10, 2018 19:23
Craft CMS matrix blocks intelligent wrapping
{# _partials/blocks/blocks.html #}
{#
Blocks component
Outputs a matrix field blocks, intelligently wrapping blocks that need to be inset from the edges
@param {object} contentBlocks (MatrixBlockModel)
#}
{# Parameters #}
@croxton
croxton / SSL-certs-OSX.md
Last active June 3, 2025 17:42 — forked from leevigraham/Generate ssl certificates with Subject Alt Names on OSX.md
Generate ssl certificates with Subject Alt Names

Generate ssl certificates with Subject Alt Names on OSX

Open ssl.conf in a text editor.

Edit the domain(s) listed under the [alt_names] section so that they match the local domain name you want to use for your project, e.g.

DNS.1   = my-project.dev

Additional FQDNs can be added if required:

@croxton
croxton / imgix_responsive _images_on_the_fly.md
Last active April 10, 2018 17:57
Responsive images with imgix.js 3.x

These images are being sourced from https://hallmark-design.co.uk, which I have added as a "web folder" source in imgix. Please try it out with your own domain rather than use up my bandwidth :).

<!DOCTYPE html>
<html>

<head>
	<title>Test Imgix</title>
    	
	<!-- imgix config -->
@croxton
croxton / serverpilot_on_tagadab_cloud.md
Last active April 10, 2018 19:06
Manage a Tagadab Cloud server with Serverpilot
  1. In Tagadab cloud control panel create new server running Ubuntu 14.04.2 minimal, with backups enabled.

  2. Change Tools > Bootloader to server so it can load it's own kernel modules.

  3. Take snapshot (pre-upgrade-os).

  4. We need to update to Ubuntu 14.04.4 first. Login as root and run:

     sudo apt update
    

sudo apt dist-upgrade

@croxton
croxton / geeup.md
Last active April 8, 2018 02:24
GeeUp Workshop

#GeeUp workshop

These instructions will help you set up the EE Zen Garden locally and you should end up with a working website.

Initial set up

  1. Fork croxton/ee_zen_garden on Github

  2. Make a local clone of your fork:

     git clone [email protected]:my-account/ee_zen_garden.git