Skip to content

Instantly share code, notes, and snippets.

@Nxtra
Nxtra / commands.js
Created November 6, 2020 20:48
Cypress custom Amplify command.
Cypress.Commands.add("signIn", () => {
cy.then(() => Auth.signIn(username, password)).then((cognitoUser) => {
const idToken = cognitoUser.signInUserSession.idToken.jwtToken;
const accessToken = cognitoUser.signInUserSession.accessToken.jwtToken;
const makeKey = (name) => `CognitoIdentityServiceProvider.${cognitoUser.pool.clientId}.${cognitoUser.username}.${name}`;
cy.setLocalStorage(makeKey("accessToken"), accessToken);
cy.setLocalStorage(makeKey("idToken"), idToken);
cy.setLocalStorage(
@Nxtra
Nxtra / example.test.js
Created November 6, 2020 20:51
Call custom signIn command before cypress test suite
describe("Example test", () => {
before(() => {
cy.signIn();
});
after(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage();
});
@Nxtra
Nxtra / template.yaml
Last active November 8, 2020 13:04
Setup a billing alarm for your AWS account with cloudformation
AWSTemplateFormatVersion: "2010-09-09"
Description: Billing Alerts for your AWS Account
Parameters:
Email:
Type: String
Default: youremail@somerandomdomain.com
Description: The email address to receive alerts per email
Phone:
@Nxtra
Nxtra / schema.graphql
Last active November 25, 2020 22:45
Amplify schema with relations and custom mutation
type Blog @model {
id: ID!
name: String!
posts: [Post] @connection(keyName: "byBlog", fields: ["id"])
}
type Post @model @key(name: "byBlog", fields: ["blogID"]) {
id: ID!
title: String!
blogID: ID!
@Nxtra
Nxtra / template.json
Last active November 26, 2020 00:01
Amplify lambda access dynamodb api resources policy
"AccessDynamoDBApiResourcesPolicy": {
"DependsOn": ["LambdaExecutionRole"],
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyName": "amplify-lambda-execution-policy",
"Roles": [
{
"Ref": "LambdaExecutionRole"
}
],
@Nxtra
Nxtra / index.js
Last active December 6, 2020 13:22
A lambda function to resolve the editPostAndComments mutation.
const AWS = require("aws-sdk");
const docClient = new AWS.DynamoDB.DocumentClient();
const POSTTABLE = process.env.POSTTABLE;
const COMMENTTABLE = process.env.COMMENTTABLE;
const resolvers = {
Mutation: {
deletePostAndComments: (event) => {
@Nxtra
Nxtra / openapi-generator-maven-plugin-configuration.xml
Last active January 16, 2021 06:46
An example of how to configure the openapi-generator plugin for your maven projects
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<skipValidateSpec>false</skipValidateSpec>
@Nxtra
Nxtra / blog.md
Created January 28, 2021 12:29
athena blog

Serverless data pipelines: ETL workflow with Step Functions and Athena

This blog is Part 3 of a multi-part series around analysing Flanders’ traffic whilst leveraging the power of cloud components!
For part 1 see: https://medium.com/cloudway/real-time-data-processing-with-kinesis-data-analytics-ad52ad338c6d
For part 2 see: https://medium.com/cloubis/serverless-data-transform-with-kinesis-e468abd33409

What is our goal?

This blog aims to explore the use of the AWS Glue service in conjunction with the AWS Athena service to repartition raw streaming data events.
We previously landed these events on an Amazon S3 bucket partitioned according to the processing time on Kinesis.

@Nxtra
Nxtra / delete-all-models.py
Created January 17, 2020 07:38
Delete all sagemaker models
import boto3
from pprint import pprint
client = boto3.client('sagemaker')
def main():
model_names = []
for key in paginate(client.list_models):