Skip to content

Instantly share code, notes, and snippets.

View DSchau's full-sized avatar

Dustin Schau DSchau

View GitHub Profile
@DSchau
DSchau / optimize.sh
Created December 30, 2022 18:51
Optimize Images
#!/bin/bash
find . \( -name '*.JPG' -o -name '*.jpg' \) -size +10kb | while read f
do
filename="optimized/$(echo $f | sed "s/\.\///g")"
echo "$filename"
convert "$f" -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG "$filename"
done
@DSchau
DSchau / gatsbyjs.com
Created September 22, 2022 03:11
Meta Tags
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<style id="typography.js">
@DSchau
DSchau / gatsby-config-drupal.js
Last active September 18, 2022 22:04
Gatsby Configs
module.exports = {
siteMetadata: {
title: 'Drupal + Bayer Starter',
description: 'Official boilerplate for getting up and running with Drupal + Gatsby for the Bayer team'
},
plugins: [
{
resolve: 'gatsby-source-drupal',
options: {
baseUrl: 'https://path-to-drupal.com'
@DSchau
DSchau / index.js
Created September 9, 2017 20:27
The GraphQL query showing how to format a date!
export const pageQuery = graphql`
query IndexQuery {
site {
siteMetadata {
title
author
}
}
allMarkdownRemark(sort: { order: DESC, fields: [frontmatter___date] }) {
edges {
@DSchau
DSchau / README.md
Created April 9, 2022 20:51
Caching with a Plugin

Instructions

  1. Check out the caching repo
  2. Push to Gatsby Cloud
  3. First build will log "Cache not persisted, getting new characters"
  4. Subsequent builds will not
    • Can validate with a builds webhook invocation: curl -X POST https://webhook.gatsbyjs.com/hooks/data_source/publish/0f86ced9-2fa3-4738-80d8-23786226a8f3

Note: there are several conditions in which the cache is (automatically) cleared. They are documented in the cache API docs.

@DSchau
DSchau / rss-status.xml
Last active February 9, 2022 15:36
PSU 200 for rss.xml
<pingdom_http_custom_check>
<status>200</status>
<response_time>10000</response_time>
</pingdom_http_custom_check>
@DSchau
DSchau / index.js
Last active January 16, 2022 07:02
Higher Order Components + Gatsby Sitting In a Tree
import React from "react"
import { Link, graphql } from "gatsby"
import Layout from "../components/layout"
import Image from "../components/image"
import SEO from "../components/seo"
const withAuthentication = Page => {
return class extends React.Component {
state = {
@DSchau
DSchau / gatsby-ssr.js
Created January 29, 2019 17:06
An example of Gatsby SSR APIs
const { Helmet } = require('react-helmet')
const { onRenderBody } = require('gatsby/ssr')
onRenderBody(({ setHeadComponents, setHtmlAttributes, setBodyAttributes }) => {
const helmet = Helmet.renderStatic()
setHtmlAttributes(helmet.htmlAttributes.toComponent())
setBodyAttributes(helmet.bodyAttributes.toComponent())
setHeadComponents([
helmet.title.toComponent(),
helmet.link.toComponent(),
@DSchau
DSchau / network-tips.md
Last active September 1, 2020 02:21
Ubuntu + HTPC Setup stuff
  1. Hold SHIFT at boot to enter recovery mode
  2. Select Ubuntu -> Recovery Mode
  3. Root
  4. mount -o rw,remount /
  5. Now edit etc/network/interfaces with correct gateway

(Note also, consider adding DHCP to /etc/network/interfaces) to test and then reset /etc/network/interfaces

iface ens160 inet dhcp
@DSchau
DSchau / cypress.json
Last active April 17, 2020 01:07
Cypress + Gatsby Recipe
{
"baseUrl": "http://localhost:8000"
}