Node.js Learning Path: Unit 5 – The Event Loop

Hey everyone! If you want to learn Node.js, then check out my Node.js Learning Path, which you can find only at IBM Developer.

The Event Loop is the key to Node’s scalability.

Unit 5 of the LP is about the Event Loop, and in it you’ll learn stuff like:

  • The phases of the Event Loop
  • How to write code that runs in the various phases (so you know when your code will run)
  • The Node Events API
  • Node Streams

There’s a quiz to help you deepen your understanding of the material, and a video too:

Ready to dive into the Node Event Loop? Then click here to jump right to Unit 5.

Want to take the entire course? Then click here to start at the beginning, with Unit 1.

Either way, have fun, good luck, and thanks for reading!



Process Substitution and SHA256 Checksum

Hey everyone!

When you verify the SHA256 checksum of a downloaded file you can copy the checksum from the website, paste it into an editor, run the shasum -a 256 command, paste the checksum into that same editor and compare them by eye.

Or, use the diff command and process substitution to do it, and never have to trust your eyeballs again (you should still keep them open while driving though).

I put together this video to show how easy it is to do this. Enjoy!

Thanks for reading!



Why I Don’t Use Postman

I do tutorials. Lots of them (check out my 2018 publications).

Sometimes the tutorial involves a REST or SOAP interface. And I get questions like, “Stevie baby, why you use SoapUI? Postman is so much nicer!”

First, I’ve used SoapUI for years, and I really like it (warts and all).

Second, it’s free and open source.

Finally, this:


I absolutely DESPISE sites that make me sign up for anything in order to use their products. When I run across stuff like this, it makes me want to grind my teeth.

Why Postman does this is not lost on me. Creating software is an expensive endeavor. I totally get it.

But, if I have another choice, I’ll exercise it rather than give these companies my email address (which almost immediately increases the already hefty amount of spam I get).

I’m not arguing for or against this type of signup-to-use-our-product shannanigans. I’m simply answering the question I was asked: why don’t I use Postman as a REST client?

Now you know.

What do you think? Leave me a comment. Thanks for reading!


Kitematic: Use This Tool

Hey everybody!

If you use Docker and don’t use Kitematic, you’re missing out!


Kitematic is an awesome addition to your Docker toolbox. Download it here.

What is Kitematic?

It’s a graphical tool that lets you see what is running in your local Docker environment.

You’re probably used to docker ps, and docker images, and so on, to see what Docker is doing. But Kitematic can show you that information in a GUI.


Okay, so I’m working on Part 3 of a tutorial series I’m doing for IBM developerWorks, and I have Hyperledger Fabric running in Docker.

Contrast this:

Ix:~ sperry$ docker ps
 CONTAINER ID        IMAGE                                                                                                                        COMMAND                  CREATED             STATUS              PORTS                                            NAMES
 c8e71d740f38   "chaincode -peer.a..."   44 minutes ago      Up 44 minutes                                              
 2931d5073686        "chaincode -peer.a..."   21 hours ago        Up 21 hours                                                
 9e4edf0acb21        hyperledger/fabric-peer:x86_64-1.0.3                                                                                         "peer node start -..."   21 hours ago        Up 21 hours>7051/tcp,>7053/tcp
 7392660e2da1        hyperledger/fabric-ca:x86_64-1.0.3                                                                                           "sh -c 'fabric-ca-..."   21 hours ago        Up 21 hours>7054/tcp                 
 61ffea441cc6        hyperledger/fabric-orderer:x86_64-1.0.3                                                                                      "orderer"                21 hours ago        Up 21 hours>7050/tcp                 
 8034e8baa63e        hyperledger/fabric-couchdb:x86_64-1.0.3                                                                                      "tini -- /docker-e..."   21 hours ago        Up 21 hours         4369/tcp, 9100/tcp,>5984/tcp       couchdb
 Ix:~ sperry$

With this:

Screenshot 2017-11-06 11.43.13

You can see the same info, but in a GUI format. Now, I love the command line as much as anybody, but sometimes figuring out what is going on with Docker through the command line can be frustrating. Not that the information isn’t there; just that it’s not super easy to tease out the information I’m looking for.

What else?

With Kitematic, you can see the logs for each container, just as you can with the docker logs command.

