Title photo
frugal technology, simple living and guerrilla large-appliance repair
Sat, 05 Nov 2016

Can you use JavaScript and Node instead of traditional shell scripts?

One of the things that would get me using (and learning) more JavaScript would be the ability to take care of all the administrative things I do in (mostly) Bash, (occasionally) Ruby and (very occasionally) Perl using JavaScript via Node on the command line.

I have played a bit with creating and writing files in that environment, and I found the following posts to help in that effort:

Fri, 20 May 2016

x2js for XML to and from JSON conversion in JavaScript, the Crack gem in Ruby and more

I'm still undecided how I will convert XML to JSON in the election results app/script I am working on.

I'm considering Ruby and Node on the back end, and pure Javascript on the front end.

To those ends, I am looking for libraries that can do the heavy lifting for me.

Among the things I've stumbled upon are x2js.

Just putting this here so I don't forget about it.

If I go for Ruby, there is the Crack gem, which is packaged for Fedora, also hopefully for CentOS, and available for installation via Ruby if that doesn't work out.

Also, I don't want to forget my previous entry on xml2json.

Update: I am currently using the Crack gem with Ruby. I'm shelling out to Bash for some file-based operations that I hope to eventually replace with native Ruby code.

My initial idea of doing this all on the client in Javascript wasn't terribly practical because of all the CPU it took to do the XML to JSON operation on such large XML files.

Sun, 15 May 2016

Converting XML to JSON in JavaScript and learning what you need to do when you need to do it

I'm working on my election script, which has been Bash on the server to produce HTML with custom display on nine different websites controlled via CSS. Hacky as shit, but it works.

I've toyed with doing the script in Perl or Ruby, but my colleague Daniel Aitkin asked whether we could script the data into JSON, aka JavaScript Object Notation.

That way we could pretty much do this as a Javascript-on-the-client Web page. For California statewide data, we are working with XML, so a simple conversion to JSON in the browser would do the trick.

And here is one of many solutions to the XML-to-JSON problem: https://github.com/enkidootech/xml2json.

If this works, server-side scripting is limited to fetching and unzipping the XML files from the California Secretary of State. JavaScript will do the rest.

Since LA County sends fixed-width ASCII, this plan goes out the window, but I vaguely remember another ancient data format that I might be able to hack into JSON. Or the LA County data will be mangled the old-fashioned way.

I'm in the mood/mode to do things with JavaScript in the browser. I recently hacked together this simple Web page that takes any URL and spits it out with nine different domains and then copies them to my desktop clipboard via buttons, an admittedly narrow use case but one that I have about 30 times a day.

That's the best way for me to learn: Have an annoying problem and make it go away through code.

Along these very same lines, since I'm collaborating with others on this project, I decided that we needed a way to share the code.

And since I wanted to work out of a private repository, Gitlab ($0/month) beat Github ($7/month). And we are all learning git.

Mon, 09 Nov 2015

I am reading 'Learning to Program' by Steven Foote

I am reading "Learning to Program," by Steven Foote, an introductory programming guide focused on JavaScript with a novel twist: Lessons are taught through the creation of Google Chrome browser extensions.

I'm only on Chapter 2, but things I already like about the book: It's for beginners but doesn't act like Node.js isn't a thing, I really like the idea of creating browser extensions, and it looks like it goes through a good number of programming concepts.

And Mr. Foote's writing style is clear and inviting.

Sun, 13 Sep 2015

I build an app, Part 1: Hashes (aka key-value pairs) are easy in JavaScript (and even in Java) ... plus my coding bio

I like to learn by doing. I'm reading and typing in code and futzing around with it. But I had an idea, and I'm betting I can learn what I need to make it happen.

The idea is a "What is this acronym?" app, where there's a web page, the user types in an acronym (or partial acronym) and gets in return a list of possible full names for that acronym.

Nothing too crazy, and I'm going to keep it as simple as I can.

I want to do it as a single-page JavaScript app. Call it "just a web page with some interactive JavaScripty elements." Is that an "app"? (Don't know, don't care).

I'm choosing JavaScript for this project because I want to keep it simple. And I want to learn JavaScript.

Read the rest of this post

Thu, 04 Dec 2014

Unhappy Node.js users fork the Joyent-run project, creating community-driven io.js

The Node.js server-side Javascript runtime is today’s hot thing. You might say it’s the Ruby on Rails of the ’10s. Where developers used to code in Perl and PHP, then Ruby/Rails, today’s startup-fueled web-development world is all about Javascript on the server, and Node is the grease that makes it all go.

And sitting atop the Node.js heap is Joyent, the company where Node creator Ryan Dahl was working when he came up with the idea and the code to make it run.

So even though Node.js is an open-source project, its direction is largely guided by the for-profit Joyent. And that doesn’t sit so well with some Node users/developers.

As reported in InfoWorld and elsewhere, a group of them just started a fork of Node.js called io.js, which is now living on GitHub and prepared to take the Node code in a community-driven direction.

As the io.js project’s “Read Me” text states:

"This repository began as a GitHub fork of joyent/node where contributions, releases, and contributorship are under an open governance model.

"We intend to release, with increasing regularity, releases which are compatible with the npm ecosystem that has been built to date for node.js."

As InfoWorld previously reported the Node forking threat has been floating around for awhile, and in response Joyent created an advisory board to get more community input into what has become one of the most-used open-source projects in the world of web-delivered application development.

Fighting, infighting, forking and just plain grumbling is nothing new to open-source projects. Friction over the transition from Python 2 to Python 3, the never-ending gestation of Perl 6, everything about Linux distribution Ubuntu and its SABDFL (self-appointed benevolent dictator for life) Mark Shuttleworth since he moved the buttons from right to left, Debian and the now-raging debate over the systemd init system that’s so much more than an init system … and the beat goes on.

The question is, does Joyent have enough developer (and major corporate) juice to keep Node as the glue holding together today’s Javascript-driven web stack?

The short-term bettor says yes, since Javascript on the server is so “now,” and corporate IT has wrapped its arms firmly around Node. But since Javascript on the server has gone from curiosity to total domination in a few short years, and there’s always something new on the hot-development-tool horizon, it’s anybody’s game.

If the many-horse race over “best Javascript web framework” is any indication, another player in Node’s space is nothing more than the familiar brand of healthy competition that keeps the technology world on its code-slinging toes.

Most forks come to nothing. Just like ex-Microsoft CEO Steve Ballmer once said in all his sweat-drenched glory, it usually comes down to “developers, developers developers.”

Fri, 18 Jan 2013

Discovering jquery's load function

I've been playing with the load function in jquery. It works quite well. I'm going to be using it in a project very soon.