Tuesday, November 14, 2017

Comparison Tool

Comparison Tool

Choose the text file you wish to examine for unique values:




 

Choose the text file you are comparing the first file to:


The values that appear in the first file that do not appear in the second are:

Friday, January 6, 2017

What makes us human

We are looking at some big changes in the near future. Once again, machines are replacing people en masse and we just can't quite see what the future holds.

You don't know what the future holds so don't put too much stock in predictions. Rather, develop a deep love of learning and of the fundamentals, and develop an insatiable urge to push at the outer edges every chance you get. Those are two things machines will never know to do, no matter how complex they get.  

For example, here is some pretty good analysis I read the other day:

"Software development is growing fast. Learning to code is easier than ever, and soon enough we will be in a survival-of-the-fittest environment. But the developer who survives is not going to be the developer who first learned about the cool new framework. It's going to be the developer who asked himself what's new about it and what's different this time. If you want to stay up to date with technology stacks, then stop worrying so much about being up to date and start hacking."
- https://techbeacon.com/what-full-stack-developer-should-mean

Be fearless. Keep learning. Keep hacking.

Monday, January 2, 2017

Trying to explain and understand "A simple chat server using Socket.IO, Express, and Async" - PART I

  //
  // # SimpleServer
  //
  // A simple chat server using Socket.IO, Express, and Async.
  //
var http = require('http');  //OK, to use Node's HTTP server and client, one must require('http') from the get-go
var path = require('path');  // OK, there is a lot that goes into using and manipulating file and directory paths; this provides a set of utilities to do that

var async = require('async'); // OK, this provides a whole host of powerful functions for working with asynchronous JavaScript
var socketio = require('socket.io'); // OK, WebSockets facilitates ongoing conversation between browser and web server without being solicited by the client,  while keeping the connection open.

var express = require('express');  // OK, just a bunch of additional web application tools inside of Node

  //
  // ## SimpleServer `SimpleServer(obj)`
  //
  // Creates a new instance of SimpleServer with the following options:
  //  * `port` - The HTTP port to listen on. If `process.env.PORT` is set, _it overrides this value_.
  //
var router = express();
      // OK, first of all, "routing." What is routing in node? Here is the basic format: app.method(path, handler) (see https://expressjs.com/en/starter/basic-routing.html )
        //"app" is an instance of express (in this example, the app is called 'router' since 'var router = express()')
        //"method" is one of several HTTP request methods (get, post, put, delete, etc)
        // "path" is a path on the server to a particular resource
        // "handler" is whatever function is to be carried out when Node finds a match for the route
      // SO, what's going on here is you are saying the "app" part of 'app.method(path, handler)' is going to be called 'router'

var server = http.createServer(router); // OK, this calls http.Server() internally and returns the resulting instance

var io = socketio.listen(server); // OK, this marks the socket referred to as a passive socket that will be used to accept incoming connection requests  

router.use(express.static(path.resolve(__dirname, 'client')));  // OK you are passing the name of the directory that contains the static assets to the express.static middleware function


var messages = []; // OK, this is just creating an array called messages
var sockets = []; // OK, this is just creating an array called sockets

io.on('connection', function (socket) {
    messages.forEach(function (data) {
      socket.emit('message', data);
    });

    sockets.push(socket);

    socket.on('disconnect', function () {
      sockets.splice(sockets.indexOf(socket), 1);
      updateRoster();
    });

    socket.on('message', function (msg) {
      var text = String(msg || '');

      if (!text)
        return;

      socket.get('name', function (err, name) {
        var data = {
          name: name,
          text: text
        };

        broadcast('message', data);
        messages.push(data);
      });
    });

    socket.on('identify', function (name) {
      socket.set('name', String(name || 'Anonymous'), function (err) {
        updateRoster();
      });
    });
  });

function updateRoster() {
  async.map(
    sockets,
    function (socket, callback) {
      socket.get('name', callback);
    },
    function (err, names) {
      broadcast('roster', names);
    }
  );
}

function broadcast(event, data) {
  sockets.forEach(function (socket) {
    socket.emit(event, data);
  });
}

server.listen(process.env.PORT || 3000, process.env.IP || "0.0.0.0", function(){
  var addr = server.address();
  console.log("Chat server listening at", addr.address + ":" + addr.port);
});