Skip to content

Instantly share code, notes, and snippets.

Avatar

Tate Thurston tatethurston

View GitHub Profile
@tatethurston
tatethurston / gist:2d244e692f16d504a86033274e06b520
Created Sep 18, 2020
Filenames for TypeScript type check failures
View gist:2d244e692f16d504a86033274e06b520
tsc --noEmit | grep -o 'src/[^\(]*'
@tatethurston
tatethurston / .eslintrc.js
Created Sep 12, 2020
TypeScript backend eslint config
View .eslintrc.js
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 Mar 14, 2018 — forked from fxsjy/SimpleAuthServer.py
SimpleAuthServer: A SimpleHTTPServer with authentication
View SimpleAuthServer.py
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 Dec 29, 2017
node multiprocess
View index.js
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;
@tatethurston
tatethurston / docker-compose.yml
Last active Nov 19, 2017
rails docker compose
View docker-compose.yml
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'
@tatethurston
tatethurston / poll.js
Created Nov 14, 2017
JavaScript polling
View poll.js
// fn: () => Promise<Boolean>
const poll = (fn, interval = 100, maxWait = 60000) => {
const start = Date.now();
let last = 0;
return new Promise((resolve, reject) => {
const _poll = () => {
const now = Date.now();
console.log(start, last, now, interval);
if (now > start + maxWait) {
@tatethurston
tatethurston / deploy-to-s3.js
Last active Nov 19, 2017
node script for AWS S3 uploads
View deploy-to-s3.js
/*
* 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 / webpack.config.js
Created Nov 12, 2017
Webpack config with HMR + deterministic content hashing
View webpack.config.js
const _ = require('lodash');
const isDev = process.env.NODE_ENV !== 'production'
const APP_PATH = '';
const BUILD_PATH = '';
const config = {
// Fail early
bail: true,
View rails-api-setup.sh
NAME=''
rails new $NAME \
--api \
--database=postgresql \
--skip-action-cable
cd $NAME
rm -rf \
View heroku-deploy.sh
#!/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\"}" \