Skip to content

Instantly share code, notes, and snippets.

View christopher-caldwell's full-sized avatar

Christopher Caldwell christopher-caldwell

View GitHub Profile

AWS Services Breakdown

This guide is intended for the absolute beginner to AWS. It assumes you know little to nothing about AWS.

Lambda

A "serverless" function ran without provisioning a certain server for a given amount of time. The concept of serverless is a huge topic, but the basic idea is that the starting and stopping of the server is abstracted away. When you ask it to run, it runs. After the code is done, the server stops running. You are only charged for the server when it's running.

They are completely stateless, and are essentially a new boot every time they run. This means that session level things maintained by a Lambda, such as auth session, are not possible.

@christopher-caldwell
christopher-caldwell / progress-bar.sh
Created April 28, 2021 18:59
Shell progress bar
#!/bin/bash
echo '##### (33%)\r\c'
sleep 1
echo '############# (66%)\r\c'
sleep 1
echo '####################### (100%)\r\c'
echo '\n'
@christopher-caldwell
christopher-caldwell / quickSort.js
Created April 28, 2021 19:12
WIP implementation of a Quick Sort algorithm
const baseArray = [
{value: 1},
{value: 4},
{value: 8},
{value: 9},
{value: 7},
{value: 2},
{value: 3},
{value: 5},
{value: 6},
@christopher-caldwell
christopher-caldwell / template.yml
Created April 29, 2021 23:23
Redis CloudFormation
Transform: 'AWS::Serverless-2016-10-31'
Parameters:
ClusterName:
Type: String
Stage:
Type: String
Resources:
@christopher-caldwell
christopher-caldwell / deploy-container.sh
Created April 29, 2021 23:26
Deploying a Docker container to ECR
#!/bin/sh
Red="\033[0;31m" # Red
Green="\033[0;32m" # Green
BICyan="\033[1;96m" # Bold Cyan
# Reset
Color_Off="\033[0m" # Text Reset
printf "\n\n$BICyan$( echo Deploying the Docker container )$Color_Off"
@christopher-caldwell
christopher-caldwell / template.yml
Created April 29, 2021 23:28
Using CodeBuild with a custom Docker image
Transform: 'AWS::Serverless-2016-10-31'
Parameters:
Stage:
Type: String
CloudFrontDistributionId:
Type: String
BranchToRunBuildFrom:
Type: String
RepositoryUrl:

Lambda vs ECS

Lambda

Steps

  • Develop Code
  • Publish Lambda, code lives in S3

Limits

@christopher-caldwell
christopher-caldwell / index.d.ts
Last active July 13, 2021 15:45
Uphold SDK Types
/** Types for @uphold/uphold-sdk-javascript as of July 9th, 2021
* Use as your own risk, as these types are created by hand from someone outside of the Uphold organization.
*/
declare module '@uphold/uphold-sdk-javascript' {
type HttpMethod = string // 'get' | 'post' | 'delete' | 'put' | 'patch'
export interface SdkConstructorArgs {
/** Key used to store the access token
* @default uphold.access_token
*/
@christopher-caldwell
christopher-caldwell / index.ts
Created March 19, 2022 23:33
Uploading file from WYSIWYG editor
import type { EditorConfig } from '@editorjs/editorjs'
// The image tool has no types, if using TS you'll need to define them. See below for example
import ImageTool from '@editorjs/image'
import axios from 'axios'
const editorOptions: EditorConfig = {
tools: {
image: {
class: ImageTool,
config: {
@christopher-caldwell
christopher-caldwell / codegen.ts
Created September 28, 2023 01:59
Codegen with mappers to models
import { CodegenConfig } from '@graphql-codegen/cli'
const modelNames = [
'User',
'Contractor',
'JobSite',
'Project',
'PunchListItem',
'ScheduleItem',
'Section',