Skip to content

Instantly share code, notes, and snippets.

View LukeMwila's full-sized avatar
👨‍💻
Doing de tings

Lukonde Mwila LukeMwila

👨‍💻
Doing de tings
View GitHub Profile
@LukeMwila
LukeMwila / main.tf
Created June 6, 2020 15:24
Main file with modules for Terraform resources
# GitHub secret
data "aws_secretsmanager_secret" "github_secret" {
name = var.github_secret_name
}
data "aws_secretsmanager_secret_version" "github_token" {
secret_id = data.aws_secretsmanager_secret.github_secret.id
}
# Docker secrets
@LukeMwila
LukeMwila / index.js
Created June 6, 2020 15:21
Lambda function that receive state events from CodePipeline and pushes notifications to Slack
const https = require('https');
const STATUS_GIF = {
started: 'https://media.giphy.com/media/tXLpxypfSXvUc/giphy.gif', // rocket launching
succeeded: 'https://media.giphy.com/media/MYDMiSizWs5sjJRHFA/giphy.gif', // micheal jordan celebrating
failed: 'https://media.giphy.com/media/d2lcHJTG5Tscg/giphy.gif', // anthony anderson crying
canceled: 'https://media.giphy.com/media/IzXmRTmKd0if6/giphy.gif', // finger pressing abort button
}
// Get project issues from Snyk
@LukeMwila
LukeMwila / db.json
Created November 9, 2019 19:41
Database for json-server
{
"players": [
{
"id": "1",
"firstName": "Lebron",
"lastName": "James",
"teamId": "2"
},
{
"id": "2",
@LukeMwila
LukeMwila / auth.ts
Created August 25, 2019 17:25
Helper functions for sign up and sign in logic with AWS Cognito
import * as React from "react";
import {
AuthenticationDetails,
CognitoUserPool,
CognitoUserAttribute,
CognitoUser,
CognitoUserSession,
} from "amazon-cognito-identity-js";
import moment from "moment";
/** Utils */
@LukeMwila
LukeMwila / Styles.tsx
Created May 22, 2019 10:37
Styled components for React Hooks to-do app exercise
import styled from "styled-components";
export const Wrapper = styled.div`
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
& button {
background: rgba(51, 51, 255, 1) !important;
}
@LukeMwila
LukeMwila / SubscribeToProduct.tsx
Created May 8, 2019 20:04
Functional component that displays product plans
import * as React from "react";
import { Row, Col, Button } from "reactstrap";
import { withToastManager } from "react-toast-notifications";
import StripeCheckout from "react-stripe-checkout";
import ErrorMessage from "./ErrorMessage";
import useErrorHandler from "./ErrorHandler";
/** Styling */
import {
CurrencySymbol,
@LukeMwila
LukeMwila / API.ts
Created May 8, 2019 19:07
Function that handles making api requests
/**
* API Request
* @param endPoint - api endpoint
* @param httpMethod - the http method defining the type of request (POST/GET/PUT/PATCH)
* @param bodyParams - object with properties being passed with the request
*/
export const apiRequest = async (
endPoint: string,
httpMethod: string,
@LukeMwila
LukeMwila / ErrorMessage.tsx
Created May 8, 2019 18:32
Presentation component for displaying error message
import * as React from "react";
import styled from "styled-components";
/** Theme */
import { Colors } from "../Theme";
type ErrorMessageProps = {
errorMessage: string | null;
};
import * as React from "react";
const useErrorHandler = (initialState: string | null) => {
const [error, setError] = React.useState(initialState);
const showError = (errorMessage: string | null) => {
setError(errorMessage);
window.setTimeout(() => {
setError(null);
}, 3000);
};
@LukeMwila
LukeMwila / Styles.tsx
Created May 8, 2019 18:16
File containing styled components for product plans to be displayed
import styled from "styled-components";
/** Theme */
import { Colors } from "../Theme";
export const AppWrapper = styled.div`
display: flex;
flex: 1;
min-height: 100vh;
margin: 20px;