(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 deployAnd Update the new password
(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 deployAnd Update the new password
###SSH into a remote machine###
ssh user@mydomain.com
#or by ip address
ssh user@192.168.1.1
exit: exit
###Install Something###
#If it's a new server, update apt-get first thing
###Prerequesites
Install flightplan globally
npm install -g flightplan
Install flightplan in your project folder
| //events - a super-basic Javascript (publish subscribe) pattern | |
| var events = { | |
| events: {}, | |
| on: function (eventName, fn) { | |
| this.events[eventName] = this.events[eventName] || []; | |
| this.events[eventName].push(fn); | |
| }, | |
| off: function(eventName, fn) { | |
| if (this.events[eventName]) { |
Here's all you have to do to add clustering to your node.js application.
cluster.js, and run cluster.js instead of server.js (or /bin/www, or whatever it's called for your project)server.js filevar cluster = require('cluster');
if (cluster.isMaster) {
// Count the machine's CPUs
var cpuCount = require('os').cpus().length;| upstream project { | |
| server 22.22.22.2:3000; | |
| server 22.22.22.3:3000; | |
| server 22.22.22.5:3000; | |
| } | |
| server { | |
| listen 80; | |
| location / { |
| var debug = process.env.NODE_ENV !== "production"; | |
| var webpack = require('webpack'); | |
| module.exports = { | |
| context: __dirname, | |
| devtool: debug ? "inline-sourcemap" : null, | |
| entry: "./js/scripts.js", | |
| output: { | |
| path: __dirname + "/js", | |
| filename: "scripts.min.js" |
###Let's install Vagrant###
###Select a Vagrant Box from https://vagrantcloud.com###
#add it to your list of boxes
vagrant box add hashicorp/precise32
#create a new folder for your project & init vagrant
| import * as tf from "@tensorflow/tfjs" | |
| import "@tensorflow/tfjs-node" | |
| import iris from "./iris.json" | |
| import irisTesting from "./iris-testing.json" | |
| // convert/setup our data | |
| const trainingData = tf.tensor2d(iris.map(item => [ | |
| item.sepal_length, item.sepal_width, item.petal_length, item.petal_width, | |
| ])) | |
| const outputData = tf.tensor2d(iris.map(item => [ |
| const axios = require("axios"); | |
| const key = "AIzaSyB9e-dHIvdxxrbmorjYHWipwBKq7LJBhNk" | |
| function getComments(pageToken, allItems = {}) { | |
| const params = { | |
| key, | |
| videoId: "a4haLJdDRmc", | |
| part: "snippet", | |
| maxResults: 100, | |
| pageToken, |