For Loop Array of Javascript Objects

var dog1 = {name:”frank”, breed:”mix”};

var dog2 = {name:”abby”, breed:”mix”};

var dogArray = [];



I have found some JavaScript engines are OK with this:

for(var x = 0; x < dogArray.length; x++){

But many are not, and it needs to be declared as:

for(var x = 0; x < Object.keys(dogArray).length; x++){


Docker Commands

#see running containers
docker ps
#kill a running container (use CONTAINER ID)
docker kill d4930c9b409a
#list all images
docker images -a
#remove an image (use IMAGE ID)
docker rmi -f 3dcfe809147d

#run without connecting into bashdocker command

#start the container in an interactive mode -i -t. In our case, we will override the entrypoint command so we are presented with a bash terminal. Now we can execute whatever commands we want, but exiting the container will stop it

docker run -i -t –entrypoint=”bash” imagename

SSL Certificate Not Working Localhost

This morning my machine updated and Chrome no longer saw my SSL certificate as valid. it was complaining about a SAN (Subject Alternative Name). Through the following links, it became apparent that Chrome had updated. Using the following links, I was able to come up with the step by step guide to resolving the issue.

  1. Delete the existing key with the following command:

keytool -delete -alias -keyalg RSA -keystore “C:/Program Files/Java/jdk1.8.0_45/jre/lib/security/cacerts”

2. Generate a new key with a SAN (Subject Alternative Name) with the following command:

keytool -genkey -alias -ext -keyalg RSA -keystore “C:/Program Files/Java/jdk1.8.0_45/jre/lib/security/cacerts”

3. Restart the machine

4. Open Chrome, Chrome Settings > Show advanced settings > HTTPS/SSL > Manage Certificates. Delete the existing certificate from the ‘Trusted Root Certification Authorities’ and ‘Trusted Publishers’ tabs respectively. If you are creating your first SSL certificate on your localhost, you can skip this step (step 4)

5. Restart Chrome

6. Navigate to the HTTPS page and press F12 to open dev settings, open the security tab and View Certificate

7. Export the certificate and name it (or whatever your alias is)

8. Open Chrome, Chrome Settings > Show advanced settings > HTTPS/SSL > Manage Certificates. Import the new certificate to the ‘Trusted Root Certification Authorities’ and ‘Trusted Publishers’ tabs respectively.

9. Restart machine

Updating Your Local SSL Certificate

Previously: Create SSL Certificate for HTTPS localhost on Tomcat 7 Chrome and Internet Explorer

The local certificate will expire after 3 months. here is how to update it.

1.Inspect your tomcats’ server.xml file to see what java it is using. So lets say it is using:
C:\Program Files\Java\jdk1.XXX
2.Delete the expired certificate with the following command:
keytool -delete -alias -keyalg
RSA -keystore “C:\Program Files\Java\C:\Program Files\Java\jdk1.XXX\jre\lib\security\cacerts” – the password is by default changeit
3.restart the machine
4.generate a new cert with the following command:
keytool -genkey -alias -keyalg
RSA -keystore “C:\Program Files\Java\C:\Program Files\Java\jdk1.XXX\jre\lib\security\cacerts”

You are now asked to enter your name. enter your name as whatever value your alias is. In my case I entered the name as
5.Copy the certificate which you have generated:
Attempt to navigate to the secure section of your site. For me, it was (Note the HTTPS protocol):
Using the 3 dot menu, more tools, developer tools, security tab, and Click the Certificate Information > Details tab > Copy To file > Export. Save it as the defaut .cer file type. Save it with the same name as you alias. For me this file is named:
6.Create an entry in the trusted certificate publishers directory of your machine
Open a command window and type
Expand the ‘Trusted Publishers’ directory. Using the menu bar, select action >All Tasks >Import, and import the file you created in step 4. Repeat this process in the ‘Trusted Root Certification Authorities’ directory.
7.Restart your machine.

Stop seeing the ‘Form Submission’ when you click back

You need to familiarise yourself with the PRG ‘design pattern’


Post-Redirect-Get Pattern in Spring MVC

Cloudinary, jQuery and HTML to upload image

I have found the Cloudinary documentation poor. Here I have listed the code and steps to upload images to your cloudinary account using jQuery.




HTML and jQuery

<!DOCTYPE html>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
<title>JSP Page</title>


$(document).ready(function () {
// $(“#cloudinary-input”).attr(“data-form-data”, jsonData);
console.log(Math.floor( / 1000));
function upload() {

var params = {
api_key: ‘1112222’,
public_id: ‘samplepublicid’,
timestamp: ‘1448741653’, //Math.floor( / 1000);,
cloud_name: ‘mycloudname’,
signature: ‘9a19e11286b77e7e4f9ba2cb1f8dd4cb40cd67bc’


var input = $(“#cloudinary-input”);
input.attr(“data-form-data”, JSON.stringify(params));
input.bind(“fileuploaddone”, function (e, data) {
input.fileupload(‘option’, ‘formData’).file;
input.fileupload(‘add’, {files: document.getElementById(“cloudinary-input”).files});

function test(data){


<h1>Hello World!</h1>
<form >
<input id=”cloudinary-input” name=”file” type=”file” class=”cloudinary-fileupload”
data-form-data=”” />
<input id=”image_upload” type=”hidden” value=””/>
<input type=”button” value=”Upload” onclick=”upload()”/>
<div class=”.cloudinary-fileupload” src=””/>

Ok, that is the base. Now read this:

You need to download the jquery files listed below and put them in the head of your HTML file. You can get them from Cloudinarys jQuery github js directory here. Make sure you have the src attribute pointing to where you’ve downloaded them.


You need to customise the value of the ‘params’ object to match your own. A guide to where you can find the values is here:

  • api_key – You can see this in your cloudinary dashboard.
  • public_id – An optional attribute, make it up.
  • timestamp – This is a unix timestamp. you can generate it with the following javascript: Math.floor( / 1000); YOUR TIMESTAMP CANNOT BE MORE THAN 1 HOUR OLD
  • cloud_name – This can be seen in your cloudinary dashboard too, at the time of writing, I saw it in the top right hand side of the screen.

Generating a Signature for Cloudinary jQuery Call

  1. lay our the parameters you are using in a string as such: public_id=samplepublicid&timestamp=1448741653. The format is key=value&key=value. They must be in alphabetical order.
  2. In the cloudinary dashboard, find your ‘API Secret’. Assume my API secret is: ‘glenirissecret’.
  3. Tag your secret on to the end of your newly formed string, eg: public_id=samplepublicid&timestamp=1448741653glenirissecret
  4. Generate a SHA1 hash code. You can Google PHP or Java code to do this, however, you can also use this site to do so:
  5. You should now have a hash value of 9a19e11286b77e7e4f9ba2cb1f8dd4cb40cd67bc
  6. The hash code you generate is now the value of your signature param.
  7. Substitute into your values to my code above and refresh the HTML. Upon uploading your image, you should see an alert box with ‘succcess’!

With inspiration and help from:

Cloudinary Support Form

Telerik Forum

Apache Tomcat fails to start from Netbeans


Log Message:

‘’ is not recognized as an internal or external command,
operable program or batch file.

The solution is taken from Stack Overflow with thanks to Sudeepta

I have faced the exact problem in apache-tomcat-7.0.56 and apache-tomcat-8.0.14 with netbeans7.4 and netbeans8. I installed tomcat from zip file. I fixed it by changing catalina.bat file in tomcat bin directory.

Find the bellow configuration in your catalina.bat file.



Just remove the double quotes



Now save and start your tomcat from NetBeans. It works for me in apache-tomcat-7.0.56 and apache-tomcat-8.0.14.