Skip to content

Instantly share code, notes, and snippets.

View bangsite's full-sized avatar

Bang bangsite

  • VN
  • 23:00 (UTC +07:00)
View GitHub Profile
@bangsite
bangsite / 01nginx-tls-sni.md
Created March 14, 2024 10:30 — forked from kekru/01nginx-tls-sni.md
nginx TLS SNI routing, based on subdomain pattern

Nginx TLS SNI routing, based on subdomain pattern

Nginx can be configured to route to a backend, based on the server's domain name, which is included in the SSL/TLS handshake (Server Name Indication, SNI).
This works for http upstream servers, but also for other protocols, that can be secured with TLS.

prerequisites

  • at least nginx 1.15.9 to use variables in ssl_certificate and ssl_certificate_key.
  • check nginx -V for the following:
    ...
    TLS SNI support enabled
@bangsite
bangsite / node_nginx_ssl.md
Created March 13, 2024 10:30 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@bangsite
bangsite / nuxt3-pm2-build-deploy-on-arm.yaml
Created February 20, 2024 10:16 — forked from L422Y/nuxt3-pm2-build-deploy-on-arm.yaml
Github Actions Workflow to build and deploy Nuxt 3 SSR with PM2, as well as node-canvas, on ARM64, utilizing cache for `pnpm` and `apt` including the build for `node-canvas`
name: "Build and deploy Nuxt SSR with PM2"
on: [push]
jobs:
build:
name: "Build Nuxt Application"
runs-on: [self-hosted, ARM64] # you can also use buildjet.com
environment:
name: "Production"
steps:
- uses: actions/checkout@v3
@bangsite
bangsite / nodejs-cicd-github-actions.md
Created January 4, 2024 17:04 — forked from danielwetan/nodejs-cicd-github-actions.md
Deploy Node.js to VPS using Github Actions

Deploy Node.js to VPS using Github Actions

Steps to deploy Node.js to VPS using PM2 and Github Actions

1. Clone repo to VPS folder

@bangsite
bangsite / simple-pagination.js
Created November 24, 2023 09:00 — forked from kottenator/simple-pagination.js
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@bangsite
bangsite / deploy_node_do.md
Created October 30, 2023 05:38 — forked from carlssonk/deploy_node_do.md
Deploy node.js app to DigitalOcean

Deploy Node.js Application to DigitalOcean

This step by step tutorial will show you how to set up a Node.js server with MongoDB to DigitalOcean using PM2, NGINX as reverse proxy and a SSL from LetsEncrypt. We will also add a custom domain name.

Prerequisites

Create Droplet & Generate SSH Key

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@bangsite
bangsite / large-scale-vue.md
Created December 16, 2022 08:00
Large Scale Vue Application Structure

Large Scale Vue Application Structure

Application Structure LIFT Principle

  • Locating our code is easy
  • Identify code at a glance
  • Flat structure as long as we can
  • Try to stay DRY (Don’t Repeat Yourself) or T-DRY

"Folders-by-Feature" Structure

@bangsite
bangsite / Localhost Wordpress Permissions
Created June 16, 2020 03:49 — forked from shawnrgrimes/Localhost Wordpress Permissions
Enable updating WordPress in a local environment on OS X (Updates, Themes and Plugins)
On Mac OS X (Leopard+), the Apache HTTP Server runs under the user account, _www which belongs to the group _www. To allow WordPress to configure wp-config.php during installation, update files during upgrades, and update the .htaccess file for pretty permalinks, give the server write permission on the files.
One way to do this is to change the owner of the wordpress directory and its contents to _www. Keep the group as staff, a group to which your user account belongs and give write permissions to the group.
$ cd /<wherever>/Sites/<thesite>
$ sudo chown -R _www wordpress
$ sudo chmod -R g+w wordpress
This way, the WordPress directories have a permission level of 775 and files have a permission level of 664. No file nor directory is world-writeable.
@bangsite
bangsite / cloudSettings
Created April 27, 2020 16:37
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-04-27T16:37:43.339Z","extensionVersion":"v3.4.3"}