Skip to content

Instantly share code, notes, and snippets.

mrcoles / index.html
Created Oct 5, 2018
redux-undo@1.0.0-beta-9.9.7 filter inconsistency
View index.html
<!DOCTYPE html>
<meta charset=utf-8 />
<title>Redux Undo Filter Test</title>
<p>See info in JS console</p>
<script src="store.js"></script>
mrcoles / replace_words.js
Last active Nov 28, 2018
Replace all instances of one word with another in a web page
View replace_words.js
// ### Replace words in document
// Update all instances of `fromWord` to `toWord` within the text
// in the current document.
function replaceWordsInDocument(fromWord, toWord) {
if (/\s/.test(fromWord)) {
throw new Error('You must enter a single word without whitespace');
mrcoles / unirest_promise.js
Created Sep 8, 2017
Node Unirest Promise Wrapper
View unirest_promise.js
function unirest_prom(unirest_req, always_resolve) {
// Returns a Promise by wrapping a unirest.Request object in
// a Promise that immediately calls `.end(...)`
// Params:
// * unirest_req - unirest.Request - any unirest Request object that has
// not yet had `.end(...)` called on it
// * always_resolve - bool (optional) - defaults to `false`, iff `true` then
// the Promise always resolves--even when the request fails
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 / 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 /
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
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 /
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 / 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