Skip to content

Instantly share code, notes, and snippets.

@DavidDeCoding
DavidDeCoding / go_jwt_token_gen_valid.go
Last active February 9, 2024 04:43
Golang JWT Token Generation and Validation
package main
import (
"crypto"
"crypto/hmac"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
// "crypto/x509"
"encoding/base64"
@DavidDeCoding
DavidDeCoding / on_message.py
Created August 16, 2022 19:34
Whiteboarding - on_message.py
import boto3
import os
import json
WHITEBOARDING_TABLE = os.environ['WHITEBOARDING_TABLE']
db_client = boto3.resource('dynamodb')
table = db_client.Table(WHITEBOARDING_TABLE)
def handler(event, context):
@DavidDeCoding
DavidDeCoding / serverless.yml
Created August 16, 2022 19:20
Whiteboarding - serverless.yml
service: whiteboarding
package:
individually: true
provider:
name: aws
runtime: python3.8
region: us-west-1
stage: ${opt:stage, "dev"}
@DavidDeCoding
DavidDeCoding / serverless.yml
Created May 2, 2022 17:55
CustomDomainAPIGateway
frameworkVersion: "3"
provider:
name: aws
stage: dev
runtime: nodejs12.x
custom:
STAGE: ${opt:stage, 'dev'}
stagedCustomDomainProps:
@DavidDeCoding
DavidDeCoding / expressJSSampledeploy
Created March 27, 2022 07:04
Deploy Script to push Image to ECR - Sample ExpressJS App
#!/bin/bash
aws ecr get-login-password --region us-west-1 | docker login --username AWS --password-stdin XXXXXXXXX.dkr.ecr.us-west-1.amazonaws.com/hello_word_expressjs_app &&
docker build -t hello_world_expressjs_app . &&
docker tag hello_world_expressjs_app:latest XXXXXXXX.dkr.ecr.us-west-1.amazonaws.com/hello_world_expressjs_app:latest &&
docker push XXXXXXXXX.dkr.ecr.us-west-1.amazonaws.com/hello_world_expressjs_app:latest
@DavidDeCoding
DavidDeCoding / expressJSSampleAppDockerfile
Created March 27, 2022 06:18
Sample ExpressJS Application Dockerfile
FROM node:12.4-alpine
RUN mkdir /app
WORKDIR /app
COPY package.json .
RUN npm install && mv node_modules /node_modules
@DavidDeCoding
DavidDeCoding / expressJSSampleApp.js
Created March 27, 2022 06:08
Sample ExpressJS Web Application
const express = require('express');
const app = express();
const port = 80;
app.get('/', (req, res) => {
res.send("Hello World!");
});
app.listen(port, () => {
@DavidDeCoding
DavidDeCoding / coupon_reminders_part2_processor.py
Last active March 5, 2022 18:18
Building Coupon Reminders - Part 2 Serverless and Secured Image Storage and Processing - coupon_processor.py
import Coupon
def handler(event, context):
for event in event["Records"]:
if event["eventName"] == "ObjectCreated:Put":
image_full_name = event["s3"]["object"]["key"]
Coupon.process_and_store(image_full_name)
return
@DavidDeCoding
DavidDeCoding / coupon_reminders_part2_service.py
Last active March 5, 2022 18:13
Building Coupon Reminders - Part 2 Serverless and Secured Image Storage and Processing - service.py
import datetime
import os
import boto3
import base64
import io
import pytesseract
from PIL import Image
from base64 import b64encode
from typing import List
@DavidDeCoding
DavidDeCoding / coupon_reminders_part2_apis.py
Last active March 5, 2022 18:18
Building Coupon Reminders - Part 2 Serverless and Secured Image Storage and Processing - app.py
from pydantic import BaseModel
from typing import List
from fastapi import FastAPI
from mangum import Mangum
import Coupon
class AddCouponRequest(BaseModel):
user_id: str