Compare this:

$ docker logs 61ffea441cc6

2017-11-05 20:19:38.265 UTC [orderer/main] main -> INFO 001 Starting orderer:
 Version: 1.0.3
 Go version: go1.7.5
 OS/Arch: linux/amd64
2017-11-05 20:19:38.274 UTC [bccsp_sw] openKeyStore -> DEBU 002 KeyStore opened at [/etc/hyperledger/msp/orderer/msp/keystore]...done
2017-11-05 20:19:38.274 UTC [bccsp] initBCCSP -> DEBU 003 Initialize BCCSP [SW]
2017-11-05 20:19:38.275 UTC [msp] getPemMaterialFromDir -> DEBU 004 Reading directory /etc/hyperledger/msp/orderer/msp/signcerts
2017-11-06 16:49:34.979 UTC [fsblkstorage] updateCheckpoint -> DEBU a7f Broadcasting about update checkpointInfo: latestFileChunkSuffixNum=[0], latestFileChunksize=[213666], isChainEmpty=[false], lastBlockNumber=[7]
2017-11-06 16:49:34.979 UTC [orderer/multichain] WriteBlock -> DEBU a80 [channel: composerchannel] Wrote block 7
2017-11-06 16:49:34.979 UTC [fsblkstorage] retrieveBlockByNumber -> DEBU a81 retrieveBlockByNumber() - blockNum = [7]
2017-11-06 16:49:34.979 UTC [fsblkstorage] newBlockfileStream -> DEBU a82 newBlockfileStream(): filePath=[/var/hyperledger/production/orderer/chains/composerchannel/blockfile_000000], startOffset=[205101]
2017-11-06 16:49:34.979 UTC [fsblkstorage] nextBlockBytesAndPlacementInfo -> DEBU a83 Remaining bytes=[8565], Going to peek [8] bytes
2017-11-06 16:49:34.979 UTC [fsblkstorage] nextBlockBytesAndPlacementInfo -> DEBU a84 Returning blockbytes - length=[8563], placementInfo={fileNum=[0], startOffset=[205101], bytesOffset=[205103]}
2017-11-06 16:49:34.979 UTC [orderer/common/deliver] Handle -> DEBU a85 [channel: composerchannel] Delivering block for (0xc4208547c0)

With this:

You can see the logs (under the Home tab on the right-hand side of the UI), in addition to information about the port that is exposed on localhost, the volumes that are mounted, and settings for both.

Get Kitematic

How do you use Kitematic? Go to the Docker drop-down menu in the status tray (mine is at the top of the screen on my Mac),

And select Kitematic. The first time you do this, you’ll see this dialog:

