Skip to content

Instantly share code, notes, and snippets.

View sawyerh's full-sized avatar

Sawyer Hollenshead sawyerh

View GitHub Profile
@sawyerh
sawyerh / machine.js
Created July 7, 2020 15:55
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@sawyerh
sawyerh / machine.js
Last active April 23, 2020 21:05
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@sawyerh
sawyerh / SketchSystems.spec
Last active April 23, 2020 21:05
Requests
Requests
Submit in-progress claim -> Request is missing required fields
Submit full form -> All required fields are present
Validation scenarios
All required fields are present
All data is valid -> 200 with no warnings
Some data is invalid -> 400 with errors
Request is missing required fields
Present data is valid -> 200 with warnings
@sawyerh
sawyerh / ConditionalContent.js
Last active April 5, 2020 15:56
Reusable components for complex multi-page forms
import PropTypes from "prop-types";
import React from "react";
/**
* Conditionally displays the content passed into it, and clears any
* fields if they're hidden when the component unmounts
*/
class ConditionalContent extends React.PureComponent {
componentWillUnmount() {
// Ensure all of the field values are cleared if they're not
@sawyerh
sawyerh / Validator.js
Created April 2, 2020 13:47
Ajv wrapper for validating JSON Schemas
const Ajv = require("ajv");
const ajvKeywords = require("ajv-keywords");
// This is an export of all of your JSON Schema files
const schemas = require("../schemas");
// EXAMPLE:
// This could live in a ApplicationError.js file and be shared with other files
const ApplicationError = class ApplicationError {
/**
@sawyerh
sawyerh / SketchSystems.spec
Last active February 18, 2020 14:34
Confirm your identity
Confirm your identity
Not started
Start -> In Progress
In Progress
Failure -> Failed
Success -> Completed
Failed
Something else? -> In Progress
Completed
@sawyerh
sawyerh / SketchSystems.spec
Last active November 10, 2019 15:46
Screener*
Screener*
Do you live in Vermont?
Yes -> Living situation
No -> Non-resident options
Contact info
Living situation
Stable -> Home address
Temporary -> Mailing address
Homeless -> Mailing address
@sawyerh
sawyerh / github-helper.js
Created February 3, 2018 20:37 — forked from timaschew/github-helper.js
automate a pull request flow via GitHub API - fork, create branch or update from upstream, commit changes, do pull request and optional merge
'use strict'
const Octokat = require('octokat')
const Promise = require('bluebird')
const ORIGIN_USERNAME = 'username-or-organisation'
const ORIGIN_REPO = 'the-origin-repo'
const ORIGIN_BRANCH = 'master'
const WAIT_FOR_FORK = 5
const WAIT_FOR_MERGE = 5

AWS: Long-term, infrequent backups

All infrequently accessed files are stored on AWS S3. All files are encrypted server-side using AES-256 with the AWS S3 Master Key. When uploading files to this bucket, you must set this encryption option, otherwise uploads will be prevented by the bucket's policy. Unfortunately, this also means using an app like Transmit won't work since they don't offer this encryption option (as of April 10, 2016).

The intention of these backups are "last resort" backups, so hopefully they'll never actually need retrieved. With that in mind, Lifecycle policies are used to archive files to AWS Glacier after a short period of days.

Using AWS because it's dirt cheap, however since the user experience isn't the greatest and Glacier retrieval prices can be a slippery slope, it's only used for infrequently accessed files and backups are uploaded only a few times a year. Most directories will consist of subdirectories named by year (e.g. finances/2014, photos/2014, etc)

Lifecycle policies

@sawyerh
sawyerh / s3-put-event.json
Created July 4, 2016 20:24
Sample S3 PUT event for AWS Lambda
{
"Records": [
{
"eventVersion": "2.0",
"eventTime": "1970-01-01T00:00:00.000Z",
"requestParameters": {
"sourceIPAddress": "127.0.0.1"
},
"s3": {
"configurationId": "testConfigRule",