Skip to content

Instantly share code, notes, and snippets.

View mdunbavan's full-sized avatar

Mark Dunbavan mdunbavan

View GitHub Profile
@mdunbavan
mdunbavan / beautiful.rest.api.docs.in.markdown.md
Created June 19, 2023 09:45 — forked from azagniotov/beautiful.rest.api.docs.in.markdown.md
Example to create beautiful REST API docs in Markdown, inspired by Swagger API docs.
@mdunbavan
mdunbavan / GitCommitEmoji.md
Created September 14, 2022 09:31 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
@mdunbavan
mdunbavan / google_cloud_storage_craft_3.md
Created July 8, 2021 11:19 — forked from croxton/google_cloud_storage_craft_3.md
How to provision Google Cloud Storage buckets for Craft CMS 3.x

Create the bucket

  1. Open the console https://console.cloud.google.com
  2. If you haven't already, setup your Cloud billing account
  3. From the drop down at the top of the screen, create new project for your client, e.g. my-client
  4. Make a note of the Project number on the project Home screen (Craft refers to this as the Project ID)
  5. In the sidebar go to APIs & Services > Credentials, click the + Create credentials button and choose the Service Account type
  • Set account name to craft-cms or similar
  • Set role to Owner
  • Save
  1. Click on the newly created service account email to edit it, then click the Keys tab and click Add key > Create new key and select the JSON format
@mdunbavan
mdunbavan / component.js
Created October 8, 2019 09:20 — forked from nathanlogan/component.js
Emulate URL anchor page scroll functionality in a React component
import React, { Component } from 'react'
class MyTopLevelComponent extends Component {
componentDidMount () {
this.scrollToHashId()
}
componentDidUpdate () {
this.scrollToHashId()
}
{% includejs %}
$('.postcode-form').submit(function(ev) {
// Prevent the form from actually submitting
ev.preventDefault();
var inputVal = $(this).find('input').val();
if(inputVal.length == 0 ){
$(this).find('input').addClass('b--red');
@mdunbavan
mdunbavan / elementApi.php
Created June 20, 2019 08:00
Fi vue js load more
'api/reviews.json' => function() {
return [
'elementType' => Entry::class,
'elementsPerPage' => 3,
'pageParam' => 'pg',
'criteria' => ['section' => 'customerReviews'],
'transformer' => function(Entry $entry) {
$image = $entry->customerPhoto->one();
$userImage = Imgix::$plugin->imgixService->transformImage( $image, [ 'width' => 120 ], ['lossless' => 0,'auto' => 'compress','fm' => 'jpg','q' => 90,'lazyload' => true ]);
@mdunbavan
mdunbavan / payment.twig
Created August 20, 2018 11:15
Stripe element card payment page Craft commerce
{% extends '_layout' %}
{% block content %}
{% include 'shop/_includes/meter' %}
<section class="container center-ns ph6-ns ph4">
<div class="flex-ns flex-wrap items-start justify-left">
<div class="w-100 tc mb4">
<h2 class="pa0 ma0 f2">Payment</h2>
</div>
<template>
<div class="vh-100 nav-bar">
<nav role="main" class="w-100 tl">
<ul class="center pv5 ph5">
<li class="db v-mid mb3 text-gray">My Folders</li>
<li class="db v-mid mb3 text-gray">Shared with me</li>
<li class="db v-mid mb3 text-gray">From Canvas8</li>
<li class="db v-mid mb3 text-gray">Sent</li>
<li class="db v-mid mb3 text-gray">Archive</li>
@mdunbavan
mdunbavan / gist:499d398e92973200df903a23c5f6eda6
Created November 24, 2017 17:59 — forked from bradwestfall/gist:f5a010e96fb0c4d18556
Pull Instagram Images via JavaScript
@mdunbavan
mdunbavan / webpack.mix.js
Created November 21, 2017 14:49 — forked from andrewdelprete/webpack.mix.js
Laravel Mix: Tailwind CSS + PurgeCSS Example
let mix = require("laravel-mix");
let tailwindcss = require("tailwindcss");
let glob = require("glob-all");
let PurgecssPlugin = require("purgecss-webpack-plugin");
/**
* Custom PurgeCSS Extractor
* https://github.com/FullHuman/purgecss
* https://github.com/FullHuman/purgecss-webpack-plugin
*/