Skip to content

Instantly share code, notes, and snippets.

Avatar

Keith Grennan keeth

View GitHub Profile
@keeth
keeth / 00-packages.config
Last active Apr 26, 2021
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 / api.tf
Last active Jan 13, 2021
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",
@keeth
keeth / createWrappedSagaMiddleware.js
Last active Dec 27, 2020
Pre-process (de-batch, filter) actions for redux saga middleware, without affecting the reducers
View createWrappedSagaMiddleware.js
const noop = () => {};
const actionsToIgnore = new Set(['SOME_ACTION', 'SOME_OTHER_ACTION']);
function createWrappedSagaMiddleware() {
const delegate = createSagaMiddleware();
const sagaMiddleware = props => next => {
const actionHandler = delegate(props)(noop);
return action => {
// send to reducers, keep the result
const result = next(action);
@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 / release.rb
Created Aug 10, 2016
Programmatically/script release an iOS app with Spaceship
View release.rb
#!/usr/bin/env ruby
require 'spaceship'
Spaceship::Tunes.login(ENV['FASTLANE_USER'], ENV['FASTLANE_PASSWORD'])
app_id = ARGV.shift
if app_id.nil?
abort('Usage: release.rb com.mycompany.myapp')
@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 / .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 =>
View salt.sls
salt:
master:
fileserver_backend:
- git
gitfs_provider: gitpython
gitfs_remotes:
- git@github-salt:sprightco/salt.git:
- root: salt
- git@github-cms:sprightco/cms.git:
- root: etc/salt
@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