Wednesday, January 10, 2018

Free Online Image to Text Converter

Today I needed to convert a picture of a spreadsheet to an actual spreadsheet.
I used and it worked great!
They support output in Text, Microsoft Word, and Microsoft Excel.
I selected 'Text' for the OCR, then imported the text into Excel. 
Directly importing an Excel spreadsheet from the web is a little scary,

Proxy Blocking Abot Spider on Windows

I like Abot Web Crawler. It's written in C# and easy to use. Abot will crawl a website so you can get a site map for analysis. Our company's proxy blocks Abot from working. The solution is simple for windows, just set the HTTP_PROXY environmental variable like this,
set HTTP_PROXY=http://proxy_userid:proxy_password@proxy_addr:proxy_port
For example:
Also also need to set the proxy for HTTPS_PROXY. Then you can run the spider:
cd c:\Git\Abot\abot-master\Abot.Demo\bin\Debug
Abot.Demo.exe > cnn.txt

Friday, December 08, 2017

Social Security Basics

I recently attended a few workshops sponsored by GM and hosted by Fidelity.  Here's what I learned:

Important Terms:
FRA - Full Retirement Age - 66 or 67, depending on your birthday.

AIME - Average Indexed Monthly Earnings - This is the average monthly amount you earned in your highest-earning 35 years.  It is indexed for inflation.  AIME is used to calculate PIA.  If you don't have 35 years of earnings, zeros will be averaged in.

PIA - Primary Insurance Amount - amount of Social Security payments you will receive at full retirement age (FRA).

Estimating your benefits - your PIA is based on the average of 35 highest earning years, so try to work 35 years if possible.  Details are  here.

If you were a homemaker and didn't work many years, you can claim 50% of your spouse's PIA if that is more than yours.  It does not affect your spouse's amount.

When to claim your SS benefits?
If you wait until FRA, you get 100%.  If you claim earlier you get less, claim later you get more, until age 70 when the amount does not go up.  There's no magic to claiming at your FRA.  You can claim earlier or later. It's not "right" to claim at FRA, it's just one option.

From for birthdate in 1958
Age% of PIA
62 70
63 80
64 87
65 93
66 100
67 108
68 116
69 124
70 127

For each year you wait you get about 8% increase in payments.
Better to wait if you have other resources, but it depends on your expected life expectancy.
The break even age is 81 or 82.  Will you be alive then?  If not, take SS early.

The average amount of SS paid is $1,300 per month, or $15,600 per year.
$2,788 is maximum you can receive per month.  So if you paid in buckets of money during your career you may reach this level at age 64, so you might as well start taking then, because it won't hurt you.

Survivor benefits can start when the survivor is 60 yrs old.

Working before FRA may reduce your PIA.  Details
here.  Some states tax SS income.

Will SS go bankrupt?  In the year 2034 trust fund will go dry, but SS can still fund 77% of obligations from taxes, we just won't have the trust fund.

One scary tidbit was that health care costs for a couple over 65, with Medicare, was $902 a month.

Friday, December 01, 2017

Git Access Error on Windows 7: unable to access ... Received HTTP code 407 from proxy after CONNECT

Occasionally I get this error connecting to Git a github:

$ git pull
fatal: unable to access '': Received HTTP code 407 from proxy after CONNECT

The proxy is complaining that the password is out of date by giving us a  407 error,  which is an authentication error.  Then I remember I just changed my system password.

The solution is easy, just tell Git your new password:

git config --global http.proxy
git config --global https.proxy

Friday, November 24, 2017

Saving Money by Moving to an OOma phone

Being the frugal person I am (having the ginger and Scottish genes), I found it hard to pay $20 a month to my cable provider for an internet land line.

(I know, I know, the 70s called and wants their phone back)

I replaced my internet provider's $20/month phone with an $80 one time purchase Ooma phone.

