Skip to content

Instantly share code, notes, and snippets.

View keeth's full-sized avatar

Keith Grennan keeth

View GitHub Profile
@keeth
keeth / Dockerfile
Created April 5, 2023 16:48
Multi-arch BigTable emulator docker image
FROM python:3-slim
COPY build.sh /build.sh
RUN apt-get update -qqy && apt-get install -qqy curl netcat &&\
curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-424.0.0-linux-arm.tar.gz -o google-cloud-cli.tar.gz &&\
tar -xf google-cloud-cli.tar.gz &&\
rm google-cloud-cli.tar.gz &&\
/google-cloud-sdk/install.sh --quiet --usage-reporting=false --screen-reader=false --command-completion=false --path-update=false &&\
/build.sh &&\
apt-get clean
#!/bin/bash
apt update
apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install -y docker-ce
usermod -aG docker ubuntu
@keeth
keeth / whitewater.ts
Created December 30, 2022 15:26
Scrape weather conditions from whitewater website
import { JSDOM } from 'jsdom';
import fetch from "node-fetch";
export type WhitewaterConditions = {
weather: string;
overnightSnowCm: number;
baseTempDegC: number;
}
const WEB_URL = 'https://skiwhitewater.com/conditions/';
@keeth
keeth / index.js
Last active November 4, 2022 19:04
CSP report rate-limiting proxy (cloud function)
const { createClient } = require("redis");
const fetch = require("node-fetch");
const REQUESTS_LIMIT = 1;
const TTL = 60; // seconds
const client = createClient({
url: process.env.REDIS_URL,
});
@keeth
keeth / new-mac-setup.sh
Last active May 16, 2024 21:20
New Mac Setup Commands
#!/bin/bash
# homebew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# essential cli
brew install\
bash\
python\
go\
@keeth
keeth / isNetworkError.js
Last active February 20, 2020 20:30
Is it a fetch network error? (for the purpose of retrying on failure).
/*
https://twitter.com/xinganwang/status/1189266788237885443
github/fetch: TypeError: Network request failed
Chrome: TypeError: Failed to fetch
Firefox: TypeError: NetworkError when attempting to fetch resource.
Safari: TypeError: The Internet connection appears to be offline.
*/
const isNetworkError = e =>
@keeth
keeth / pingmon.py
Created October 10, 2019 21:52
Monitor packet loss to a particular host and send statistics to Cloudwatch
import threading
import time
import logging
logging.basicConfig(level=logging.INFO, format='[%(levelname)s %(asctime)s %(name)s] %(message)s')
logger = logging.getLogger('pingmon')
logger.setLevel(logging.INFO)
import boto3

Keybase proof

I hereby claim:

  • I am keeth on github.
  • I am keeth (https://keybase.io/keeth) on keybase.
  • I have a public key ASCgC0494QvYPRo5H-dPDtqY-Z6mIsW_Z8Hk9PhsfnWhQAo

To claim this, I am signing this object:

@keeth
keeth / cacti.yml
Last active September 17, 2019 02:05
Non-interactive install of Cacti 1.1.23 + Spine 1.1.23 on Ubuntu Server LTS 16.04 EC2 (via Cloud Init / Terraform)
#cloud-config
write_files:
-
content: |
[mysqld]
max_heap_table_size=64M
tmp_table_size=64M
join_buffer_size=64M
innodb_doublewrite=OFF
innodb_buffer_pool_size=242M
@keeth
keeth / 01-next-js.config
Last active October 27, 2021 18:37
Next.js on Elastic Beanstalk, run 'next build' or 'npm run build' from .eb-extensions
container_commands:
01_build:
command: "PATH=$NODE_HOME/bin:$PATH $NODE_HOME/bin/npm run build"