Skip to content

Instantly share code, notes, and snippets.

Avatar
🙃
Play

Brian brianfoody

🙃
Play
View GitHub Profile
@brianfoody
brianfoody / .bashrc
Created Apr 12, 2021
GitHub alias to add, commit and publish
View .bashrc
gitc () {
msg=${1:-'Quick commit'}
git add . && git commit -m "$msg" && git push origin $(git branch | sed -n "/\* /s///p")
}
View CFHealthCheckRight
Type: AWS::Route53::HealthCheck
Properties:
HealthCheckConfig:
Port: 443
Type: HTTPS
ResourcePath: /prod/system/health/check
FullyQualifiedDomainName:
Fn::Join:
- ""
- - Ref: sensiveRootSensiveRegionalApiF65332A1
View CFHealthCheck
Type: AWS::Route53::HealthCheck
Properties:
HealthCheckConfig:
port: 443
type: HTTPS
resourcePath: /prod/system/health/check
fullyQualifiedDomainName:
Fn::Join:
- ""
- - Ref: sensiveRootSensiveRegionalApiF65332A1
View HealthCheck
new CfnHealthCheck(this, "ApiHealthCheck", {
healthCheckConfig: {
port: 443,
type: "HTTPS",
resourcePath: "/prod/system/health/check",
fullyQualifiedDomainName: `${this.api.restApiId}.execute-api.${props.region}.amazonaws.com`,
requestInterval: 30,
failureThreshold: 2
}
});
View mystack.test.ts
test("EventBridge and resources are created", () => {
const app = new cdk.App();
const stack = new MyEvents.MyEventsStack(app, "MyTestStack");
expectCDK(stack).to(haveResource("AWS::Events::EventBus"));
expectCDK(stack).to(haveResource("AWS::EventSchemas::Registry"));
expectCDK(stack).to(haveResource("AWS::EventSchemas::Schema"));
@brianfoody
brianfoody / dataclasses.py
Created Oct 1, 2020
Data classes with replace
View dataclasses.py
from dataclasses import dataclass, replace
from typing import List, Optional
@dataclass(frozen=True)
class State:
val1: float
val2: float
@dataclass
class Controller:
@brianfoody
brianfoody / UserEvents.ts
Created Aug 24, 2020
User Events Sample
View UserEvents.ts
type MembershipType = "Basic" | "Pro" | "Premium";
type SignUp = {
userId: string;
phoneNumber: string;
membershipType: MembershipType;
};
type MembershipUpdate = {
membershipType: MembershipType;
@brianfoody
brianfoody / OrgEvents.ts
Last active Aug 24, 2020
Organisational Event typings
View OrgEvents.ts
import { Events as MarketingEvents } from "./MarketingEvents";
import { Events as SalesEvents } from "./SalesEvents";
import { Events as UserEvents } from "./UserEvents";
type EventsBySource = {
Marketing: MarketingEvents;
Sales: SalesEvents;
User: UserEvents;
};
@brianfoody
brianfoody / schema.ts
Last active Aug 24, 2020
Create EventBridge Schema from TypeScript
View schema.ts
import * as schemas from "@aws-cdk/aws-eventschemas";
import * as cdk from "@aws-cdk/core";
import { generateOpenApiSchema } from "./generators/schemaGenerator";
...
this.schema = new schemas.CfnSchema(this, "MySchema", {
registryName: props.mlRegistry.attrRegistryName,
type: "OpenApi3",
description: "Schema Definition for my events",
@brianfoody
brianfoody / tsToOpenApi.ts
Last active Aug 23, 2020
TypeScript to OpenAPI 3
View tsToOpenApi.ts
import * as tsj from "ts-json-schema-generator";
const toOpenApi = require("json-schema-to-openapi-schema");
const defaultConfig: SchemaConfig = {
tsconfig: "./tsconfig-types.json",
type: "*",
};
export const generateOpenApiSchema = (
schemaName: string,