control flow in javascript using async.js

For those who are new to node.js, Async.js library provides us with some cool functions for the control flow and for performing some functional operations like map,reduce,filter etc. In this post we will dig into the async.series function.

async.series is useful if we need to execute few functions one after the other.   async.series takes an array of functions and an optional callback function which will be called once all functions are executed.Each function will be passed a callback function and the callback needs to be called upon completion. Below is the example from the documentation.

function one(callback) {callback();}
function two(callback) {callback();}

async.series([one,two],function(err, results){
// results is now equal to ['one', 'two']
});

Below is the basic implementation of async.series . It is simple function which takes an array and the optional callback as arguments.

function asyncSeries (fnArray,finalCallback) {
     if (fnArray.length) {
         var fn = fnArray.shift();
         var callback = function (err) {
          if(err)
            finalCallback(err);
          else
           asyncSeries(fnArray,finalCallback);
         };
        fn(callback);
    }
    else {
      finalCallback();
    }
}

Saying goodbye to bookshops

Visiting Crossword, Landmark or Walden stores was my traditional way to buy books. Although i have tried  infibeam and flipkart to buy books i was more comfortable going to the book store to buy books. 

Recently i have been more active on flipkart website and been ordering books online. I have been getting great deals on the books which are not being matched at the offline stores. The service provided by flipkart is also awesome and i have been buying more books online. Looks like i wont be going back to bookshops. 

Using webcam in kopete

Kopete is an instant messenger supporting AIM, ICQ, Windows Live Messenger, Yahoo.
Kopete supports yahoo webcam and it works seamlessly. Although it doesn’t work right away after installing kopete. If you try to access anyone’s webcam you’ll get the following error.

Unable to find the Jasper image conversion program.
Jasper is required to render Yahoo webcam images.
Please see http://wiki.kde.org/tiki-index.php?page=Kopete%20Webcam%20Support
for further information.

You can fix it simply by installing jasper packages available in Ubuntu repositories:

sudo apt-get install jasper libjasper-java libjasper-runtime libjasper-dev libjasper1

Google launches Java tools

In early August, Google acquired Instantiations, a company known for its focus on Eclipse Java developer tools. Yesterday it has announced it is relaunching the Instantiations products under the Google name and making them available to all developers at no charge.

GWT Designer
Powerful Eclipse-based development tools that enable Java developers to quickly create Ajax user interfaces using Google Web Toolkit (GWT)
CodePro AnalytiX
Comprehensive automated software code quality and security analysis tools to improve software quality, reliability, and maintainability
WindowBuilder Pro
Java graphical user interface designer for Swing, SWT, GWT, RCP, and XWT UI frameworks
WindowTester Pro
Test GUI interactions within Java client rich applications for the SWT and Swing UI frameworks

Google is also planning to unify all the tools into a Eclipse plug-in. You can download them here.

Flex Focus issue

I came across an interesting bug which is reproducible only in IE6 and IE7.  I have a web page which has a SWF file embeded.  There is a IFRAME  in that web page and that IFRAME contains a HTML input field. There is also a Flex Text Field in the SWF file.  Now the issue is the flex text field is not gaining focus after clicking on the HTML input field. There is a bug which was filed with adobe but closed without any resolution.

The SWF file and the HTML file are in two layers in the browser and focus is not getting passed to the SWF file from HTML in a IFRAME. So as a work around i needed to set the focus using javascript.

//Flex code
 private function gainCursor() : void
 {
      var textID:* = focusManager.getFocus() as TextInput;
      if (textID is TextInput)
         {
            ExternalInterface.call("deFocus");
            focusManager.setFocus(IFocusManagerComponent(textID));
         }
 }

// javascript function
function deFocus()
 {
      window.focus();
      window.document["YourSWFFilenamehere"].focus();
 }