Skip to content

Instantly share code, notes, and snippets.

@tatethurston
tatethurston / wifi
Created December 2, 2024 00:13
replacement for airport wifi scanning
system_profiler SPAirPortDataType | awk '
BEGIN { printf "%-30s %-10s %-5s\n", "SSID", "Channel", "Signal" }
/Other Local Wi-Fi Networks:/ { start = 1; next }
/:/ {
if (start == 0 ) { next }
if (block == 0) {
ssid = $0
@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 / 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;
@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'
@tatethurston
tatethurston / poll.js
Created November 14, 2017 19:10
JavaScript polling
// 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 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 / webpack.config.js
Created November 12, 2017 22:38
Webpack config with HMR + deterministic content hashing
const _ = require('lodash');
const isDev = process.env.NODE_ENV !== 'production'
const APP_PATH = '';
const BUILD_PATH = '';
const config = {
// Fail early
bail: true,