Skip to content

Instantly share code, notes, and snippets.

View rheinardkorf's full-sized avatar

Rheinard Korf rheinardkorf

View GitHub Profile
@rheinardkorf
rheinardkorf / .gitignore
Created August 13, 2020 00:40
A .gitignore for use on WP Engine. Slight tweaks to the official one: https://wpengine.com/wp-content/uploads/2020/02/recommended-gitignore-no-wp.txt
*~
.DS_Store
.svn
.cvs
*.bak
*.swp
Thumbs.db
# wordpress specific
wp-config.php
@rheinardkorf
rheinardkorf / .gitignore
Last active July 27, 2020 06:35
Some GatsbyJS workspace stuff.
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@rheinardkorf
rheinardkorf / mode-switch-plugin.js
Created June 3, 2020 03:30
Gutenberg manipulate Editor Mode state. (Experimental)
(function (wp) {
var registerPlugin = wp.plugins.registerPlugin;
var PluginMoreMenuItem = wp.editPost.PluginMoreMenuItem;
// var image = wp.icons.image;
var el = wp.element.createElement;
var withDispatch = wp.data.withDispatch;
var MoreItem = function (props) {
return el(PluginMoreMenuItem,
@rheinardkorf
rheinardkorf / gatsby-node.js
Last active August 27, 2019 05:19
Use parent's resolver using custom field extension. FTW!!
exports.createSchemaCustomization = ({ actions }) => {
const { createFieldExtension, createTypes } = actions;
createFieldExtension({
name: `parent`,
description: `Proxy resolver from a parent's field.`,
args: {
from: `String!`
},

First attempt...

Inside gatsby-browser.js

import Amplify, { Auth } from 'aws-amplify';
import awsconfig from './src/aws-exports'
Amplify.configure(awsconfig);
@rheinardkorf
rheinardkorf / with-theme-path.js
Created April 22, 2019 04:46
For posterity. Manually trying to implement component shadowing with Gatsby. So glad this is backed in by default.  😅
exports.withThemePath = (relativePath, root = __dirname) => {
const qualifiedPath = relativePath.replace('./src', `${root}/src`);
let qualifiedResolvedPath = path.resolve(qualifiedPath);
let finalPath = qualifiedResolvedPath;
const theme = path.basename(root);
const themedPath = relativePath.replace('./src', `./src/${theme}`);
let themedResolvedPath = path.resolve(themedPath);
try {
@rheinardkorf
rheinardkorf / brew-instructions.sh
Created March 9, 2019 10:32 — forked from petemcw/brew-instructions.sh
Setup dnsmasq on Mac OS X
# Install `dnsmasq` and configure for *.dev domains
$ brew install dnsmasq
$ vim /usr/local/etc/dnsmasq.conf
# Reload configuration and clear cache
$ sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ dscacheutil -flushcache
@rheinardkorf
rheinardkorf / gist:0daa5531c60a6c8733b805f29f4d20c1
Last active April 2, 2024 03:44
Example WordPress Proxy Layer
<?php
/**
* Init Proxy endpoints.
*
* @return void
*/
public function rest_api_init() {
/**
@rheinardkorf
rheinardkorf / slack-verify.php
Last active August 4, 2018 06:46
Verifying Slack Requests
<?php
/**
* Validate Slack notification signature.
*
* @see https://api.slack.com/docs/verifying-requests-from-slack
*
* @param array $headers POST headers.
* @param string $response_body JSON string of body.
* @param string $signing_secret Slack secret.
@rheinardkorf
rheinardkorf / index.html
Created July 24, 2018 11:16
Cloudinary DAM Widget Example
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Demo</title>
<script src="https://media-library.cloudinary.com/global/all.js"></script>
<script type="text/javascript">
const mloptions = {
cloud_name: '<CHANGE_THIS>',
api_key: '<CHANGE_THIS>',