Skip to content

Instantly share code, notes, and snippets.

@brianfoody
brianfoody / cleanup.ts
Last active April 4, 2022 03:32
How to do a StepFunction cleanup post deploy
const taskWaitThreeHours = new sfn.Wait(this, "Wait 3 hours for tasks to have executed.", {
time: sfn.WaitTime.duration(cdk.Duration.hours(3))
});
const deprovisionLambda = new nodeLambda.NodejsFunction(this, "deprovisionFn", {
runtime: lambda.Runtime.NODEJS_14_X,
entry: "workflow/deprovision.ts",
handler: "main",
timeout: cdk.Duration.seconds(30),
logRetention: logs.RetentionDays.ONE_MONTH,
@brianfoody
brianfoody / monorepo.mjs
Created January 5, 2022 18:15
Clone an environment
await Promise.all([$`sleep 1; echo 1`, $`sleep 2; echo 2`, $`sleep 3; echo 3`]);
@brianfoody
brianfoody / cloudwatch.sql?
Created November 4, 2021 12:54
Cloudwatch Insights
// Get memory stats and see if any are overprovisioned
filter @type = "REPORT"
| stats max(@memorySize / 1000 / 1000) as provisonedMemoryMB,
min(@maxMemoryUsed / 1000 / 1000) as smallestMemoryRequestMB,
avg(@maxMemoryUsed / 1000 / 1000) as avgMemoryUsedMB,
max(@maxMemoryUsed / 1000 / 1000) as maxMemoryUsedMB,
provisonedMemoryMB - maxMemoryUsedMB as overProvisionedMB
@brianfoody
brianfoody / initialise.sh
Last active September 24, 2021 17:43
New Python Project
pyenv local 3.9.4
python -m pip install --user virtualenv
python -m virtualenv .env
source .env/bin/activate
python -m pip install pandas matplotlib
python -m pip freeze > requirements.txt
@brianfoody
brianfoody / fixLz.sh
Created September 9, 2021 12:26
Fix lz incomplete install
prefix=$(brew --prefix)
export LDFLAGS="-L$prefix/opt/xz/lib $LDFLAGS"
export CPPFLAGS="-I$prefix/opt/xz/include $CPPFLAGS"
export PKG_CONFIG_PATH="$prefix/opt/xz/lib/pkgconfig:$PKG_CONFIG_PATH"
# YOU CANNOT HAVE THE GNUBINS in your PATH when you run this
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.9.4
python3 -c "import lzma" # should work and not throw "cannot import _lzma"
@brianfoody
brianfoody / broadcast.test.ts
Last active July 9, 2021 03:58
Broadcast Verification
import "isomorphic-fetch";
import { defineFeature, loadFeature } from "jest-cucumber";
import * as uuid from "uuid";
import * as http from "http";
import ngrok from "ngrok";
const feature = loadFeature("./acceptance/broadcast.feature");
defineFeature(feature, (test) => {
let ngrokUrl: string;
@brianfoody
brianfoody / Broadcast.feature
Created July 9, 2021 03:42
BDD Test for broadcasting of SNS
Feature: Broadcast that a item has been added so that downstream listeners can action.
Scenario: When a new item is added to the table it should be published to the mySNSTopicName topic.
Given I have a listener subscribed to the "mySNSTopicName" SNS topic
And I have an "MyDynamoTable" table
When an item is added
Then I will receive a message notifying me of it
And I will be able to read it from the table.
@brianfoody
brianfoody / .bashrc
Created April 12, 2021 08:45
GitHub alias to add, commit and publish
gitc () {
msg=${1:-'Quick commit'}
git add . && git commit -m "$msg" && git push origin $(git branch | sed -n "/\* /s///p")
}
@brianfoody
brianfoody / CFHealthCheckRight
Created October 25, 2020 09:53
CFHealthCheckRight
Type: AWS::Route53::HealthCheck
Properties:
HealthCheckConfig:
Port: 443
Type: HTTPS
ResourcePath: /prod/system/health/check
FullyQualifiedDomainName:
Fn::Join:
- ""
- - Ref: sensiveRootSensiveRegionalApiF65332A1
@brianfoody
brianfoody / CFHealthCheck
Created October 25, 2020 09:51
CFHealthCheck
Type: AWS::Route53::HealthCheck
Properties:
HealthCheckConfig:
port: 443
type: HTTPS
resourcePath: /prod/system/health/check
fullyQualifiedDomainName:
Fn::Join:
- ""
- - Ref: sensiveRootSensiveRegionalApiF65332A1