Transferring our old number to the new Ooma phone cost a one time fee of $40.
The Ooma phone has to charge taxes on their service of $3-$4 a month.
At a one-time charge of $120 with the monthly tax , our family should start saving money in only seven months.
We should be saving $17 a month after that.

And one more thing:  Removing your internet phone from your internet provider makes switching to lower cost internet providers easier.  No messy phone number to switch every time you go with a lower cost provider.

Wednesday, November 22, 2017

JavaScript Notes

Objects and Prototypes

Notes from Jim Cooper's excellent PluraSight course on JavaScript Objects and Prototypes and Kyle Simpson's Advanced JavaScript class, and my random scribblings.

Use to play with JavaScript.

  1. Six Ways to Create Objects:
    1. Creating objects with Object Literals
      'use strict';
      var cat = {name: 'Fluffy', color: 'White'}
      console.log(; //Fluffy
      cat.age = 3; //we can create properties on the fly
      cat.speak = function() {console.log("Meeooow") }//add functions directly
    2. Creating objects with constructors:

      Calling "new" makes the function a constructor and does four magic things:

      1. Creates new object
      2. Sets the 'this' to its context
      3. Calls the function
      4. Returns a pointer to the new object

      Here's Jim's example:

      function Cat(name, color) { = name
        this.color = color
      var cat = new Cat('Fluffy','White');
      This writes:
      [object Object] {
        color: "White",
        name: "Fluffy"
    3. Creating objects with Object.create syntax Object.create()

      The "create()" method exists at the top level object cleverly named, "Object".

      Object.create(proto[, propertiesObject])

      "Object.create()" creates a new object and sets its prototype link to be the first parameter passed in. It also copies the properties from propertiesObject to the new object.

      The "new" keyword is just syntactic sugar, we could do the previous example like this:

      var cat = Object.create(Object.prototype,
      name: {
      value: 'Fluffy',
      color: {
      value: 'White',
      o = {};
      //is shorthand for 
      o = Object.create(Object.prototype);
    4. A Fallback Polyfill for Older Browsers

      Older browsers may not have the "create()" method, so you can use a polyfill from

      if (typeof Object.create !== "function") {
          Object.create = function (proto, propertiesObject) {
              if (!(proto === null || typeof proto === "object" || typeof proto === "function")) {
                  throw TypeError('Argument must be an object, or null');
              var temp = new Object();
              temp.__proto__ = proto;
              Object.defineProperties(temp, propertiesObject);
              return temp;
    5. Creating objects with the new ECMAScript 6

      ES6 has new built in support for creating classes:

      'use strict';
      class Cat {
         constructor(name, color) {
            this.color = color
         speak() {
  2. Properties
    1. Bracket Notation

      Besides the dot notation, 'this.color = "blue"' you can use the bracket notation. An advantage of the bracket notation is that you can use property names with embedded spaces:

      cat['color'] = "blue";
      cat['Eye Color'] = "green";
    2. Descriptors

      JavaScript properties have 4 descriptors: value, writable, enumerable, and configurable.

      1. Value

        This is simply the actual "value" of the property.

      2. writable

        "writable" is a boolean that determines if the value can be written over.

        var cat = {name: 'Fluffy', color: 'White'}
        console.log(Object.getOwnPropertyDescriptor(cat, 'name')
        Object {
          value: Fluffy
          writable: true
          enumerable: true
          configurable: true

        To set a property of field use defineProperty

        Object.defineProperty(cat, 'name', {writable: false})
        var cat = {
           name: {first: 'Fluffy', last: 'LaBeouf'}, color: 'White'

        To prevent writing of an object:

      3. enumerable

        If "enumerable" set to false, the property will not show up in any list

        Object.defineProperty(cat, 'name', {enumerable: false})
        console.log(JSON.stringify(cat))//will not show enumerable-false items

        How to Loop Over Enumerables:

        for(var propertyName in cat) {
          console.log(propertyName+':'+ cat[propertyName])
      4. configurable

        If configurable is set to true you cannot change enumerable attr or configurable attr, or delete it, but can change writable attr.

        Object.defineProperty(cat, 'name', {configurable: false}
    3. Getters and Setters

      Let's create a new property and add a get() and set() methods.

      var cat = {
         name: {first: 'Fluffy', last: 'LaBeouf'}, color: 'White'
      Object.defineProperty(cat, 'fullName',
      get: function() {
        return + ' ' +
      set: function(value) {
        var nameParts = value.split(' ') = nameParts[0] = nameParts[1]
      console.log(cat.fullName); //"Fluffy LaBeouf"
      cat.fullName = 'Top Cat'; //"Top Cat"
  3. Prototypes and Inheritance
    1. We can add methods to individual objects. Here we create a 'last' method to an object, arr.

      'use strict';
      var arr = ['red','blue','green']
      Object.defineProperty(arr, 'last', {get: function() {
         return this[this.length-1];}});

      But wouldn't it be nice to add a method to all arrays. We can by adding a method to 'Array's prototype which is shared by all the Array objects. If an individual object doesn't contain a function, it looks to its "prototype" to see if it has that function.

      'use strict';
      var arr = ['red','blue','green']
      Object.defineProperty(Array.prototype, 'last', {get: function() {
         return this[this.length-1];}});
      console.log(arr.last); //"green"
      console.log(['sour','sweet','bitter'].last); //"bitter"

      All functions have a built-in property that points to another object called "prototype".

      var myFunc = function() { }
      console.log(myFunc.prototype); //[object Object] { ... }

      Objects do not have a prototype property but they have a __proto__

    2. function Cat(name, color) { = name;
        this.color = color;
      var fluffy = new Cat('Fluffy','White');
      console.log(Cat.prototype);//[object Object] { ... }
      console.log(fluffy.__proto__);//[object Object] { ... }
      console.log(Cat.prototype === fluffy.__proto__);//true
      Cat.prototype.age = 4;

      Important: A function's prototype is the object instance that will become the default prototype for all objects created using this function.

      Jim has a great example of linking two classes, "Animal" and "Cat" into an inheritance chain. It's kinda tedious and error prone. Be very careful. This is why Kyle Simpson prefers OLOO. (more on that later).

      'use strict';
      function Animal(voice) {
        this.voice = voice || 'grunt';
      Animal.prototype.speak = function() {
      function Cat(name, color) {, 'Meow'); = name;
        this.color = color;
      Cat.prototype = Object.create(Animal.prototype);
      Cat.prototype.constructor = Cat;
      var fluffy = new Cat('Fluffy','White');

      This prints:

      [object Object] {
        speak: function () {

      The above code is a little cleaner with the new ES6 "class" structure:

      'use strict'
      class Animal {
        constructor(voice) {
        this.voice = voice || 'grunt'
        speak() {
      class Cat extends Animal {
      constructor(name, color) {
        super('Meow'); = name;
        this.color = color;
      var fluffy = new Cat('Fluffy', 'White');

JavaScript Scope

My notes from Plurasight's Advanced JavaScript by Kyle Simpson. His series of online books is available on github at

A good reference site for JavaScript is the Mozilla Developer Network MDM at

A good place to learn styles of programming JS is

The actual definitive spec is at

  1. Details of Scope

    Scope: where to look for things

    JavaScript is not interpreted. Bash is interpreted. The JS compiler goes through all the code before starting execution. It finds declaration of variables and puts them into appropriate scope slots. Finds "var" and "function"s.

    JS has function scope only (kinda).

    lhs - left hand side (target)

    rhs - right hand side (source)

    "undefined" really means uninitialized

    Kyle has a good way of explaining scope: When executing a function "foo" and encountering a variable "foo", JavaScript asks the question: "Hey, scope of 'foo' do you have a lhs reference to variable x?"

    For a function declaration, the first thing in the statement is "function name()".

    function bar() { ... }

    function expressions should have names

    var foo = function bar() { ... }

    Why use named functions and not anonymous?

    1. Can refer to itself for recurse
    2. Can find it in minified stack trace
    3. Is self-documenting
  2. eval

    "eval" cheats lexical scope. putting an "eval" in your code, forces the engine to run slower in strict mode, code is more optimizable. Don't use eval unless absolutely necessary.

    For example, using setTimeout with a string of code is bad practive since it invokes "eval()"; better to use with a function:

    setTimeout("console.log('hi')", 1000); 
    setTimeout(function () {console.log('bye');}, 2000); //ok with func pointer
  3. "with" is "more evil than eval"
    var obj = { a: 2, b: 3, c: 4 };
    with(obj) {//implies an obj.
    a = b + c;

    "with" effects the scope and in strick mode, you can't use "with".

Immediately-invoked-function-expression (IIFE) pattern

This is a widespread pattern in JavaScript with a history here: It forces a function to run immediately - hense the catchy name.

var foo = "outside";
(function() {
  var foo = "inside";
  console.log("foo:"+foo)//prints "inside"

"let" (ES6) and block scope

"let" will set the scope of the variable to the "for" loop (or outer braces), not the function scope as "var" would have done. creates an implicit block on the "for".

function foo() {
  for(let i=0; i<var.length; i++) {

warnings: "let" is not hoisted. If in the middle of an if statement block, the variable is only available after the "let". The area above the "let" declaration where the variable is not defined is called the "Temporal Dead Zone".

How to get a new scope? create a function, catch, or a brace with the "let" in ES6

"undefined" is a value, meaning a variable doesn't currently have a value.

"undeclared" never been declared. reference error.


during compile phase, functions and then declarations are "hoisted" to the top.

var a=6;
function foo() { ... }

The compiler rearrages and hoists declarations to top

function foo() { ... }
var a;

Why hoisting? mutual recursion would be impossible. like c header files.

The "this" pointer

Four Rules for how the 'this' keyword get bound.

Every function, while executing, has a reference to its current execution context called "this".

The value of the "this" pointer depends on the call site i.e., where the method gets invoked.

BTW, "this" is not like "this" in any other language.

  1. new

    "new" turns a function into a constructor call and sets the this pointer

    The "new" constructor does four things:

    1. A brand new empty object will be created
    2. The new object gets linked to another object
    3. The new object gets bound as the "this" keyword for the function call
    4. If the function doesn't return something, it will return "this"
  2. Explicit binding Rule

    .call() or .apply() take as their first arg "this"

    example of hardcoding

    function foo() { console.log(; }
    var obj = { bar: "bar" };
    var orig = foo;
    foo = function() {; } //forces this context on foo

    utility to do hardbinding:

    function bind(fn,o) {return function() {; };}
    function foo() { console.log(; }
    var obj = { bar: "bar" };
    foo = bind(foo,obj);

    put bind on Function prototype

    if(!Function.prototype.bind2) {
      Function.prototype.bind2 =
        function(o) {
          var fn = this; //the original function
          return function() {
            return fn.apply(o,arguments);
    var obj = { bar: "bar" };
    foo = foo.bind2(obj);

    ES5 has a builtin "bind"

    hardbind makes "this" be predictable
  3. Implicit binding Rule

    - object calling function becomes the "this"

  4. Default Binding Rule

    in strict mode, default "this" is set to the undefined value

    not in strict, "this" defaults to global, which in browser is window

Summary: Four Questions to determine what is the "this" object
  1. Was the function called with the "new" keyword? use that object.
  2. Was it called with .call() or .apply(). Use explicit object
  3. Was the function called with an owning object? use that.
  4. Default: global object (except in strict mode)

Details in his second book "You Don't Know" - chapter 2


Closure comes from Lambda calculus. Closure is when a function "remembers" its lexical scope even when the function is executed outside that lexical scope.

function foo() {
  var bar = "bar";
  function baz() {

function bam(baz) { baz(); }

//calling a method that returns a method that retains lexical scope (Closure)
function foo() {
  var bar = "bar";
  return function() { 

function bam() {
    foo()();  //call the returned method


The Classic Closure Example

for(var i=1; i<=5; i++) {
  setTimeout(function() {
    console.log("i: "+i);//writes 6 since i references outer scope

for(var i=1; i<=5; i++) {
  (function(i) {//use an IIFE
  setTimeout(function() {
    console.log("i: "+i);//writes 1,2,3,4,5

Classic Module Pattern

Two Characterics of Classic Module Pattern

1. Must have outer function wrapper

2. One or more functions that are returned that have closure over inner scope to access variables

example of module pattern

var foo = (function() {
  var o = {bar: "bar" };
  return {
    bar: function() {
//example of modified module pattern
var foo = (function() {
  var publicAPI = {
    bar: function() {
    baz: function() {
return publicAPI;

Object Orienting

OO Design Patterns

  1. Prototype

    Every single "object" is built by a constructor function.

    Each time a constructor is called, a new object is created.

    A constructor makes an object linked to its own prototype. (In class-based system, new objects are instantiations of the class)

    An object has a link called ".prototype" pointing to its prototype object. The prototype object has a link back to the object called ".constructor"

    A object has a private link called "[[Prototype]]" which points to its prototype object.

    Three ways to get a "new"'d object's prototype.

    1. A object in all browsers except IE has a public link called "__prototype__" (called DunderProto) which points to its prototype object.(in ES6, adopted in IE11)

    2. The standard way to get an object's prototype is "Object.getPrototypeOf(o)" (in IE9, ES5)

    3. For IE8 (ES3): o.constructor.prototype (but .constructor and .prototype are writtable)

    A function has a [[Prototype]] link (__proto__ in ES6 and all browsers except IE below 10) to the object "Function"'s prototype which contains "call()", "apply()", and "bind()".

  2. Inheritance

    Classical inheritance copys the class to make object. Instead use "Behavior Delegation".

    OLOO - Objects Linked to Other Objects

    function Foo(who) { = who;
    Foo.prototype.identify = function() {
      return "I am " +;
    function Bar(who) {,who);
    Bar.prototype = Object.create(Foo.prototype);
    Bar.prototype.speak = function() {
        alert("Hello, " + this.identify() + ".");
    var b1 = new Bar("b1");
    b1.speak(); //alerts: "Hello, I am b1."
    //a slight improvement
    var b1 = Object.create(Bar.prototype);,"b1");
    //moving forward
    bar b1 = Object.create(Bar);

Monday, November 13, 2017

Building Beautiful RESTful APIs in .Net Core - Adnug November Meeting

Nate Barbettini talked to 26 developers at the Austin .Net Users Group.

Here's my notes from his talk:
RPC (Remote Procedure Call) vs. REST (REpresentational State Transfer)
RPC endpoints are verbs (, in REST endpoints are resources (/User)

HATEOAS - hypermmedia as the engine of application state
Data exchange should be treated as if the client were a web browser
No documentation or out-of-band info needed

Use RPC when dealing with a simple object, like the Slack API
Use REST when dealing with lots of different objects with CRUD operations possible on all of them
GraphQL is useful when trying to traverse a graph of REST calls

REST + JSON is popular but hard because no schema is available for the data.
HAL and JSONSchema try to solve that.  Also Ion trys to give structure to JSON data.
The Ion content type is application/ion+json
Ion data is embedded in JSON with fields, like "href","rel", and "value".

ASP.NET Core is a full rewrite of .Net to be portable, faster and cleaner.
Dependency Injection is now in the framework, don't have to download StructureMap

Nate has a free eBook about starting with .Net Core at
Demo to create new .Net Core API with Web API template.  No diff between MVC or API controllers.

Nate used package Entityframework inmemory to do development of demo.  inmemory just gives an inmemory

ASP.NET Core is friendly to async/await pattern.  async first philosophy.


Nate has a course on this. is the result of his 4 hour Lynda course.

Nate has done a great job of learning .NET Core and sharing his knowledge with the community free of charge.