Skip to content

Instantly share code, notes, and snippets.

View michaelhue's full-sized avatar

Michael Hüneburg michaelhue

View GitHub Profile
@michaelhue
michaelhue / page-fieldset.yaml
Last active August 29, 2015 14:03
Creating re-usable snippets with the var-plugin for Statamic.
fields:
layout:
type: select
instructions: "Select the layout of the page."
options:
image_left: Image left
image_right: Image right
default: image_left
image:
type: file
@michaelhue
michaelhue / lazyload.js
Last active February 16, 2016 19:00
JS viewport-aware image lazy loading
/**
* Minimal viewport-aware lazy loading for images.
*
* This is a simple vanilla JS script for async image loading
* shortly before the element enters the viewport.
*
* Example:
*
* <div class="img-container" data-ll='{"src": "myimage.jpg", "alt": "My Image"}'>
* <noscript><img src="myimage.jpg" alt="My Image"></noscript>
@michaelhue
michaelhue / hookify.js
Last active February 21, 2016 22:53
Hookify.js – a simple helper for implementing the Hooks pattern.
/**
* Hookify
*
* A very simple helper for implementing the Hooks pattern in your applications.
*
* @param {Object} obj The object containing hooks.
* @param {Object} ctx Optional context that is applied to hooks. Defaults to the obj.
* @return {Function}
*/
function hookify(obj, ctx) {
@michaelhue
michaelhue / keybase.md
Created February 20, 2018 14:18
Keybase proof

Keybase proof

I hereby claim:

  • I am michaelhue on github.
  • I am michaelhue (https://keybase.io/michaelhue) on keybase.
  • I have a public key ASB3TtVlSTaejcPZ1fcA49ruOQ8a6JcxIJKmYhWXA0Bazgo

To claim this, I am signing this object:

@michaelhue
michaelhue / app.php
Last active August 26, 2021 14:33
Craft CMS workaround for "resourcepaths" UPSERTs
<?php
use craft\events\RegisterCacheOptionsEvent;
use craft\utilities\ClearCaches;
use yii\base\Event;
// Register the "resourcepaths" cache tag for clearing via craft command.
// Important: the following command should be run after every deploy.
// php craft invalidate-tags/resourcepaths
Event::on(
@michaelhue
michaelhue / FormieAsset.php
Created September 14, 2021 16:06
Formie "New submission" extension
<?php
namespace site\web\assets\formie;
use craft\web\AssetBundle;
use verbb\formie\web\assets\cp\CpAsset;
class FormieAsset extends AssetBundle
{
public function init()
@michaelhue
michaelhue / BrowserTestCase.php
Created April 17, 2022 12:32
InertiaBrowser
<?php
namespace App\Tests;
use Orchestra\Testbench\Dusk\TestCase as BaseTestCase;
use App\Testing\Concerns\CreatesApplication;
use App\Testing\Concerns\ProvidesInertiaBrowser;
abstract class BrowserTestCase extends BaseTestCase
{