Welcome all, to my humble abode in this mad digital world ;)

...and so after a long time...
...a random post. could help somebody...

Few things to watch out for while developing browser based apps with cross domain calls.

  • If we have an iframe calling another domain (cross domain calling),
    we wont be able to access the parent window and child window documents from each other.
    Instead, we must use postmessage function to communicate with each other.

    Sender:
    In parent's page:

    
    var ifrm = document.createElement('iframe');
    
    ifrm.onload = function () {
            if (ifrm.contentWindow.postMessage) {
                    	ifrm.contentWindow.postMessage("some message from parent", targetDomain);
            }
    }
    				
    			
    targetDomain: URL to which message is to be sent.
    Protocol, port and hostname should be an exact match of the targetDomain.

    Receiver:
    Now in the targetDomain (in the iframe's page):
    We must have a listener of the type:
    
    addEvent(window, 'message', ParentMessage);
    				
    function ParentMessage(event) { 
    	// This check is a must for sanity and integrity reasons. In a production environment, 
    	// there could be other code doing postmessage (google, facebook etc., does this).
    	// It could interfere with the messages you receive.
            if (event.origin !== OurSourceHostName) {
            	return;
            }
    
    
            //event.data;
    	//event.origin;
    	//event.source;
    
            event.source.postMessage("some message from child", event.origin);
    	// To read this message, the parent window should have a message listener.
    }	
    			
    MDN Postmessage reference
  • When using a local development environment, don't use "localhost" or "127.0.0.1".
    Use some other ip address like 192.168.0.1 or some other private ip block address.
    The reason is that IE and Safari wont send SessionId if you use http GET.

2015-Mar-28

...not sure when the next post will be...

What's the purpose of Artificial Intelligence (AI)?

What's the purpose of Artificial Intelligence (AI)? What will it mean for humans? Robots with AI could eventually take over whatever work humans do. What are humans going to do if Robots do all the work. Perhaps humans will pursue whatever thing interests them. But will it pay? Humans make money by way of work. If robots are doing all of it how will we earn money?

The current way of how one earns a living will be rendered obsolete. The economics has to change. Eventually the whole paradigm of sustenance has to change. Notions like "One has to earn a living/Work is worship etc.," will change.

If you think deep, you could envision that money could be rendered obsolete. But still humans would need sustenance. Will it be given free of "cost"? It will be interesting to see how benevolent humans will be in that scenario.

Some people are worried of a sentient robot rising up against humans. Could that happen? Not sure.

2015-July-04