Quickly Diff Two Strings in Bash Shell

Hello, World!

I am working on a Raspberry Pi 3 project (my first, I’m embarrassed to say :-p) and downloaded NOOBS OS installer to install Raspbian on my new Pi.

Even though I torrented the ZIP file, I still wanted to check the SHA256 checksum of the download. I’m careful that way.

Here’s what I want to do: compute the SHA256 hash of the NOOBS Zip file and compare that to the checksum from the website:

Screenshot 2017-08-25 09.56.05

Drop out to a command window. Enter this command (I don’t want the file name, so I run it through sed after the shamus command):

shasum -a 256 ./NOOBS_v2_4_3.zip | sed 's/^\(.[a-f0-9]*\) .*$/\1/'

Which returned:


Now, copy the line from the Terminal window, open a text editor, paste it in. Hit enter to get a new line in the editor, copy the SHA-256 hash from the NOOBS download page, and paste that in below it:

Screenshot 2017-08-25 10.09.00

By eye, I can easily see these match, but I thought, “Sheesh, what a lot of work! There has to be a better way!” Spoiler alert: there is!

I found this post at StackOverflow, which linked to this post about process substitution.

So through a single command, I can compute the SHA-256 hash of the downloaded ZIP file, and compare that to the checksum from the NOOBS downloads page (okay, okay, I still have to manually copy the checksum from the downloads page and paste it into the command line after the echo):

diff <(shasum -a 256 ./NOOBS_v2_4_3.zip | sed 's/^\(.[a-f0-9]*\) .*$/\1/') \
<(echo 94790b8d87086d46d16413bd1967e3f5eb709cb5e124d8213d40e5707da18437)

Note: I’m using “\” to indicate the line is too long for WordPress to display, but the command works just fine with the backslash in there. Here’s a screenshot in case you need further convincing (I ran it twice, once with and once without the backslash):

Screenshot 2017-08-25 10.39.55

Voila! When the command line comes back with no output (as diff does when there are no differences between “files”), I know the checksum is good!

So, to sum up, the basic format for this command (assumes you’re checking an SHA-256 hash) is:

diff <(shasum -a 256 /path/to/file/FILE_TO_CHECK | \
sed 's/^\(.[a-f0-9]*\) .*$/\1/') <(echo CHECKSUM_FROM_WEBSITE)

Hope you enjoyed this tip. Thanks for reading!

Now if you’ll excuse me, I have a Raspberry Pi 3 project to get to!


Java News and Code, Episode 13


Welcome to Java News and Code, where I tell you about interesting goings-on in the world of IT in general, and Java in particular.

And there’s always code.

On This Episode:

  • Java Still on top in the Tiobe Index (but falling)
  • Android O Final Preview
  • Code Talkthrough: Android and the Cloud


Java Still on Top (but Falling)

Screen Shot 2017-08-14 at 10.26.31 AM

According to the Tiobe index for August 2017, Java is at #1 and still has a commanding lead over all other languages. But its percentage score has fallen to about 13%, down from just over 19% a year ago.

And Java is not alone: the top 5 are all in decline from a year ago, with C at 6 1/2%, C++ at 5.6%, C# at 4.2%, and Python at 3.7%.

Scroll down on the page to see just how far ahead of the pack Java is:

Screenshot 2017-08-14 15.10.52

From the graph you can see Java had a similar drop back in 2004 from which it rebounded strongly, so maybe this is a temporary trend. Who can say?

If you want to see how the index is put together, you can visit this page.

The Tiobe index is put together during the first week of each month.

Make sure and check out the show notes page, where you can find this story, along with all the links in this episode of Java News and Code.

So be sure to check that out.

Android O Final Preview is Out

On July 24th, Android O Developer Preview 4 was made available.

The announcement on the Android Developer’s Blog, comes one month after the announcement of Developer Preview 3, which I told you about in episode 8 of Java News and Code.

Preview 3 contained some very nice features like simplified settings, battery life optimizations, and per app notifications.

Preview 4 is the final preview before the official O release later this summer:

