+ R1: A good test suite increases confidence that code changes won't cause
+ unexpected side effects without being noticed.
+ R2: Tests reduce the cost of structural changes in later stages of a project
+ because fewer bugs sneak into a system unnoticed.
- R3: Brittle tests can increase the cost of refactoring if they focus on | <!DOCTYPE html> | |
| <html ng-app="App"> | |
| <head> | |
| <script src="https://code.jquery.com/jquery.min.js"></script> | |
| <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> | |
| <script src="https://rawgit.com/angular/bower-angular/master/angular.min.js"></script> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> |
| var gulp = require( 'gulp' ), | |
| plumber = require( 'gulp-plumber' ), | |
| watch = require( 'gulp-watch' ), | |
| livereload = require( 'gulp-livereload' ), | |
| minifycss = require( 'gulp-minify-css' ), | |
| jshint = require( 'gulp-jshint' ), | |
| stylish = require( 'jshint-stylish' ), | |
| uglify = require( 'gulp-uglify' ), | |
| rename = require( 'gulp-rename' ), | |
| notify = require( 'gulp-notify' ), |
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
##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
Whether you use 2 spaces or 4 spaces, there are a few simple things that can make your node.js code easier to read. We've been using them in all the hapi modules for over 4 years now to great results. This list is by no means complete but it highlights the most useful elements that will give you immediate value in reducing bugs.
JavaScript makes is harder than most languages to know where variables are coming from. Variables assigned required modules are particularly important because they represent a singleton object shared with the entire application. There are also globals and module globals, along with function variables and arguments.
Traditionally, variables starting with an uppercase letter represent a class that must be instantiated using new. This was an important semantic in the early days of JavaScript but at this point, if you don't know Date requires new Date() you are probably very new. We have adopted CamelCase variable names for all module global variables which a
| @reboot /usr/bin/forever start -c /usr/bin/node /home/root/smart-monitoring-tr-bbb/index.js |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta name="description" content="Binding is a core feature of AngularJS. It provides a simple mechanism for integrating your HTML with your data via {{bracketed expressions}}. In this video, John covers the basics of binding to get you started." /> | |
| <script src="http://code.jquery.com/jquery.min.js"></script> | |
| <link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" /> | |
| <script src="http://getbootstrap.com/dist/js/bootstrap.js"></script> | |
| <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script> | |
| <meta charset="utf-8"> | |
| <title>JS Bin</title> |
| #hours, #minutes, #tmSeparator { | |
| font-size: 2.5em; | |
| } | |
| #tmSeparator { | |
| color: grey; | |
| } | |
| #ampm { | |
| font-size: 1.5em; | |
| } |
| # file: /etc/ntp.conf | |
| # This is the most basic ntp configuration file | |
| # The driftfile must remain in a place specific to this | |
| # machine - it records the machine specific clock error | |
| driftfile /etc/ntp.drift | |
| logfile /var/log/ntpd.log | |
| # NTP Servers for Mexico |