Creating a simple state CRUD REST Service using NodeRed on Bluemix

This is my first article and video in my BlueMix series. BlueMix is an amazing platform where you can get a highly scalable solution up and running very quickly. Because there is so much to BlueMix, I figure I would start off with something simple but useful. A state storage and retrieval service. A simple REST API based on JSON implemented as a NodeRed application on the IBM BlueMix platform. We will be doing the CRU of CRUD (create, read, update, delete), so no delete in this first stab.

The first flow is the “Store State” which is an HTML POST that takes this JSON object:

"_id": "eb7c844a07e4ad183df6e7921498c898",
"_rev": "8-47b75155b16372e040ec9803c550b91c",
"key": "BobBalfe","state": "0"

Don’t get intimidated by the complexity of that because you actually get most of that information from the get state flow below. But first lets look at the store state flow:
Screen Shot 2016-03-29 at 10.44.19 PM

Now we could just slam that information right into the database but I don’t like doing that without at least one or two checks prior. The switch statement takes care of that, I basically require a “key” property in the JSON in order to continue. Otherwise I take the entire load, with the unique key, and store it. If no key is specified the original load is sent back to the caller with an error:

Screen Shot 2016-03-29 at 10.45.10 PM

Now for the easy part, the “get state” REST call. This takes a very simple load:

     "key" : "some big unique key"

Yep, thats it. And if you have an entry in the database you will get an array with a record back, otherwise you will just get an empty array. This is because I am really not doing much in this flow. I pass the load into a function that constructs the search string, pass it on to the Cloudent search node and pass that functions results to the caller – pretty basic.

Screen Shot 2016-03-29 at 10.49.26 PM

Well now you can see me walk through how this flow was constructed with Larry commentating on the side.


Simulate a mouse click using Dojo with Larry

The next video in the Dojo series where I go through animating a mouse click with Dojo. The key functions used are the Dojo query and fx.animateProperty functions. Larry was pretty talkative in this one, he even answered me a couple of times.

Click here for the JSFiddle

Simulate moving a cursor in Dojo with Larry

Larry is definitely settling in on the perch with the green screen. I always have snacks in his bowls and he hasn’t touched them much. I guess he decided to sit by and snack while we record.

Continuing on from the previous video here we implement a moveto function in our simulator.  There is one fix in the code, I removed these two lines as I realized I did not need them:

var l = Math.round(aPos.x);
var t = Math.round(aPos.y);

Check out the jsFiddle here.


Simulate typing text using Dojo with Larry

This was a pretty funny video, Larry is definitely becoming more comfortable in front of the camera. He says a lot of new phrases and a couple of swears in this one.

So this is the first part in a three part series where I essentially do the same thing I did in the jQuery series. One difference is I start with the typing text emulator. With the Dojo query API it is very easy because it uses the same CSS3 convention jQuery uses.
Click here for the jsFiddle


The new for loop in jQuery 3

Love the fact that the for loops are now iterations in jQuery. The old way of doing loops like this:

var $elements = $(".myclass");
for (var x=0; x< $elements.length; x++){

Can now look like this in jQuery 3:

var $elements = $(".myclass");
for (var element of $elements){

Simulate Typing Text using jQuery with Larry my parrot

This was the first time I recorded Larry at the same time I recorded myself doing a lesson. Let’s just say he didn’t say what I wanted him to say. Too many F-U’s in this one. The good thing is he doesn’t say the word, he actually says the letter F then the letter U. Either way, its pretty cool how easy this was to do and I am sure Larry will be saying a lot more as he gets comfortable in his new setting.

On to coding and the video!

Continue reading “Simulate Typing Text using jQuery with Larry my parrot”

Simulate a Press with jQuery Animate using JSFiddle

In this video I demonstrate how you can simulate a cursor press using jQueries animate API in JSFiddle. By cube mate Larry made some announcements in this video and since he often speaks I decided to include him in some of them and translate what he is saying. He for some reason just keeps saying the word “four”…

So, I digress, I ended up having a double call to animate, where once the cursor is shrunk, we call the click action and then do an additional animate to restore the cursor to its original size. You can mess with the 500 millisecond delay to have a slower press or a faster press. Make sure you check out the JSFiddle!


Animating a Cursor with jQuery and JSON

A followup to the last video, I take the same concepts as before but now I generalize the steps into a JSON array. The JSFiddle code then executes those actions in the array.

In the code I show how to use a recursive function with the window.setTimeout call and ending the animation once the entire array is processed.


Animating a Cursor with jQuery

This video is about using jQuery and the animate API to move a graphic (cursor) from one location to a DIV, then simulating a click event on that DIV. This allows you to instrument tutorials within your web applications. Stay tuned for more on that!

You can see the JSFiddle code below:

Click here for the JSFiddle!

Blog at

Up ↑

%d bloggers like this: