Node.js Start script or run command and handoff to OS (no waiting)

Sometimes you want to run something in the OS from your node code but you do not want to follow it or have a callback posted on your stack. The default for child_process spawning is to hold on to a handle and park a callback on the stack. however there is an option which is…

hex2bin in node.js

Basically it’s all over-engineered and does not work well. responses are out of alignment and though text-wise they are the same bit wise everything is all over the place : curl http://phpimpl.domain.com/testhex.php | xxd 00000000: de56 a735 4739 c01d f2dc e14b ba30 8af0 .Q.%G9…..;.0.. curl http://nodejs.domain.com/ | xxd 00000000: c39e 56c2 a725 4739 c380 c3ad…

Install node.js on Centos 6.8

Epel’s yum install does not cut it anymore at time of writing installing node.js causes a mass of 404s and file not found.   current best approach : Enterprise Linux and Fedora Including Red Hat® Enterprise Linux® / RHEL, CentOS and Fedora. Node.js is available from the NodeSource Enterprise Linux and Fedora binary distributions repository….

package.json sample

This is the basic structure for a node.js package file { "name": "Express-Basic", "description": "Demonstrating Express", "version": "0.0.1", "private": true, "dependencies": { "express": "3.x" } } nJoy 😉

Node.js and Express with HTTPS

Quoting from the doco + some missing stuff: var express = require('express'); var https = require('https'); var http = require('http'); var app = express(); var fs = require('fs'); var options = { key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem') }; http.createServer(app).listen(80); https.createServer(options, app).listen(443); nJoy 😉

Node.js handling mysql disconnects.

You may lose the connection to a MySQL server due to network problems, the server timing you out, the server being restarted, or crashing. All of these events are considered fatal errors, and will have the err.code = ‘PROTOCOL_CONNECTION_LOST’. See the Error Handling section for more information. A good way to handle such unexpected disconnects is shown below:…