Skip to content

Instantly share code, notes, and snippets.

View 211211's full-sized avatar

Quan Nguyen 211211

View GitHub Profile
@211211
211211 / postgres.md
Created February 1, 2023 06:30 — forked from phortuin/postgres.md
Set up postgres + database on MacOS (M1)

Based on this blogpost.

Install with Homebrew:

$ brew install postgresql@14

(The version number 14 needs to be explicitly stated. The @ mark designates a version number is specified. If you need an older version of postgres, use postgresql@13, for example.)

@211211
211211 / nextjs-deploy.md
Created August 15, 2022 05:35 — forked from jjcodes78/nextjs-deploy.md
Deploying NEXTJS site with nginx + pm2

How to setup next.js app on nginx with letsencrypt

next.js, nginx, reverse-proxy, ssl

1. Install nginx and letsencrypt

$ sudo apt-get update
$ sudo apt-get install nginx letsencrypt

Also enable nginx in ufw

@211211
211211 / S3-Static-Sites.md
Created June 18, 2022 14:01 — forked from bradwestfall/S3-Static-Sites.md
Use S3 and CloudFront to host Static Single Page Apps (SPAs) with HTTPs and www-redirects. Also covers deployments.

S3 Static Sites

What this will cover

  • Host a static website at S3
  • Redirect www.website.com to website.com
  • Website can be an SPA (requiring all requests to return index.html)
  • Free AWS SSL certs
  • Deployment with CDN invalidation

Resources

@211211
211211 / clean_code.md
Created May 10, 2022 15:41 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@211211
211211 / elasticsearch-scroll.js
Created February 22, 2022 18:12 — forked from johnnybui/elasticsearch-scroll.js
Get all documents from Elasticsearch index by scroll method
const elasticsearch = require('elasticsearch');
const esClient = new elasticsearch.Client({
host: 'YOUR ELASTICSEARCH SERVER'
});
/**
* Get all documents of an Elasticsearch index by scroll method
* @param {string} index Index to get documents
* @param {Object} query Querying object
@211211
211211 / app.js
Created February 22, 2022 18:12 — forked from johnnybui/app.js
Node.JS - Import Data From Cloud Firestore Into Elasticsearch
const admin = require('firebase-admin');
const elasticsearch = require('elasticsearch');
// Config before running
const CONFIG = {
limit: 1000, // reduce if got Deadline exceeded error
index: 'stock',
type: 'doc',
dev: {
serviceAccountJson: './devServiceAccount.json',
@211211
211211 / letsencrypt_2020.md
Created September 16, 2020 18:33 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@211211
211211 / App.js
Created October 27, 2017 08:00 — forked from fdidron/App.js
React Router v4 Auth
//Usage
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import Route from './AuthRoute';
import Login from './Login';
import Private from './Private';
export default () =>
<Router>