Title photo
frugal technology, simple living and guerrilla large-appliance repair

Regular blog here, 'microblog' there

Many of my traditional blog post live on this site, but a great majority of my social-style posts can be found on my much-busier microbloging site at updates.passthejoe.net. It's busier because my BlogPoster "microblogging" script generates short, Twitter-style posts from the Linux or Windows (or anywhere you can run Ruby with too many Gems) command line, uploads them to the web server and send them out on my Twitter and Mastodon feeds.

I used to post to this blog via scripts and Unix/Linux utilities (curl and Unison) that helped me mirror the files locally and on the server. Since this site recently moved hosts, none of that is set up. I'm just using SFTP and SSH to write posts and manage the site.

Disqus comments are not live just yet because I'm not sure about what I'm going to do for the domain on this site. I'll probably restore the old domain at first just to have some continuity, but for now I like using the "free" domain from this site's new host, NearlyFreeSpeech.net.

Wed, 20 Dec 2017

Regular expressions in JavaScript

Regular expressions in JavaScript by Zsolt Nagy.

Sun, 17 Sep 2017

Building a Twitter clone with Meteor

From The Meteor Chef:

Wed, 26 Jul 2017

Free book: The JavaScript Way

I just heard about "The JavaScript Way," a book by http://www.bpesquet.com/ that is https://github.com/bpesquet/thejsway/ and a minimum of https://leanpub.com/thejsway.

It bills itself as beginner-friendly yet written to ES2015 standards. I took a quick look, and so far I like it.

Sat, 15 Jul 2017

Meteor Forums: Why I fell in love with Meteor

This post from the Meteor Forums is drawing some attention. (Thanks to HashBang Weekly for the link.)

Sat, 01 Jul 2017

7 Strengths of #ReactJS Every Programmer Should Know About

https://blog.reactiveconf.com/7-strengths-of-reactjs-every-programmer-should-know-about-6a5f3a69a861

Sat, 17 Jun 2017

Eloquent Javascript, Chapter 3 (Functions) -- what the hell?

I read Chapter 3 of Eloquent Javascript some time ago, and it's a difficult one. It introduces the concept of functions. Quickly introduced are: Parameters and Scopes, Nested Scopes, Closure and Recursion.

It is too much, too fast with too few examples. I was able to do the first exercise, Minimum, but got lost in the second, Recursion.

Here is my solution for Minimum:

#!/usr/bin/env node
/* Eloquent Javascript, Chapter 3, Page 56, Exercises 
Create a function to find the minimum of two arguments

By Steven Rosenberg, 6/17/2017 */

function smallest(first_number, second_number) {
    if (first_number < second_number)
        return first_number;
    else if (second_number < first_number)
        return second_number;
    else
        console.log("They are equal")
}

// Output will be the smallest of these two numbers
console.log(smallest(100, 2));

Expressing this as a function doesn't really do much. The program could just as easily have been written in a straight "procedural" format. But it's a function, and it works.

The second problem on recursion stumped me. I'm pretty sure I can figure it out, but I need more time to think (and look up more on recursion).

Tue, 13 Jun 2017

Sitepoint: How I Designed & Built a Fullstack JavaScript Trello Clone

Sitepoint: How I Designed & Built a Fullstack JavaScript Trello Clone by Moustapha Diouf.

This article and accompanying repo show how Moustapha Diouf built this React app with Express and Mongo.

Tue, 30 May 2017

To run Node in Debian and Ubuntu, install nodejs and nodejs-legacy

Installing node.js in Fedora is no problem. You just run sudo dnf install node, and you're off to the JavaScript-in-the-console races. But it's slightly more complicated in Debian and Ubuntu.

Since there's an old amateur radio package called node for communicating on packet radio nodes, Debian and Ubuntu use the package name (and shell command) nodejs. So you would run nodejs when you would normally run node.

But you don't have to do this. And you don't have to resort to any Linux/Unix tomfoolery either.

Both Debian and Ubuntu have a package called nodejs-legacy that makes the symlink for you. Then you can run node by typing node in the console.

Since it looks like there is no node for amateur radio in Debian Sid or Experimental, I'm thinking that the node-vs-node.js problem will go away at some point in the near future -- when Debian declares its next release stable, and in turn when Ubuntu bases its future releases on versions of Debian that have "re-resolved" the issue. (Since I'm running Ubuntu 16.04 in the Windows Subsystem for Linux, this hasn't happened yet.)

Until then:

$ sudo apt install nodejs nodejs-legacy
Tue, 09 May 2017

Javascript digital clock

Since this blog's time is displayed in UTC, I wanted to put a digital clock on the site that told the current Universal Time so a casual reader (like me) could have some idea of how long ago (or what time of "day") a given post was published.

I started with some JavaScript code from Cory/uniqname on CodePen and simplified it greatly and because I wanted more output rather than less, counterintuitively as well.

It uses the Date() object and the toUTCString() method to create the text for display of the time/day/date/year and setInterval to "update" the text every second:

function clock() {
  var local_time = new Date(),
  utc_time = local_time.toUTCString();

document.querySelectorAll('.clock')[0].innerHTML = utc_time;

}
  setInterval(clock, 1000);

I stashed this bit of code in a file called clock.js, and called it into the site with script tags and a div:

<script type="text/javascript" src="/path/to/clock.js">
</script>
<div class="clock"></div>

(Note that /path/to/clock.js means the actual path on the server to where you happen to have created the JavaScript file.)

The toUTCString() method outputs the time in 24-hour format. If I want it it in 12-hour format (with AM/PM), the script would have to get a lot more complicated. I'm not saying I won't do that, but for now the easy wins over the perfect.

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.

Update: After a Windows 10 upgrade hosed the laptop, I restored Windows and reinstalled the Windows Subsystem for Linux after that. My user files were preserved, but I lost all of the files I created in the WSL.

Moral of this story: Back up your Linux files. You can back them up in your Windows user files. I would recommend making a habit of using the WSL/Ubuntu command line not in the WSL's traditional /home directory but in your Windows user area. However, things that are complicated (and particularly which involve setting Unix-style permissions) cannot be done successfully on the Windows side. Among these "complicated" things are the use of Unison to sync two filesystems on different computers. The Ubuntu/WSL version of Unison works great in the WSL but throws errors aplenty when used on the Windows side. (One solution is to use the Windows version of Unison, but I'm a whole lot of hacking away from getting ssh working on the Windows command line in a way that Windows Unison finds acceptable; It's not as easy as subbing PuTTY's plink command-line tool.)

My new WSL turned out to be 16.04, not 14.04: This "solved" my Node problem, as I got 4.2.6 instead of 0.10.25, but I also got a newer version of Unison (and had to download, install and "hold" the 14.04 version).

The newer Node in Windows: So I could make better use of Node in Windows, I installed the Windows version of Vim, making sure the console version was included and .bat files were created so I could use Vim to edit files for Node from the Windows command line, which is somewhat of a mystery to me as I've barely used it (and many years ago at that).