Click the “here” link (which takes you to Once the ZIP file is downloaded, unzip it. It contains the Kitematic app, which you then drag and drop into your Applications folder. The next time you select Kitematic from the Docker drop-down, it fires up seamlessly.

You can sign into Docker Hub if you have an ID (if not, just select “Skip for Now”).

That’s it! Now you can use Kitematic.


I’m not suggesting you shouldn’t use the Docker command line tools. They’re great. But Kitematic is another tool in your Docker arsenal.

Enjoy. And thanks for reading!


Container Orchestration with Kubernetes, Part 1

Why Containers?

Hey everybody! In this post, I’d like to talk about Container-centric infrastructure with Kubernetes. This is Part 1 of a series of posts on using installing and using Kubernetes.

Let’s start with the kubernetes documentation.


Host-Centric infrastructure

Before containers, we installed applications directly on the target host, along with libraries our apps needed, plus the libraries any other applications needed as well.

At best, it presents DevOps with maintenance challenges. And at worst, integration conflicts between applications, versions of dependent libraries, and so on, can lead to poor application performance and even downtime.

Container-Centric infrastructure

With containers, on the other hand, all the applications run in their own isolated mini environments, away from each other, and the underlying OS.

And this is what you get with Kubernetes!


Container-centric infrastructure like that provided by Kubernetes has tremendous benefits, and in Part 2 I’ll give you an overview of Kubernetes, and talk about Pods, Nodes, and the “desired state” of the cluster. Stay tuned for that.

Want to know more?

If you want to learn more about Kubernetes, check out this post at IBM developerWorks: What is Kubernetes?

Check out this video at IBM developerWorks TV, where I show you everything I covered in Parts 1-5 of this series:

Introduction to Kubernetes:

Thanks for reading!


What is Apache Kafka?

Change the way you think about data.

You’ve probably heard of Apache Kafka. You know, that Big Data, publish/subscribe message broker, time ordered log thingamajig that integrates all your application data, and provides real-time materialized views while being crazy scalable?

Yeah, that one. In this article at the IBM developerWorks Blog, I talk about Apache Kafka. I’ll assume you’re the  perfect candidate for applying Kafka, and talk about your architecture today. Then I’ll describe where you want to be, what is blocking the path to your getting there, and finally, how Kafka can help.

Check it out if you get a chance. Kafka is really cool.

And don’t forget to follow my blog, and follow me on Twitter @jstevenperry


What is Node-RED?

Ah, the Internet of Things (IoT for all you acronym aficionados). It’s awesome, right? Throw in some JavaScript, and a browser, and what do you have? Node-RED!

Node-RED was created by IBM’s Emerging Technology Services team, and allows you to create functionality by wiring together flows of data between nodes using a browser. And it has gained tremendous popularity in the IoT space, by modeling bits of application functionality between IoT devices like sensors, cameras, and wireless routers.

But it’s so much more than that, and in this article, I’ll break it down for you.

What Problems Does Node-RED Solve?

It’s helpful to understand the problems a technology solves, or you might misapply it. So what problems does Node-RED solve?

High Barrier to Entry

Let’s face it, not everyone writes great code (I’m certainly not talking about you or me, of course). Coding has a high barrier to entry that can sometimes stifle innovation due to the gap between the idea and the code to implement it.

What happens to all those great, innovative ideas out there because nobody is around to code them?

Not only that, but not everyone thinks in code. Some people are more visual.

Prototypes are critical to innovation

If you’re going to pitch an innovative idea, you need something to show. You know, a straw man. That means you’ll need a prototype.

Let’s say you build a prototype. Now what? Prototypes are often just toy applications. How do you get from prototype to something useful?

And what about someone who doesn’t code? How would they build a prototype?

What Node Red is NOT

A new technology stack

Node-RED uses battle tested technologies as part of its technology stack like Node.js, JSON for metadata, JavaScript for coding, and almost any web browsers.

Of course, nodes can be written to allow processing in pretty much any way you like. Node-RED is super flexible!

XML based

I’m not terribly fond of XML – not because it’s not awesome but because in practice it’s so often misapplied (application metadata comes to mind) – and Node-RED doesn’t need a single shred of XML metadata to function.

Sure, there are contribs that allow you to work with XML, but the metadata of a Node-RED flow is not built on XML (but much more – IMHO – readable JSON).

A toy

Build a prototype in Node-RED and wow your customer. Then build on that prototype to create the finished product, whether that is a single new function, a collection of new functionality, or an entire application from browser to database.

Serious application functionality can be built using Node-RED. Don’t take my word for it. Using IBM’s BLOOP BLURP

Just for IoT

While Node-RED shines at the Edge, it can be used to solve pretty much any problem that can be modeled as a flow-based program (FBP).

An FBP is made up of processing components (the nodes) that process data (e.g., transform it from one form to another) and write the data out to other components to which they’re connected in a network of such components. FBP lends itself well to problems that don’t naturally fit traditional, sequential program models (e.g., multiplexing, and recursive programs).

The Solution

Enter Node-RED

Node-RED is:

  • A browser-based flow editing tool,
  • Built on Node.js, and
  • Designed for reuse – lots of pre-built nodes, or build your own and share them!

Okay, you may be thinking, how does that solve the problems listed earlier?

High Barrier to Entry

First off, Node-RED is simple to setup and use. You just install a few things (like Node.js, and the node-red package) and it’s ready to use. Seriously.

Then, once you’ve fired up Node-RED, you can use is to create flows visually. See, Flow-based programming is all about the flow of data: data in, data out. Visualize the data, Neo.

Finally, using Node-RED’s graphical flows makes building prototypes a snap:

  • Select pre-built nodes from the palette
  • Wire them together
  • Test
  • Repeat


So what are you waiting for? Give Node-RED a spin today.

You’ll be glad you did.