Skip to content

Instantly share code, notes, and snippets.

mrcoles / parcel-local-proxy.js
Last active Dec 4, 2019
A simple proxy script for controlling URL rewriting when running Parcel with multiple entry points (including https support)
View parcel-local-proxy.js
const chalk = require('chalk');
const fs = require('fs');
const http = require('http');
const https = require('https');
const yargs = require('yargs');
// Configuration
mrcoles / aws-amplify-build-settings-cache-static-files.yml
Last active Mar 9, 2021
Sample file caching custom headers to add to an AWS Amplify build-settings.yml file
View aws-amplify-build-settings-cache-static-files.yml
# cache static assets! (can I just use a glob for this, e.g., '**/*.{js,css,gif,ico,jpg,png,svg,mp4,webm}' ?)
# js
- pattern: '**/*.js'
headers: [ { key: 'Cache-Control', value: 'public,max-age=31536000,immutable' } ]
# css
- pattern: '**/*.css'
headers: [ { key: 'Cache-Control', value: 'public,max-age=31536000,immutable' } ]
# images
mrcoles / Plural.tsx
Created Jul 26, 2019
A simple React component for handling pluralization of a word.
View Plural.tsx
import React from 'react';
export const Plural = ({
}: {
num: number;
mrcoles / clean-amplify-s3-builds.js
Created Jun 25, 2019
A script for deleting old amplify builds in s3 and keeping the 5 most recent ones.
View clean-amplify-s3-builds.js
const AWS = require('aws-sdk');
const PREFIX = 'amplify-builds/';
const DEFAULT_KEEP_N = 5;
const DEFAULT_DRY_RUN = false;
const s3 = new AWS.S3();
// ## Main
mrcoles /
Last active May 15, 2019
Simple template for a python script that uses argparse and reads in and prints out a CSV or TSV
import csv
def run(infile, outfile, is_tsv=False, dry_run=False):
dialect = 'excel-tab' if is_tsv else 'excel'
reader = csv.DictReader(infile, dialect=dialect)
writer = None
is_first = True
for row in reader:
mrcoles /
Created Apr 5, 2019
Script for cropping iPhone X screen recordings with ffmpeg
#!/usr/bin/env bash
print_usage() {
mrcoles /
Last active May 13, 2019
The steps I followed to setup AWS Cognito for a React AWS Amplify project using the hosted UI with sign in/sign up by email and also social sign in

Steps to setup the AWS Cognito hosted UI with email sign up/sign in for a React AWS Amplify Project

This was done using the amplify cli v0.2.2-multienv.1.

The goal was to:

  1. Create an auth setup for my React AWS Amplify project
  2. Use email as the sign up/sign in id and make sure it's unique
  3. Offer social sign in with Facebook and Google (and have those users also end up in the Cognito user pool—this appeared to only be possible using the hosted UI)
mrcoles / LoaderDots.jsx
Last active Mar 13, 2019
LoaderDots.jsx: a React loader component (to show when waiting on a network call)
View LoaderDots.jsx
import React from 'react';
export default ({
fill = '#666666',
width = 52,
height = 12,
scale = 1,
style = {}
}) => (
mrcoles / extract-props.d.ts
Created Mar 6, 2019
A simple function to split up a props object into specified `customProps` that match `keys` and the remaining `spreadProps`
View extract-props.d.ts
declare module "extract-props" {
export interface ExtractedProps {
spreadProps: object;
customProps: object;
export default function extractProps(props: object, keys: string[]): ExtractedProps;
mrcoles /
Last active Apr 5, 2019
Script for compressing a video to .mp4 and .webm with ffmpeg
#!/usr/bin/env bash
# inspired by:
if [ -z "$INPUT" ]; then
echo "No file specified"
exit 1