Skip to content

Instantly share code, notes, and snippets.

View clodal's full-sized avatar

clodal clodal

  • Singapore
View GitHub Profile
@clodal
clodal / vercel-git-migration.MD
Created October 17, 2020 09:04
Vercel + Git Migration

How to setup Vercel + Git integration

Why?

  • To eliminate gap between code-merge and deployment for seamless releases
  • To eliminate guesswork out of the latest staging link status etc.
  • To eliminate labour of manual link-sharing

How it works

Using Vercel's built-in Git integration with Bitbucket, every code merge to any branch will automatically create a staging/preview link. Code merge to the release branch will automatically create a production link.

@clodal
clodal / ec2-node-app.md
Last active June 9, 2024 12:46
How to deploy NodeJS App to EC2

How to deploy NodeJS App to EC2

Instructions

  1. Connect to ec2 via ssh
  2. Install nvm: https://github.com/nvm-sh/nvm via curl e.g. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
  3. Source nvm: . ~/.nvm/nvm.sh
  4. Install node: nvm install <your_version>
  5. Install git: sudo yum install -y git
  6. Git clone your project and cd in
  7. Install yarn: npm i -g yarn

How to start

  1. Run yarn dev at localhost:3000
  2. Run yarn test to test all the files (Impt: Please ensure that you have step 1 running in the background)

Key commands

  • Run yarn test --headless to test programmatically without the UI
  • Run yarn test:debug to print debug info
  • Run yarn test <filename> to test an individual file
  • Run killall -9 Chromium to close stale Chromium browsers left behind by failed tests
@clodal
clodal / add-mailgen-lambda.md
Last active October 6, 2020 06:33
Add Mailgen to Lambda

Amplify Email Template Solution (AWS Pinpoint + Mailgen)

We use Mailgen to generate email template html body. We need to use a Lambda because Mailgen is a backend-only package as it relies on ESJ (a kind of server-side templating language). Using Mailgen on the FE is not possible.

The idea is to fire a request to this lambda to generate the html template and pass it off to AWS Pinpoint to fire the email.

Pre-Requisites

  1. amplify add analytics and amplify push to add Pinpoint
  2. Access Key & Secret Access Key of IAM User with PinPointFullAccess
@clodal
clodal / init-amplify-stack.md
Last active January 13, 2021 07:34
Init Amplify Stack

How to init Amplify Stack

1. Clone

  • cd sites
  • mkdir -p slk/slk-api
  • cp -rf vts/vts-api slk/slk-api

2. Clean

  • If you are on a mono-repo, cd to each of the package folder to run the following commands.
  • rm -rf .env .vercel .now .next .idea .git .graphqlconfig.yml node_modules amplify src/graphql/dist src/graphql/node_modules
@clodal
clodal / deploy-private-npm-to-vercel.md
Last active April 26, 2020 15:22
Deploy Private NPM Module to Vercel
@clodal
clodal / git_config.md
Last active September 10, 2019 06:58
Manage git config and identity

Bash commands for managing git config

List global level git identity

git config --global -l

Set global level git identity

git config --global user.name ""
@clodal
clodal / aws_rds_pg_dump_steps.md
Last active September 12, 2019 05:35
Dumping and Restoring PG dump from AWS

How to get dump file from prod into local?

Method 1: pg_dump

  1. Retrieve database dump from production pg_dump --host=<HOST> --dbname=<DBNAME> --username=<USERNAME> > <FILE NAME>

Example: pg_dump --host=foo.2j3klh13kj1237.us-west-1.rds.amazonaws.com --dbname=mydb_dev --username=user &gt; prod_20190227

@clodal
clodal / my-new-mac-user-pref.md
Last active February 3, 2021 05:36
Setup new macos user

Install brew

Fix error when installing brew

sudo chown -R `whoami` /usr/local
cd /usr/local
git reset --hard origin/master

Install zsh

  1. Run curl to install
  2. Go to ~/.zshrc and ensure that the PATH export in the first line is not commented out