Go to Sublime Text 2 > Preferences > Key Bindings - User and add this JSON to the file:
[
{ "keys": ["super+shift+l"],
"command": "insert_snippet",
"args": {
"contents": "console.log(${1:}$SELECTION);${0}"
}
}| # Prompt (Debian) | |
| source /usr/local/bin/git-completion.sh | |
| # Prompt (OS X + homebrew) | |
| source /usr/local/etc/bash_completion.d/git-completion.bash | |
| PS1="\[\033[31;38m\]\w\[\033[1;31m\]\$(__git_ps1)\[\033[00m\] " | |
| export GIT_PS1_SHOWDIRTYSTATE=1 |
| var mongoose = require('mongoose'); | |
| var db = mongoose.connect("mongodb://localhost/testdb"); | |
| var reconnTimer = null; | |
| function tryReconnect() { | |
| reconnTimer = null; | |
| console.log("try to connect: %d", mongoose.connection.readyState); | |
| db = mongoose.connect("mongodb://localhost/testdb"); | |
| } |
| <!doctype html> | |
| <html> | |
| <head> | |
| <!-- Encoding --> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
| <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame --> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta> | |
| var express = require('express'); | |
| var app = express.createServer(); | |
| app.set('view engine', 'jade'); | |
| app.set('port', parseInt(process.env.PORT || 5000, 10)); | |
| app.get('/', function(req, res) { | |
| res.render('index'); |
| var cluster = require('cluster'); | |
| var http = require('http'); | |
| var numCPUs = require('os').cpus().length; | |
| if (cluster.isMaster) { | |
| // Fork workers. | |
| for (var i = 0; i < numCPUs; i++) { | |
| cluster.fork(); | |
| } |
| # /etc/monit/monitrc (excerpt) | |
| check process node-app with pidfile /var/run/node-app.pid | |
| start program = "/sbin/start node-app" with timeout 5 seconds | |
| stop program = "/sbin/stop node-app" | |
| if failed port 3000 protocol HTTP | |
| request / | |
| with timeout 3 seconds | |
| then restart | |
| if cpu > 80% for 10 cycles then restart |
| <!-- copy this to YOUR_THEME.tmTheme--> | |
| <dict> | |
| <key>name</key> | |
| <string>diff: deleted</string> | |
| <key>scope</key> | |
| <string>markup.deleted</string> | |
| <key>settings</key> | |
| <dict> | |
| <key>background</key> | |
| <string>#EAE3CA</string> |
Go to Sublime Text 2 > Preferences > Key Bindings - User and add this JSON to the file:
[
{ "keys": ["super+shift+l"],
"command": "insert_snippet",
"args": {
"contents": "console.log(${1:}$SELECTION);${0}"
}
}Node.js is just JavaScript running on the server side. That's it. That's all there is to it.