Skip to content

Instantly share code, notes, and snippets.

Avatar

Tyler Sustare TylerSustare

View GitHub Profile
View CloudFormationExample.yaml
# Super simple example
Resources:
Ec2Instance:
Type: 'AWS::EC2::Instance'
Properties:
InstanceType: t2.micro
ImageId: ami-46ca739 # Amazon Linux AMI
# Update with a Tag
Tags:
- Key: Name
View .prettierrc
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"bracketSpacing": true,
"jsxBracketSameLine": true,
"arrowParens": "avoid",
"printWidth": 160
}
@TylerSustare
TylerSustare / change_the_rest.js
Last active Sep 17, 2019
Neat use of rest operator in React
View change_the_rest.js
class SomeClass extends Component {
onChange({ ...rest }) {
this.setState(rest);
};
options = {
// ...
onChangePage: currentPage => this.onChange({ currentPage }),
onChangeRowsPerPage: numberOfRows => this.onChange({ numberOfRows })
};
@TylerSustare
TylerSustare / batchedSequentialPromiseAll.js
Created Sep 26, 2019
Sequential Promise.all() in batches
View batchedSequentialPromiseAll.js
const waait = i => new Promise(res => setTimeout(() => { return res(i); }, 2000));
const batchedPromiseAll = async (array) => {
let requests = array.slice(0);
let results = [];
let processBatch = async (chunks, results) => {
let curr;
try {
@TylerSustare
TylerSustare / app.js
Created Jan 10, 2020
firebase realtime database data
View app.js
import React, { Component } from 'react'
import firebase from 'firebase';
export default class List extends Component {
constructor(props) {
super(props);
this.state = {
loaded: false,
data: {},
};
View tsconfig.json
{
"compilerOptions": {
"target": "es2018",
"module": "commonjs",
"lib": ["ESNext", "ES2019", "es2018", "es2017", "es7", "es6", "dom"],
"declaration": true,
"outDir": "./dist",
"strict": false,
"esModuleInterop": true,
"resolveJsonModule": true,
@TylerSustare
TylerSustare / iterateOverEnum.ts
Created Jun 12, 2020
Itterate through string enum in TypeScript
View iterateOverEnum.ts
export enum EnumType {
choice = 'choice',
checkbox = 'checkbox',
boolean = 'boolean',
blank = 'blank',
match = 'match',
order = 'order'
}
export const getEnumTypeValues = (): { key: string; text: string }[] =>
@TylerSustare
TylerSustare / pretty_log.js
Created Oct 9, 2020
Fantastic Console Logs
View pretty_log.js
console.log("%cPLS WORK!!!!","color: red; font-family:sans-serif; font-size: 20px");
console.log("%cYAY it worked!","color: cyan; font-family:sans-serif; font-size: 24px");
@TylerSustare
TylerSustare / docker-compose.yaml
Last active Oct 20, 2020
Postgres, Mongo, DynamoDB, and Redis Docker compose. Just start 'em all and see what happens.
View docker-compose.yaml
# inspiration
# https://dev.to/pfreitag/running-postgresql-in-docker-for-local-dev-2ojk
# https://medium.com/faun/managing-mongodb-on-docker-with-docker-compose-26bf8a0bbae3
# https://rharshad.com/dynamodb-local-docker/
# https://docs.fauna.com/fauna/current/integrations/dev.html#requirements
# instructions
# 1. start 'em up
# docker-compose up -d
@TylerSustare
TylerSustare / boot.sh
Last active Aug 15, 2021
Ubuntu Boot Script with Caddy
View boot.sh
apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo tee /etc/apt/trusted.gpg.d/caddy-stable.asc
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
apt update
apt full-upgrade -y
apt install caddy