Skip to content

Instantly share code, notes, and snippets.

View keeth's full-sized avatar

Keith Grennan keeth

View GitHub Profile
@keeth
keeth / new-mac-setup.sh
Last active October 28, 2023 00:57
New Mac Setup Commands
#!/bin/bash
# homebew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# bash-it
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 / 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 / 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"
@keeth
keeth / createWrappedSagaMiddleware.js
Last active October 9, 2021 16:04
Pre-process (de-batch, filter) actions for redux saga middleware, without affecting the reducers
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 / 00-packages.config
Last active April 26, 2021 00:35
Django, Postgres 9.6 and Celery on Elastic Beanstalk - ebextensions
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 January 13, 2021 14:34
Apex + Terraform + AWS Lambda + API Gateway + JSON Encoded Errors + CORS
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 / release.rb
Created August 10, 2016 05:54
Programmatically/script release an iOS app with Spaceship
#!/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')