Skip to content

Instantly share code, notes, and snippets.

var connectionDetector = require('connection-detector')
connectionDetector.analyze((err, data) => {
// data is the output
})
- If you aren't a programmer yet then it is probably easier to start by reading JavaScript for Cats. (http://jsforcats.com/)
- https://github.com/maxogden/art-of-node
@Arkotek
Arkotek / net_fs.js
Created May 11, 2016 12:54
Send and receive file over TCP socket node.js
var debug = require('debug')('filesmanager');
var fs = require('fs');
var defaults = require('../constants.js');
var net = require('net');
var chalk = require('chalk');
var NetFS = function() {
this.port = defaults.DSS_FS_PORT;
this.dss_running = false;
};
@Arkotek
Arkotek / starttls.js
Created May 9, 2016 09:50 — forked from TooTallNate/starttls.js
Upgrade a regular `net.Stream` connection to a secure `tls` connection.
// Target API:
//
// var s = require('net').createStream(25, 'smtp.example.com');
// s.on('connect', function() {
// require('starttls')(s, options, function() {
// if (!s.authorized) {
// s.destroy();
// return;
// }
//

How you can help reduce node_modules bloat

This recent reddit thread reveals discontent among the web development community about the sheer volume of stuff in a typical node_modules dir. 140MB in this case!

Is it a design flaw in npm?

Opinions in the thread varied from "I'm surprised npm even works" to "everything is fine". I'm not going to offer an opinion, just these two observations:

  1. node_modules dirs typically do contain lots of stuff that doesn't need to be there.
  2. The latest version mitigates overall size by flattening the dependency tree, but some of the bloat is beyond npm's control.
var Toto = function() {
};
Toto.prototype.test = function() {
};
var wrappedClass = new Proxy(Toto, {
get : function(o, method_name) {
console.log(o, method_name);
return function() {
[PM2] PM2 stopped
>> RELOAD LOGS (ENTIRE EXISTS)
[PM2] Spawning PM2 daemon
2016-04-27 10:21:00: [PM2][WORKER] Started with refreshing interval: 30000
2016-04-27 10:21:00: [[[[ PM2/God daemon launched ]]]]
2016-04-27 10:21:00: BUS system [READY] on port /home/travis/.pm2/pub.sock
2016-04-27 10:21:00: RPC interface [READY] on port /home/travis/.pm2/rpc.sock
[PM2] PM2 Successfully daemonized
[PM2] Starting throw-later.js in fork_mode (1 instance)
2016-04-27 10:21:00: Starting execution sequence in -fork mode- for app name:throw-later id:0
2016-04-02 11:51:18: Buffer size 6388346
2016-04-02 11:51:19: Buffer size 6394211
2016-04-02 11:51:20: Buffer size 6400076
2016-04-02 11:51:21: Buffer size 6405909
2016-04-02 11:51:21: [PUSH] Reconnecting
2016-04-02 11:51:21: [PUSH] Client got error getaddrinfo EAI_AGAIN noe2.keymetrics.io:80
2016-04-02 11:51:21: [PUSH] Reconnecting
2016-04-02 11:51:21: [PUSH] Client got error getaddrinfo EAI_AGAIN noe2.keymetrics.io:80
2016-04-02 11:51:22: [PUSH] Reconnecting
2016-04-02 11:51:22: [PUSH] Client got error getaddrinfo EAI_AGAIN noe2.keymetrics.io:80
2016-04-02 11:27:10: Error: getaddrinfo EAI_AGAIN root.keymetrics.io:443
2016-04-02 11:27:10: Buffer size 6227403
2016-04-02 11:27:11: Buffer size 6233236
2016-04-02 11:27:12: Buffer size 6239069
2016-04-02 11:27:13: Buffer size 6244902
2016-04-02 11:27:14: Buffer size 6250735
2016-04-02 11:27:15: Buffer size 6256568
2016-04-02 11:27:16: Buffer size 6262401
2016-04-02 11:27:17: Buffer size 6268234
2016-04-02 11:27:18: Buffer size 6274067