Skip to content

Instantly share code, notes, and snippets.

@kellyrmilligan
kellyrmilligan / s3Sync.sh
Created June 8, 2017 13:38
Sync files to s3 and set cache control headers
#!/bin/bash
if [[ "$1" != "" ]]; then
S3BUCKETNAME="$1"
else
echo ERROR: Failed to supply S3 bucket name
exit 1
fi
aws s3 sync build s3://$S3BUCKETNAME --delete --cache-control max-age=31536000,public
@kellyrmilligan
kellyrmilligan / webpack.config.dev.js
Created December 13, 2017 20:45
webpack.config.dev.js - adjusted
'use strict';
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
@kellyrmilligan
kellyrmilligan / webpackDevServer.config.js
Created December 13, 2017 20:54
webpackDevServer.config.js - adjusted
'use strict';
const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
const path = require('path');
const config = require('./webpack.config.dev');
const paths = require('./paths');
const express = require('express');
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
@kellyrmilligan
kellyrmilligan / start.js
Created December 13, 2017 21:01
start.js - adjusted
'use strict';
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'development';
process.env.NODE_ENV = 'development';
// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', err => {
import React, { PropTypes, Component } from 'react'
class ContextExample extends Component {
static childContextTypes = {
config: PropTypes.object,
}
getChildContext() {
@kellyrmilligan
kellyrmilligan / registerServiceWorker.js
Last active April 10, 2018 11:29
modified service worker registration from create react app
// In production, we register a service worker to serve assets from local cache.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on the "N+1" visit to a page, since previously
// cached resources are updated in the background.
// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
// This link also includes instructions on opting out of this behavior.
const List = ({ items, onClick }) => (
<ul>
{items.map(item => (
<ClickHandler key={item.id} data={item} onClick={onClick}>
{(handleClick) => (
<li onClick={handleClick}>
{item.text}
</li>
)}
</ClickHandler>
const List = ({ items, onClick }) => (
<ul>
{items.map(item => (
<li onClick={() => onClick(item)}>
{item.text}
</li>
))}
</ul>
)
const List = ({ items, onClick }) => (
<ul>
{items.map(item => (
<li>
{item.text}
</li>
))}
</ul>
)
@kellyrmilligan
kellyrmilligan / multiple calls from a loop with caching
Last active August 22, 2017 18:35
multiple calls with client side caching
import CacheClientPromise from 'cache-client-promise'
const myCache = new CacheClientPromise();
[{
id: 1234,
title: 'test',
view: 'two-column'
},
{