Skip to content

Instantly share code, notes, and snippets.

View AugustMiller's full-sized avatar
🌳

August Miller AugustMiller

🌳
View GitHub Profile
@AugustMiller
AugustMiller / image-notifier.coffee
Last active October 1, 2015 18:59
Image Load Notifier
module.exports = class LazyLoad
constructor: (@el, @callback) ->
if @is_loaded() then @after() else @listen()
listen: ->
@el.on 'load', (e) => @after()
is_loaded: ->
@loaded = @el.get(0).complete
@AugustMiller
AugustMiller / try_snippet.php
Last active April 4, 2018 12:15
Kirby snippet fallback function
<?php function try_snippet($try, $data = [], $return = false) {
$snippets = kirby::instance()->roots()->snippets();
foreach ( $try as $snippet ) {
$file = $snippets . DS . $snippet . '.php';
if ( f::exists($file) ) {
return tpl::load($file, $data, $return);
} else {
continue;
}
}
@AugustMiller
AugustMiller / date-range-query.twig
Created April 24, 2016 23:36
Fetch entries with a custom date field set between two other dates
{% set entriesWithDateInRange = craft.entries({
section: 'section',
type: 'type',
order: 'customDate asc',
customDate: ['and', '>= ' ~ now, '<= ' ~ (now.year + 1)]
}) %}
@AugustMiller
AugustMiller / Gulpfile.js
Created September 27, 2016 22:06
Craft + Gulp Setup
var gulp = require('gulp'),
gutil = require('gulp-util'),
coffee = require('gulp-coffee'),
coffeeify = require('gulp-coffeeify'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
test = require('gulp-if'),
del = require('del'),
rename = require('gulp-rename'),
@AugustMiller
AugustMiller / mailgun-html.php
Created November 14, 2016 23:07
Kirby + Mailgun HTML Email service
<? email::$services['mailgun-html'] = function($email) {
if(empty($email->options['key'])) throw new Error('Missing Mailgun API key');
if(empty($email->options['domain'])) throw new Error('Missing Mailgun API domain');
$url = 'https://api.mailgun.net/v2/' . $email->options['domain'] . '/messages';
$auth = base64_encode('api:' . $email->options['key']);
$headers = array(
'Accept: application/json',
@AugustMiller
AugustMiller / svg-classname.coffee
Last active January 20, 2017 19:50
SVG Classname Utility
getClass = (el) ->
if el.hasAttribute 'class'
el.getAttribute('class').split ' '
else
[]
hasClass = (el, className) ->
-1 < getClass(el).indexOf className
addClass = (el, className) ->
@AugustMiller
AugustMiller / HelpersPlugin.php
Last active February 19, 2019 00:53
Basic asset cache busting plugin for Craft CMS.
<? namespace Craft;
# craft/plugins/helpers/HelpersPlugin.php
class HelpersPlugin extends BasePlugin
{
public function getName()
{
return Craft::t('Helpers');
}
<? namespace Craft;
class HelpersPlugin extends BasePlugin
{
public function getName()
{
return Craft::t('Helpers');
}
public function getVersion()
@AugustMiller
AugustMiller / banner.html
Created April 17, 2017 21:35
oof. Studio Banner
<!--
@@@@@@ @@@@@@ @@@@@@@@ @@@@@@ @@@@@@@ @@@ @@@ @@@@@@@ @@@ @@@@@@
@@@@@@@@ @@@@@@@@ @@@@@@@@ @@@@@@@ @@@@@@@ @@@ @@@ @@@@@@@@ @@@ @@@@@@@@
@@! @@@ @@! @@@ @@! !@@ @@! @@! @@@ @@! @@@ @@! @@! @@@
!@! @!@ !@! @!@ !@! !@! !@! !@! @!@ !@! @!@ !@! !@! @!@
@!@ !@! @!@ !@! @!!!:! !!@@!! @!! @!@ !@! @!@ !@! !!@ @!@ !@!
!@! !!! !@! !!! !!!!!: !!@!!! !!! !@! !!! !@! !!! !!! !@! !!!
!!: !!! !!: !!! !!: !:! !!: !!: !!! !!: !!! !!: !!: !!!
:!: !:! :!: !:! :!: :!: !:! :!: :!: !:! :!: !:! :!: :!: !:!
@AugustMiller
AugustMiller / SfscPlugin.php
Last active April 24, 2017 21:05
Sprout Form + Solspace Calendar
<? namespace Craft;
class SfscPlugin extends BasePlugin
{
public function getName()
{
return Craft::t('Event Attendance');
}
public function getVersion()