Skip to content

Instantly share code, notes, and snippets.

@tatethurston
tatethurston / AWS-Amplify-SEO-Redirects.md
Last active July 24, 2023 19:53
AWS Amplify Redirect Rules for SEO
Source address Target address Type Country code
https://tatethurston.com https://www.tatethurston.com 301 (Redirect - Permanent) -
/<a>/ /<a> 301 (Redirect - Permanent) -
/<a>/<b>/ /<a>/<b> 301 (Redirect - Permanent) -
/<a>/<b>/<c>/ /<a>/<b>/<c> 301 (Redirect - Permanent) -
/<\*> /404 404 (Rewrite) -
@tatethurston
tatethurston / ajax.js
Created June 28, 2017 18:54
Retry jQuery AJAX requests with exponential backoff
import $ from 'jquery';
import uuidv4 from 'uuid/v4';
const wait = ms => $.Deferred(defer => setTimeout(defer.resolve, ms));
const request = (opts, numTries = 0) => {
/*
* Retry failed requests 2 additional times with exponential backoff
*/
const RETRY_COUNT = 2;
@tatethurston
tatethurston / gist:2d244e692f16d504a86033274e06b520
Created September 18, 2020 00:29
Filenames for TypeScript type check failures
tsc --noEmit | grep -o 'src/[^\(]*'
@tatethurston
tatethurston / .eslintrc.js
Created September 12, 2020 17:22
TypeScript backend eslint config
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
},
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
@tatethurston
tatethurston / SimpleAuthServer.py
Created March 14, 2018 22:25 — forked from fxsjy/SimpleAuthServer.py
SimpleAuthServer: A SimpleHTTPServer with authentication
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import sys
import base64
key = ""
class AuthHandler(SimpleHTTPRequestHandler):
''' Main class to present webpages and authentication. '''
def do_HEAD(self):
@tatethurston
tatethurston / index.js
Last active December 29, 2017 08:53
node multiprocess
import * as throng from 'throng';
const { WEB_CONCURRENCY = 1, PORT = "" } = process.env;
const start = async (id: number) => {
/*
* This could be imported statically at the top, but then the master process
* could be crashed.
*/
const server = require('./server').default;
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
post_slack() {
SLACK_URL="TODO:_FILL_ME_IN"
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"text\": \"$1\"}" \
@tatethurston
tatethurston / .eslintrc.js
Last active November 23, 2017 02:45
.eslintrc import/no-unresolved NODE_PATH
module.exports = {
"extends": "eslint:recommended",
"env": {
"node": true,
"mocha": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 8
},
@tatethurston
tatethurston / deploy-to-s3.js
Last active November 19, 2017 12:46
node script for AWS S3 uploads
/*
* NOTE: You'll need to follow the steps outlined in aws-config.js.example
* before running this deploy script for the first time
*/
// https://github.com/andrewrk/node-s3-client
const s3 = require('s3');
const DIRECTORY = 'dist';
@tatethurston
tatethurston / docker-compose.yml
Last active November 19, 2017 10:09
rails docker compose
version: '3'
services:
db:
image: postgres
# ports:
# - "5432:5432"
web:
image: ruby:2.3-onbuild
command: bundle exec rails s -p 5000 -b '0.0.0.0'