Skip to content

Instantly share code, notes, and snippets.

View jkinkead's full-sized avatar

Jesse Kinkead jkinkead

View GitHub Profile
@jkinkead
jkinkead / ecr_login.fish
Created January 26, 2020 17:25
ECR login helper for fish.
function ecr_login -d \
"ecr_login [profile_name] [region]: Log in to ECR via the AWS CLI." \
-a profile_name region
set -l args
if [ -n "$profile_name" ]
set args $args "--profile=$profile_name"
end
if [ -n "$region" ]
set args $args "--region=$region"
@jkinkead
jkinkead / ecr_login.sh
Created January 26, 2020 17:24
ECR login helper for bash.
# Login to ECR, optionally specifying a profile namd and region.
ecr_login () {
local profile_name="$1"
local region="$2"
local args=()
if [ -n "$profile_name" ]; then
args=("${args[@]}" "--profile=$profile_name")
fi
if [ -n "$region" ]; then
args=("${args[@]}" "--region=$region")
@jkinkead
jkinkead / Dockerfile
Last active July 5, 2019 20:33
Simple Dockerfile using npm
FROM node:12.5.0-stretch-slim
# Install tini, per best-practices. See:
# https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#handling-kernel-signals
ARG TINI_VERSION=v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]
WORKDIR /app
@jkinkead
jkinkead / index.js
Created October 19, 2018 16:08
Hello World cloud function
"use-strict";
exports.render = function (request, response) {
response.send("Hello from the clouds!")
}
@jkinkead
jkinkead / webpack.config.cloud.js
Created October 19, 2018 00:29
Webpack for a React application in the cloud
const path = require('path')
const webpack = require('webpack')
const nodeExternals = require("webpack-node-externals")
module.exports = {
target: 'node',
node: {
__dirname: false
},
entry: ['./index.js'],
externals: [nodeExternals()],
@jkinkead
jkinkead / webpack.config.local.js
Created October 19, 2018 00:25
@babel/react snippet for webpack config
...
module: {
rules: [{
test: /\.js?$/,
loader: 'babel-loader',
options: {
presets: ["@babel/react", ["@babel/preset-env", {"modules": false}]]
},
exclude: /node_modules/
}]
@jkinkead
jkinkead / index.js
Last active October 19, 2018 16:09
Cloud Function to serve prerendered React
import fs from "fs";
import path from "path";
import React from "react";
import ReactDOMServer from "react-dom/server";
import App from "./app";
const htmlData = `
<html>
<head>
<meta charset="utf-8">
@jkinkead
jkinkead / index.js
Created October 19, 2018 00:12
Simple React index.js
import React from 'react'
import { render, hydrate } from 'react-dom'
import App from './components/App'
hydrate(<App />, document.getElementById('root'))
@jkinkead
jkinkead / App.js
Created October 19, 2018 00:11
Hello World React component
import React from 'react'
const styles = {
titleBar: {
backgroundColor: 'black',
color: 'white'
},
date: {
color: 'blue',
backgroundColor: 'gray',
textAlign: 'center'
@jkinkead
jkinkead / local.js
Created October 19, 2018 00:01
Hot reload configuration
// Save the initial app so we can remove it from the server when
// there are Webpack Hot Module Reload updates.
let currentApp = initialApp
if (module.hot) {
module.hot.accept('../index.js', () => {
// Create a new Express app with the updated Cloud Function
// handlers.
const newApp = setUpApp(require('../index.js'))
// Remove the old Express app.