Skip to content

Instantly share code, notes, and snippets.

Avatar

Dalton Rooney daltonrooney

View GitHub Profile
View hover-export.js
// Hover.com "Zone file import/export" has been *Planned* since 2011
// https://help.hover.com/entries/471066-Zone-file-import-export
// Here's a brittle approximation of export.
//
// 1. login to your account: https://www.hover.com/domains
// 2. run the following in your browser's JavaScript console, changing the first line
// to your domain
// 3. copy the text logged to the console.
// 4. manually correct FQDNs, these have to end with a period "."
//
@daltonrooney
daltonrooney / app.js
Last active Aug 5, 2021
Craft CMS GQL query w/ filters and pagination
View app.js
import Vue from 'vue'
import { debounce } from './utils/debounce';
import { ProCatalogCategoriesQuery } from './queries/proCatalogCategories.gql';
import { makeProCatalogResourcesQuery } from './queries/proCatalogResources';
import Loading from './components/loading.vue';
const GraphqlEndpoint = '/api'
const ResultsPerPage = 12;
const el = document.querySelector('#professional-catalog-app')
@daltonrooney
daltonrooney / toggleButton.css
Last active Nov 8, 2020
toggleButton (redactor plugin)
View toggleButton.css
a.button {
display: inline-block;
box-sizing: border-box;
font-size: 14px;
font-weight: 700;
text-align: center;
padding: 10px 20px 9px 20px;
cursor: pointer;
outline: none;
border: none;
@daltonrooney
daltonrooney / contentModule.gql
Last active Feb 20, 2021
Craft CMS GraphQL matrix shared fragment example
View contentModule.gql
import gql from 'graphql-tag'
import { print } from 'graphql/language/printer'
import richTextFragment from './contentModules/richText.gql'
import logoBlockFragment from './contentModules/logoBlock.gql'
import embedBlockFragment from './contentModules/embedBlock.gql'
import videoBlockFragment from './contentModules/videoBlock.gql'
import imageCollageFragment from './contentModules/imageCollage.gql'
import imageGridFragment from './contentModules/imageGrid.gql'
import slideshowBlockFragment from './contentModules/slideshowBlock.gql'
import singleImageFragment from './contentModules/singleImage.gql'
@daltonrooney
daltonrooney / steps.vue
Created Jun 12, 2020
Using Bulma Steps in Vue.js & Nuxt
View steps.vue
<template>
<div
ref="stepsApp"
class="steps"
>
<div class="step-item is-active is-success">
<div class="step-marker">
1
</div>
<div class="step-details">
@daltonrooney
daltonrooney / modal-video.vue
Last active Jun 3, 2022
Modal video player component for Vue.js
View modal-video.vue
/* Based on https://github.com/appleple/react-modal-video/ */
<template>
<div v-if="isOpen">
<div
:class="classNames.modalVideo"
tabIndex='-1'
role='dialog'
:aria-label="aria.openMessage"
@click="$emit('update:isOpen', false)"
View debounce.js
/* https://gist.github.com/nmsdvid/8807205#gistcomment-3168449 */
var debounce = (callback, wait = 250) => {
let timer;
let last_call = 0;
return (...args) => {
clearTimeout(timer);
const now = Date.now(), time_from_last_call = now - last_call;
if (time_from_last_call > wait) {
@daltonrooney
daltonrooney / module.php
Created May 12, 2020
Clear Craft CMS cache after Entry save event
View module.php
<?php
use yii\base\Event;
use Craft;
use craft\elements\Entry;
Event::on(
Entry::class,
Entry::EVENT_AFTER_SAVE,
function(ModelEvent $event) {
@daltonrooney
daltonrooney / twig-filters.php
Last active May 22, 2020
Useful HTML filters for Timber Twig (widows and markdown support)
View twig-filters.php
<?php
add_filter( 'timber/twig', 'add_to_twig' );
function add_to_twig( $twig ) {
$twig->addFilter( new Timber\Twig_Filter( 'noWidows', 'twigNoWidow' ) );
return $twig;
}
function twigNoWidow($text = "", $numberOfWords = 1, $outputRaw = true ) {
@daltonrooney
daltonrooney / img-macros.twig
Created Jan 23, 2020 — forked from stenvdb/img-macros.twig
Macro collection for Imager in Craft CMS
View img-macros.twig
{#
# USAGE:
# (transform can either be an object, or an array of objects, aka srcset)
#
# {{ macro.regular(entry.image.one(), { width: 50, height: 50 }, 'class="block"') }}
# ➡️ <img src="..." width="50" height="50" alt="..." class="block" />
#
# {{ macro.url(entry.image.one(), { width: 50, height: 50 }) }}
# ➡️ /uploads_c/../{...}.jpg
#