Skip to content

Instantly share code, notes, and snippets.

@AugustMiller
AugustMiller / MyModule.php
Last active June 6, 2021 00:57
Craft Commerce: Add user to a group when they make a purchase
<?php
namespace modules\mymodule;
use Craft;
use craft\elements\User;
use craft\helpers\ArrayHelper;
use yii\base\Event;
@philipboomy
philipboomy / gist:b4f22c26cca62f0779714ac97ebe7cb2
Last active October 25, 2019 17:17
Laravel Mix 4 with Tailwind and Purge
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');
require('laravel-mix-purgecss');
mix.setPublicPath('./web')
.postCss('src/css/main.css', 'css')
.options({
postCss: [tailwindcss('tailwind.config.js'), require('autoprefixer')],
processCssUrls: false,
})
// Dependencies
var gulp = require('gulp'); // Gulp!
var cheerio = require('gulp-cheerio'); // Cheerio, good chap!
var filter = require('gulp-filter'); // Filter a pipeline.
var plumber = require('gulp-plumber'); // Gulp Plumber
var rename = require('gulp-rename'); // Rename
var svgstore = require('gulp-svgstore'); // Combine SVG files into one
var svgmin = require('gulp-svgmin'); // Compress SVG files
// Paths
@radarseven
radarseven / craft-template-with-querystring-filters.twig
Last active January 11, 2017 16:44
Craft 2.x - Filtering entries in a single Twig template
{# How to handle querystring filters in a single Twig template. #}
{# Baseline entries/categories criteria. #}
{# Set any criteria here that will be relevant regardless of filters. #}
{# Section name can be array if you need to fetch from more than one section. #}
{% set criteria = {
section: ['sectionName'],
order: 'postDate desc',
limit: 9
} %}
@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
@danhett
danhett / contract.md
Last active July 6, 2020 17:57 — forked from brendandawes/Dawesome Design Contract.md
A contract for creative technologist/development services.

This is simple, clear and concise contract that I use for general creative and technical projects. It's based largely upon Brendan Dawe's excellent open-source design contract, but has been modified to contain more appropriate terminology for my field, and now contains sections pertaining to source code, ongoing support, NDA's etc.

Please feel free to fork, modify, distribute and use this document as you wish - and please please do use it. Do not start work without a contract, ever. Additionally: DO NOT START WORK WITHOUT A CONTRACT, EVER.

Agreement for commission of work between:

Dan Hett ("Developer", "me", "I")

and:

[CLIENT NAME] ("Client", "you")

@aelvan
aelvan / macro.twig
Created September 23, 2015 15:07
Twig macro for creating a srcset string in Craft
{% macro getSrcSet(image, sizes, upscale) %}
{%- spaceless %}
{% set sizesOut = [] %}
{% set allowScaleLarger = upscale | default(false) %}
{# loop over sizes parameter and generate transforms #}
{% for size in sizes %}
{%- spaceless %}
{% set currentTransform = {} %}
@jasonvarga
jasonvarga / form.html
Last active September 5, 2021 23:34
Using Statamic HTML Caching with a dynamic Raven form. Put the form on a separate page and pull it in via JS.
<!--
A template for raven stuff.
Display this at a URL like /contact-form for example
Exclude this URL from html_caching
Make this form look/act like it was part of the parent page.
The contents of #raven will be injected into it.
-->
@dennisfrank
dennisfrank / get_remote_db.sh
Created May 23, 2014 16:49
Shell script to import a remote database into local environment
#!/bin/sh
# Import a remote database into a local database
# ----------------------------------------------
#
# Based on http://danherd.net/quick-script-synchronise-from-a-remote-expressionengine-database/
#
# Don’t forget chmod +x to make the script executable.
#
# Change the extension to .command to run the script directly from OS X Finder.
@jasonvarga
jasonvarga / Gruntfile.js
Last active January 4, 2016 15:19
Using Grunt to copy Statamic add-on files to a sandbox site
module.exports = function(grunt) {
grunt.initConfig({
concat: {
// js stuff
},
uglify: {
// more js stuff