Skip to content

Instantly share code, notes, and snippets.

Trevor Harmon thetrevorharmon

Block or report user

Report or block thetrevorharmon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thetrevorharmon
thetrevorharmon / example-form.tsx
Last active Jul 17, 2019
Gatsby Mailchimp Signup Form
View example-form.tsx
import addToMailchimp from 'gatsby-plugin-mailchimp';
import React, { useState } from 'react';
import * as styles from './EmailListForm.module.scss';
const EmailListForm: React.FunctionComponent<{}> = () => {
const [email, setEmail] = useState('');
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
@thetrevorharmon
thetrevorharmon / example-query.js
Last active Jul 5, 2019
Query JSON with S3 Select in Node.js
View example-query.js
// See tth.im/s3json for a full explanation of this code
const AWS = require('aws-sdk');
const S3 = new AWS.S3();
exports.handler = async (_, context) => {
try {
const query = 'SELECT * FROM s3object[*].results[*] r;';
// test query is against data from https://swapi.co/api/planets/?page=2
@thetrevorharmon
thetrevorharmon / Helmet.tsx
Created Jan 10, 2019
A wrapper around react-helmet that makes use of StaticQuery from Gatsby.
View Helmet.tsx
import { graphql, StaticQuery } from 'gatsby';
import * as React from 'react';
import { Helmet as ReactHelmet } from 'react-helmet';
interface HelmetProps {
pageTitle?: string;
}
interface HelmetDataProps extends HelmetProps {
data: {
@thetrevorharmon
thetrevorharmon / StaticQuery-and-typescript.tsx
Created Nov 29, 2018
An example of how to use Gatsby's StaticQuery with Typescript
View StaticQuery-and-typescript.tsx
import { graphql, StaticQuery } from 'gatsby';
import * as React from 'react';
interface HeaderProps {
className: string;
}
interface HeaderPropsWithData extends HeaderProps {
data: {
site: {
@thetrevorharmon
thetrevorharmon / install-apple-font-tools.sh
Created Jun 19, 2018
These commands help you install the Apple Font Tools, since their installer doesn't work on newer versions of macOS.
View install-apple-font-tools.sh
# Mount the font tools dmg as a volume on your Mac
hdiutil attach ~/Downloads/osxfonttools.dmg
# Navigate into the volume and copy
# the main .pkg file somewhere locally
# so you can manipulate it
cd /Volumes/OS\ X\ Font\ Tools/
pkgutil --expand OS\ X\ Font\ Tools.pkg ~/fontTools && cd ~/fontTools
# If you ls, here's what's in the file
@thetrevorharmon
thetrevorharmon / index.html.slim
Created Feb 7, 2018
Rails Scaffold with Slim
View index.html.slim
p#notice #{notice}
h1 <%= plural_table_name.titleize %>
table
thead
tr
<% attributes.reject(&:password_digest?).each do |attribute| -%>
th <%= attribute.human_name %>
<% end -%>
th colspan="3"
View index.html.erb
<p id="notice"><%%= notice %></p>
<h1><%= plural_table_name.titleize %></h1>
<table>
<thead>
<tr>
<% attributes.reject(&:password_digest?).each do |attribute| -%>
<th><%= attribute.human_name %></th>
<% end -%>
You can’t perform that action at this time.