Skip to content

Instantly share code, notes, and snippets.

View ryanscherler's full-sized avatar

Ryan Scherler ryanscherler

View GitHub Profile
@ryanscherler
ryanscherler / DOSpacesLocalVolumesModule.php
Created November 6, 2020 18:32
Yii Module for Craft CMS to enable local volumes for development when using Digital Ocean Spaces as an asset volume.
<?php
namespace modules;
use yii\base\Module;
use Craft;
use craft\volumes\Local;
use vaersaagod\dospaces\Volume;
/**
* Custom module class.
@ryanscherler
ryanscherler / Instagram.php
Created June 29, 2020 23:39
WP Theme Class: Query Instagram API via GraphQL / Zttp
<?php
namespace Theme;
use Illuminate\Support\Collection;
use Zttp\Zttp;
class Instagram {
protected $cache_mins;
@ryanscherler
ryanscherler / gatsby-node.js
Last active August 14, 2019 23:03
Gatsby Node
const path = require('path')
const { createFilePath } = require('gatsby-source-filesystem')
const { fmImagesToRelative } = require('gatsby-remark-relative-images')
const config = require('./site-config.json')
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions
fmImagesToRelative(node)
if (node.internal.type === 'MarkdownRemark') {
@ryanscherler
ryanscherler / image.js
Created August 13, 2019 20:08
Gatsby Dynamic Image
import React from 'react'
import PropTypes from 'prop-types'
import Img from 'gatsby-image'
const Image = ({ node, alt, className }) => {
if (node.childImageSharp && node.childImageSharp.fluid) {
return (
<Img fluid={node.childImageSharp.fluid} alt={alt} className={className} />
)
}
@ryanscherler
ryanscherler / TokenMiddleware.php
Created February 24, 2019 17:48
Token middleware invokable class for Slim PHP
<?php
namespace App\Middleware;
use Psr\Container\ContainerInterface;
class TokenAuthentication
{
private $container;
@ryanscherler
ryanscherler / HostMiddleware.php
Last active February 23, 2019 06:14
Slim PHP Host Middleware
<?php
namespace App\Middleware;
class HostMiddleware
{
/**
* Host middleware invokable class
*
* @param \Psr\Http\Message\ServerRequestInterface $request PSR7 request
@ryanscherler
ryanscherler / Modal.js
Created January 25, 2019 01:08
Simple Class Modal
/*
Usage:
<a href="#url" data-modal-open="modal-123">Open Modal</a>
<div class="modal" data-modal="modal-123">
<button data-modal-close="modal-123">Close Modal</button>
...
</div>
@ryanscherler
ryanscherler / ScrollWatcher.js
Created January 11, 2019 00:39
Scroll Watcher
/*
Usage:
new ScrollWatcher({
selector: '.header--scroll',
classes: 'header--scroll-in-view',
scrollOffset: 0,
})
*/
export default class {
@ryanscherler
ryanscherler / gatsby-node.js
Created November 30, 2018 17:36
Add PurgeCSS in production for Gatsby
// Add PurgeCSS in production
// See: https://github.com/gatsbyjs/gatsby/issues/5778#issuecomment-402481270
const PurgeCssPlugin = require(`purgecss-webpack-plugin`)
const path = require(`path`)
const glob = require(`glob`)
const PATHS = {
src: path.join(__dirname, `src`)
}
@ryanscherler
ryanscherler / .htaccess
Last active October 8, 2018 20:44
Apache: Force httpS and non www
<IfModule mod_rewrite.c>
RewriteEngine On
AddDefaultCharset UTF-8
# -----------------------------------------------------------------------------------------------
# If you only want to allow HTTPS, uncomment the RewriteCond and RewriteRule lines below.
# -----------------------------------------------------------------------------------------------
RewriteCond %{HTTPS} off