Skip to content

Instantly share code, notes, and snippets.

View terryupton's full-sized avatar

Terry Upton terryupton

View GitHub Profile
@juban
juban / CriticalCssController.php
Last active June 12, 2022 22:11
CriticalCssController console controller to export a rollup-plugin-critical compatible configuration file to use with Vite.
<?php
namespace modules\console\controllers;
use Craft;
use craft\console\Controller;
use craft\elements\Entry;
use craft\helpers\Console;
use craft\helpers\FileHelper;
use craft\helpers\Json;

How I Update Craft CMS 3.5.x and Craft CMS Plugins

⏳ 2 min read.

Update apnea: the temporary cessation of breath when updating Craft and Craft plugins.

This article describes the steps I follow to update Craft 3.5.x and plugins in a stress-free and reliable manner. 🧘

Photo of blue and pink sea by Harli Marten Photo by Harli Marten on Unsplash

@KevinBatdorf
KevinBatdorf / add-alpine-js-to-tailwind-ui.js
Last active May 7, 2024 18:51
Auto copy the Alpine code from Tailwind UI's copy button
// ==UserScript==
// @name Add AlpineJs to Tailwind UI
// @namespace http://tampermonkey.net/
// @version 3.0
// @description Add Alpine JS code to Tailwind Ui copy/paste
// @author https://gist.github.com/KevinBatdorf/8bd5f808fff6a59e100dfa08a7431822
// @match https://tailwindui.com/components/*
// @grant none
// ==/UserScript==
@terryupton
terryupton / modal.twig
Created April 9, 2020 18:18
Ajax Loading a page into a modal with Alpine JS
<section x-data="{showModal: false, html: ''}">
<button
@click="html='loading...'; showLoading = true; showModal = !showModal;
fetch('{{ entry.url }}', {
method: 'GET',
headers: {
'X-Requested-With': 'XMLHttpRequest',
},
})
@craigerskine
craigerskine / _dropbox_node_prep.scpt
Last active December 21, 2023 19:40
Force Dropbox to truly ignore node_modules using Apple Script (macOS only)
# Prep dropbox to ignore 'node_modules' in a node project
# 1. Move this script to your node project root;
# 2. Delete the existing 'node_modules' folder;
# 3. Run this script;
# 4. `npm install` as normal;
# 5. Enjoy!
tell application "Finder"
set current_path to container of (path to me) as alias
make new folder at current_path with properties {name:"node_modules"}
@dillingham
dillingham / Steps.vue
Last active October 27, 2021 15:18
tailwind & vue stepper
<template>
<div class>
<div class="bg-grey-light h-1"></div>
<div class="flex">
<div class="flex-1" v-for="s in steps" :key="s">
<div
v-if="step >= s"
class="bg-blue -mt-1 h-1"
:class="{ 'w-1/2': step == s, 'w-full': step < s }"
></div>
@terdelyi
terdelyi / craft_validate_public_user_registration.php
Last active September 11, 2021 03:18
CraftCMS 3 - Extending the validation on the public user registration form
<?php
use Craft;
use craft\base\Element;
use craft\elements\User;
use craft\events\ModelEvent;
use yii\base\Event;
@bootsified
bootsified / current-week-dates.twig
Last active January 4, 2022 20:06
Get current week's range of dates (Craft/Twig)
{# CALCULATE THIS WEEK'S DATES #}
{% set todayNum = 'now' | date('w') %}
{% set startDate = 'now' | date_modify('-' ~ todayNum ~ ' day') %}
{% set endDate = startDate | date_modify('+6 day') %}
{% set endDateFormatted = '-' ~ endDate | date('j') %}
{% if startDate | date('M') != endDate | date('M') %}
{% set endDateFormatted = ' - ' ~ endDate | date('M j') %}
{% endif %}
<p>The Week of {{ startDate | date('M j') }}{{ endDateFormatted }}</p>
@brettburwell
brettburwell / img.html
Last active June 26, 2018 09:05
Craft macro to centralize the markup and config for responsive images
{# ================================================================== #}
{# Responsive Image Macro
{# ================================================================== #}
{#
Macro to centralize the markup and config for responsive images.
Based on an article by Marion Newlevant (@marionnewlevant) and
adapted for the Lazysizes plugin. Read more:
https://straightupcraft.com/articles/responsive-images-with-twig-macros
@vlandham
vlandham / part1.md
Last active March 21, 2024 12:57
Feature Branches and Pull Requests : Walkthrough

Here's a little walkthrough of how Yannick and I are using feature branches and pull requests to develop new features and adding them to the project. Below are the steps I take when working on a new feature. Hopefully this, along with watching the process on Github, will serve as a starting point to having everyone use a similar workflow.

Questions, comments, and suggestions for improvements welcome!

Start with the latest on master

When starting a new feature, I make sure to start with the latest and greatest codebase:

git checkout master