Title photo
frugal technology, simple living and guerrilla large-appliance repair
Wed, 12 Apr 2017

The Node in the Windows Subsystem for Linux is so old, I installed Node for Windows

I want to run Node, so I figured that I would install the package from the Ubuntu LTS in the Windows Subsystem for Linux and just use it from the Ubuntu commmand line in Windows 10.

But I soon learned that the nodejs in the WSL is v0.10.25. That is hella old. Early 2014 old. No ES6 old.

I don't want to mess with the WSL environment too much, and I have no idea what kinds of binaries from outside the WSL will even work (if any of them will). But I wanted a newer -- a much newer -- Node.

So I installed the Windows version of Node -- the Current version -- which is v7.9.0.

That is a lot newer.

I'm not building major web applications with Node. I'm mostly using it to learn Javascript and even do some traditional scripting that I might otherwise do in Ruby or Bash.

Now I'll be doing that in the Windows command line and not the Windows Subsystem for Linux (until I can no longer hold out without a full, "modern" Linux distribution like Fedora on this laptop).

Update: Node v.0.10.25 in the Ubuntu Trusty LTS is super, super old. For comparison's sake:

Ubuntu Trusty: Node v0.10.25
Ubuntu Xenial (newer LTS): Node v4.2.6
Ubuntu Zesty: Node v.4.7.2
Debian Jessie: Node v0.10.29
Debian Stretch: Node v4.7.2
Debian Sid: Node v4.8.2
Fedora 25 and 26: Node v6.10.2

Even Debian Jessie has a slightly newer nodejs than the Ubuntu LTS in the Windows 10 WSL. There is a way to update the Ubuntu in the WSL from 14.04 to 16.04. Might be worth a look for me.

Tue, 04 Apr 2017

Make a website with Ember - great introduction to a framework

I really like the idea behind Less than *ambitious* websites with Ember.js, in which author sheriffderek goes through the steps required to create a simple web site with the Ember JavaScript framework.

Easing into a framework -- that's the way I want to do it.

Thu, 30 Mar 2017

React-Redux links by Mark Erikson

React-Redux links by Mark Erikson https://github.com/markerikson/react-redux-links -- an excellent list that also covers learning JavaScript

Wed, 29 Mar 2017

Eloquent JavaScript - Chapter 2 exercises - Fizz Buzz

I'm not saying I will make it through all 22 chapters of "Eloquent JavaScript," by Marijn Haverbeke, but enough people I respect have recommended the book that I'm doing my best to absorb what I can from it.

To that end, I am doing the exercises in the back of each chapter, and I plan on presenting my solutions here.

This entry also serves as a test of the Highlight.js JavaScript library, which I just added to this Ode site for syntax highlighting of code. I'm using the zenburn CSS.

Back to "Eloquent JavaScript." If you don't want any hints, don't go past the blog index. I will only start showing my code after the "read more" portion of each entry.

Before maybe a year ago, I'd never heard of Fizz Buzz, where you write a program that outputs the words Fizz, Buzz or Fizz Buzz depending on whether a number is divisible by 3, by 5 (and not 3) or by 5 and 3.

Fizz Buzz is supposedly used as a programming test in hiring. I was surprised when it was given as the second exercise in Chapter 2

Read the rest of this post

Sun, 01 Jan 2017

JavaScript books for 2017

"Eloquent JavaScript: A Modern Introduction to Programming" by Marijn Haverbeke

"Learning JavaScript: JavaScript Essentials for Modern Application Development" by Ethan Brown

"Speaking JavaScript: An In-Depth Guide for Programmers" by Dr. Axel Rauschmayer

"Learning JavaScript Data Structures and Algorithms" by Loiane Groner

"You Don't Know JS" (series) by Kyle Simpson

"Programming JavaScript Applications: Robust Web Architecure With Node, HTML5 and Modern JS Libraries" by Eric Elliott

Wed, 28 Dec 2016

Eric Elliott on JavaScript

I am linking to these Eric Elliott articles on JavaScript programming because I don't want to forget about them.

Eric Elliott: 12 Books Every JavaScript Developer Should Read

Eric Elliott: The Software Developer’s Library: A Treasure Trove of Books for People Who Love Code

Eric Elliott: Learn to Code: 13 Tips that Could Save You Years of Effort

Eric Elliott: Native Apps are Doomed

Eric Elliott: Why Native Apps Really are Doomed: Native Apps are Doomed pt 2

Wed, 07 Dec 2016

Text processing in node (i.e. in JavaScript)

My last text processing project started in Bash, which which I'm more familiar, and then took a turn toward Ruby before returning to Bash when deadlines got tight.

Now I'm thinking about the next election-results script, which won't be using XML from the state of California but instead the space-delimited ASCII from Los Angeles County. Another developer handled that task in November, but I want to take a crack at it for March 2017.

My goal is a "universal" script that can work on any results file that the county provides without requiring a lot of hacking for individual races in any given election.

In other words, I want to write once, run many times.

I could do it in Bash. Or Ruby. But I might want to try JavaScript and run it with Node on the server (or, if the election is "small" enough, client-side in the browser).

LA County data is not standard. It's not XML or JSON (though the county DOES use JSON in its own results, it does not share that data with the media).

Instead, the county uses what appears to be a home-grown data format that is arcane yet well-documented.

Each line begins with an alphanumeric code, and data fields are placed on those lines at predetermined character lengths and predetermined positions.

So a script would have to create substrings of the data from each line. I'm thinking that I'll use the script to either create XML that I would then convert, or to skip that step and create JSON directly from the county's data.

Doing it in JavaScript would be an opportunity to learn more about the language (just like it would be for Ruby if I used that language; and the jury is most definitely out).

What muddies the water considerably is the fact that my company is also following elections in San Bernardino, Riverside and Orange counties. I know that San Bernardino doesn't really provide data at all. I generally scrape their web page on Election Night. I don't know what Riverside and Orange do.

So I'm going to focus on LA County for now. Another developer wrote the front-end code for the election-results display, and all I have to do is provide the JSON. I wouldn't be opposed to writing the whole app, but for now a "smaller" bite is a more realistic one.

XML to JSON in Javascript with enkidootech's xml2json

I'm exploring my options for coverting XML to JSON, even though I don't have any new XML coming my way.

I previously used a Ruby library and considered a different JavaScript library to do the conversion.

I just tested a different JavaScript library, enkidootech's xml2json, and that worked very well right out of the box.

Well, almost.

I tried to install it globally via npm, but my resulting JavaScript file didn't seem to be able to find it.

Then I used npm to install the package locally, and that worked. I have a node_modules directory in the same directory as my script, and it outputs JSON as expected.

I just took what enidootech offers as an example and put that in my file (which I named xml_to_json.js). I ran it with node and it worked:

// From https://github.com/enkidootech/xml2json

var parser = require('xml2json-light');
var xml = '<person><name>John Doe</name></person>';
var json = parser.xml2json(xml); 

console.log(json);

You get this:

$ node xml_to_json.js 
{ person: { name: 'John Doe' } }

Nice!

If my next script won't involve XML, what will it do? That's a question for the next entry.

Tue, 06 Dec 2016

CodePen: JavaScript Basics 2: Arrays and Loops

CodePen: JavaScript Basics 2: Arrays and Loops http://codepen.io/jakealbaugh/post/js-basics-2-arrays-and-loops

CodePen: JavaScript Basics 1: Functions and Variables

CodePen: JavaScript Basics 1: Functions and Variables http://codepen.io/jakealbaugh/post/js-basics-1-functions-and-variables