Skip to content

Instantly share code, notes, and snippets.

Avatar

Keith Grennan keeth

  • Vancouver, BC
View GitHub Profile
@keeth
keeth / new-mac-setup.sh
Created Sep 12, 2020
New Mac Setup Commands
View new-mac-setup.sh
#!/bin/bash
# homebew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# bash
chsh -s /bin/bash
echo 'export BASH_SILENCE_DEPRECATION_WARNING=1' >> ~/.bash_profile
git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it
~/.bash_it/install.sh
@keeth
keeth / .babelrc
Last active Apr 8, 2020
Minimal Babel Webpack with dev server
View .babelrc
{ "presets": ["@babel/preset-env"] }
@keeth
keeth / isNetworkError.js
Last active Feb 20, 2020
Is it a fetch network error? (for the purpose of retrying on failure).
View isNetworkError.js
/*
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 Oct 10, 2019
Monitor packet loss to a particular host and send statistics to Cloudwatch
View pingmon.py
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
View keybase.md

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 Sep 17, 2019
Non-interactive install of Cacti 1.1.23 + Spine 1.1.23 on Ubuntu Server LTS 16.04 EC2 (via Cloud Init / Terraform)
View cacti.yml
#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 May 26, 2020
Next.js on Elastic Beanstalk, run 'next build' or 'npm run build' from .eb-extensions
View 01-next-js.config
container_commands:
01_build:
command: "PATH=$NODE_HOME/bin:$PATH $NODE_HOME/bin/npm run build"
@keeth
keeth / 00-packages.config
Last active Aug 3, 2020
Django, Postgres 9.6 and Celery on Elastic Beanstalk - ebextensions
View 00-packages.config
packages:
yum:
libjpeg-turbo-devel: []
libpng-devel: []
libcurl-devel: []
commands:
01_install_rhel_pg:
command: "(yum repolist |grep -q pgdg96) || sudo yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-ami201503-96-9.6-2.noarch.rpm -y"
02_install_pg_devel:
@keeth
keeth / bean-scratch-accel-no-button.ino
Last active Apr 17, 2017
Lightblue Bean Serial/Scratch speed tests with and without accelerometer
View bean-scratch-accel-no-button.ino
uint8_t buffer[20];
String msg = "ABCDEFGHIJKLMNOPQRS";
unsigned long startTest = 20000;
unsigned long stopTest = 40000;
void setup() {
pinMode(A3, INPUT);
msg.toCharArray((char *)buffer,20);
}
@keeth
keeth / api.tf
Last active Apr 21, 2020
Apex + Terraform + AWS Lambda + API Gateway + JSON Encoded Errors + CORS
View api.tf
resource "aws_api_gateway_rest_api" "myApi" {
name = "myApi-${var.env}"
description = "My awesome API (${var.env} environment)"
}
resource "aws_api_gateway_deployment" "myApi" {
depends_on = [
"aws_api_gateway_integration.myApi_myEndpoint_post",
"aws_api_gateway_integration_response.myApi_myEndpoint_post",
"aws_api_gateway_integration_response.myApi_myEndpoint_post_400",
You can’t perform that action at this time.