Screenshot 2017-08-14 15.25.35

Preview 4 is a Release Candidate build of the Android O platform, and while it doesn’t have any new features, it contains the final system behaviors, bug fixes, and the final API (level 26).

Coming soon is also a new release of the Android Testing Support Library. The blog post says to stay tuned for more details coming soon.

And if you want to use Developer Preview 4, it’s recommended that you download Android Studio 3 Canary 1 as well, available in the Canary channel.

The show notes page has links to the blog post, download page, and lots more.

So be sure to check that out.

Code Talkthrough: Android and the Cloud

Finally, in today’s code talk through, I’d like to show you a recipe for building a RESTful web service application, deploying it to the Bluemix cloud as a Cloud Foundry application, and building an Android app to communicate with it.

The code I’ll show you is available in GitHub, and is from a recipe I wrote for IBM developerWorks called Android and the Cloud.

To follow along with the video, you will need a Bluemix account, JDK 8, Eclipse, WebSphere Liberty, and Android studio installed on your computer.

You will need three projects from GitHub also:

In today’s show, I’m just going to show you the high level steps.  The recipe walks you through it step-by-step if you’re interested in reproducing this yourself, which I hope you are.

Let’s get started.

First, clone the code from GitHub for the two web services projects.

git clone https://github.com/makotogo/oDoTCore
git clone https://github.com/makotogo/OdotWrapper

Now import the code into Eclipse.

With the code in Eclipse, build the oDoTCore JAR file using Maven, specifying the install goal so the JAR file gets installed to your local Maven repository.

Next, build the OdotWrapper WAR file using Maven, specifying the package goal.

Locate the WAR file in the target directory, and copy it to the WebSphere Liberty droppins directory.

Start WebSphere Liberty in Eclipse.

To verify the WebService is working, go to a browser and access this URL


When you see the JSON message, you know you have everything built and packaged correctly.

Now I’ll bundle the WebSphere Liberty server, including the WAR file, and deploy it to Bluemix.

For this part I need my Bluemix credentials, and the route I want to deploy it to.

I’m going over this fast, I know, but this is just an overview. The recipe has all the details.

Once I’ve deployed the application to Bluemix, I can test it and make sure it’s running. Open a browser, and hit this URL:


Again, when I see the JSON message “Hello from the server side!” I know it’s up and running.

Now to build the code for the Android app, run the app in the Android Emulator, and access the Web Service running in Bluemix.

Don’t worry, we’re almost there!

First, pull the code from GitHub:

git clone https://github.com/makotogo/AndroidCloudRecipe

Now import the code into Android Studio, and run the code in the Android Emulator. Choose the virtual device you setup when you installed and smoke tested Android Studio. It takes a minute or two for the device to start.

When the device starts, it will load the application. If you don’t see the application, click the Run button again in Android Studio.

Verify that the URL is correct (if not, change the code and run it again), and click the Info floating action button to invoke the Ping method. If you get back a Toast message that looks like this, then you’re good to go:


Under the hood, the Android app receives the JSON message we saw earlier in the browser, and is rendering it as a Toast message.

Now click on the Refresh From Server button, and the list should fill with data:


And that’s how you connect an Android app to an application running in the Cloud!

The developerWorks recipe has the steps broken down in much more detail, so be sure to check that out.

That’s all for this episode of Java News and Code.

Make sure to visit the show notes page, click the subscribe button, and you’ll be notified each time a new episode comes out!


Injecting Parameters into JUnit 5 Unit Tests (@ Baeldung.com)

Check out my first (hopefully of many!) post at Baeldung.

The post is called: Inject Parameters into JUnit Jupiter Unit Tests

If you’ve been wanting to make the move to JUnit 5, now is the time! JUnit 5 Release Candidate 2 is out (as of this writing), and the final release is getting closer every day!

I love writing about software testing. I believe as developers we don’t pay enough attention to unit testing (myself included), so it’s important to me to get the word out: unit testing is important!

There, I said it.


p.s., Keep checking back here for more information on JUnit, including tutorials, like this one I wrote for IBM developerWorks.