Skip to content

Instantly share code, notes, and snippets.

View nmquaan's full-sized avatar
🎯
Focusing

Luis Nguyen nmquaan

🎯
Focusing
  • HCMC
View GitHub Profile
@nmquaan
nmquaan / gist.md
Created June 30, 2022 19:01 — forked from ArcRanges/gist.md
aws-ec2-nextjs

Instructions to properly set up a production-ready NextJS App with AWS

This is a summary of how to start your own NextJS app, create the repo on Github, upload later in an AWS EC2 Instance and automate the process with AWS Codebuild, CodeDeploy, & CodePipeline.

After following these instructions you should be able to:

  • Create a NextJS App
  • Create an AWS EC2 instance
  • Be able to SSH to an EC2 instance
  • Prepare the instance as a Node environment
  • Configure Nginx service for proper routing
  • Configure domain and add SSL
@nmquaan
nmquaan / JobProcessor.ts
Created October 23, 2021 11:44 — forked from Eunovo/JobProcessor.ts
Code describing a system to handle CPU-intensive jobs on NodeJS servers
class JobProcessor {
private assignedJobs = new Map<String, any>();
private queue = new Queue<any>();
private nWorkers = 5;
async loadOutstandingJobs() {
// load 'pending' or 'processing' jobs from DB
const jobs = await services.Job
.findMany({
$or: [
@nmquaan
nmquaan / composing-software.md
Created January 11, 2021 03:59 — forked from Geoff-Ford/composing-software.md
Eric Elliott's Composing Software Series

Eric Elliott's "Composing Software" Series

A collection of links to the excellent "Composing Software" series of medium stories by Eric Elliott.

Edit: I see that each post in the series now has index, previous and next links. However, they don't follow a linear flow through all the articles with some pointing back to previous posts effectively locking you in a loop.

@nmquaan
nmquaan / [Docker Tips & Trick] List of Docker Container Commands you should know.md
Created November 27, 2020 11:02
[Docker Tips & Trick] List of Docker Container Commands you should know

Start container

  • To start/stop a docker container, you can do that using the command,
docker container start [OPTIONS]  <Container id>

Noted: you can specify the name or you can just specify the first two digits of the container id.

Stop container

  • To stop the container, you need to specify the stop in the docker container command.
@nmquaan
nmquaan / Docker on Ubuntu.md
Last active November 12, 2020 10:10
Install docker on Ubuntu

Docker CE on Ubuntu To install Docker Engine - Community, you need the 64-bit version of one of these Ubuntu versions:

  • Focal 20.04 (LTS)
  • Disco 19.04
  • Cosmic 18.10
  • Bionic 18.04 (LTS)
  • Xenial 16.04 (LTS)

That’s all you need. There aren’t many complex requirements.

@nmquaan
nmquaan / Writing ES6 in NodeJS using Babel.md
Last active December 16, 2020 10:48
Writing ES6 in NodeJS using Babel

Setting up Babel and nodemon with lastest version

Inital set-up

Set up project:

mkdir project
cd project
mkdir src
@nmquaan
nmquaan / regexCheatsheet.js
Last active September 25, 2020 04:40 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@nmquaan
nmquaan / dynamic-redux-sagas.md
Created October 4, 2019 06:54 — forked from mpolci/dynamic-redux-sagas.md
Helper function creating a dynamic saga for code splitting with redux-saga

Helper function

This function create a saga that runs the sagas in the startingSagas array and takes the actions with type indicated by changeActionType to replace the running sagas. The replacing actions must have a field sagas cointaining the array with the new sagas.

function createDynamicSaga (changeActionType, startingSagas) {
  function* _start (sagas) {
    try {
      yield sagas
server {
root /var/www/project/src/public/;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name domain.vn;
access_log /var/log/nginx/porject.access.log;
error_log /var/log/nginx/porject.error.log;
location / {