Skip to content

Instantly share code, notes, and snippets.

View changx03's full-sized avatar
🏠
Working from home

Luke Chang changx03

🏠
Working from home
  • The University of Auckland
  • Auckland
  • 08:29 (UTC +12:00)
View GitHub Profile
@changx03
changx03 / Install_OpenCV4_CUDA10.md
Created January 25, 2021 04:30 — forked from raulqf/Install_OpenCV4_CUDA11_CUDNN8.md
How to install OpenCV 4.2 with CUDA 10.0 in Ubuntu 18.04

How to install OpenCV 4.2.0 with CUDA 10.0 in Ubuntu distro 18.04

First of all install update and upgrade your system:

    $ sudo apt update
    $ sudo apt upgrade

Then, install required libraries:

@changx03
changx03 / deployUser.md
Created May 17, 2019 16:56 — forked from learncodeacademy/deployUser.md
Adding a deploy user in Linux

(wherever it says url.com, use your server's domain or IP)

Login to new server as root, then add a deploy user

sudo useradd --create-home -s /bin/bash deploy
sudo adduser deploy sudo
sudo passwd deploy

And Update the new password

@changx03
changx03 / gist:5f281ffa1f598e42e7cb1605b0bd7807
Created May 17, 2019 13:41 — forked from learncodeacademy/gist:5f84705f2229f14d758d
Getting Started with Vagrant, SSH & Linux Server Administration
@changx03
changx03 / cluster.md
Created May 17, 2019 13:37 — forked from learncodeacademy/cluster.md
Node Cluster - Enhance your node app by using all the cores of your processor.

Here's all you have to do to add clustering to your node.js application.

  • save this code as cluster.js, and run cluster.js instead of server.js (or /bin/www, or whatever it's called for your project)
  • the only line you'll need to change is the last line - it needs to point to the location of your server.js file
var cluster = require('cluster');

if (cluster.isMaster) {
  // Count the machine's CPUs
 var cpuCount = require('os').cpus().length;
@changx03
changx03 / gist:ad4d34b2b64b85d27ff6068c39337199
Created May 17, 2019 13:37 — forked from learncodeacademy/gist:ebba574fc3f438c851ae
Nginx Node Frontend / Load Balancer / Static Assets Caching
upstream project {
server 22.22.22.2:3000;
server 22.22.22.3:3000;
server 22.22.22.5:3000;
}
server {
listen 80;
location / {
@changx03
changx03 / node-deploy-as-upstart-service.md
Created May 17, 2019 13:19 — forked from learncodeacademy/node-deploy-as-upstart-service.md
Deploy Node.js app on Ubuntu as Upstart Service - instead of using Forever

Deploying a node app with Forever is great...until your server restarts unexpectedly. Then your app stops running and you have to re-deploy.

To get around this, we're going to run our node app as an Upstart service. Upstart services are great, because, once started, the system auto-restarts them if they fail, or if the server restarts.

###Step 1: Create a service for your node app

  • ssh in as root ssh root@youripaddress
  • Create a node-app.conf file in /etc/init
    IMPORTANT: whatever filename you pick is what you will use to start|stop|restart your service i.e. service node-app start
@changx03
changx03 / flightplan-deploy.md
Created May 17, 2019 13:18 — forked from learncodeacademy/flightplan-deploy.md
Deploy Node.js Apps with Flightplan

##Setup your server (this would ideally be done with automated provisioning)

  • add a deploy user with password-less ssh see this gist
  • install forever npm install -g forever

##Install flightplan

  • npm install -g flightplan
  • in your project folder npm install flightplan --save-dev
  • create a flightplan.js file