Thursday, April 17, 2008

Green Earth? Where are we heading?

Its time we ruminated further over our chances of creating a greener & healthier planet. With the economic rise globally, its tough to minify on the emission & pollution control front. The emerging world economies, while gaining pace towards development have forgotten what menace we are upto, if we are not able to control our environment.

Developing countries, particularly India & China have been polluting the environment in the race for supremacy as global economy drivers. The harm that we are doing to the climate via the industrial emission, vehicle pollution, waste production, etc is not being conceived at a granular level. Will we have a planet to live in 100 years is a question unanswerable by even the most experienced scientists & individuals. The smoke, pollutants, gas, etc is producing enough trauma for our environment. 80% of this destruction is being caused by the the top 17 developed/developing nations.


In the most recent climate control seminar where all the major economic leaders participated, it was decided not to let go off of this severe menace silently biting our planet. Has this been taken seriously by all is still a question. The consequences at the granular level in these nations will clearly answer for itself.

Folks, its time we agree on it & take a step forward to save future lives. How can we? The initiative has to come from within us & further more from our government.

Tuesday, April 15, 2008

An Amazing Vacation !

This winter we planned for a trip to a hill station! Well, you would say what a bizarre idea but fortunately it turned out to be an amazing experience (even though it was dead cold on the hills ;-) ). Our trip lasted 10 days from Kolkata to Delhi through Shimla/Manali & back to Kolkata. Even though it was quite a hectic tour, yet we enjoyed every moment of it. Each destination we visited was unique in its own way & had its own enamor & enchantment. Right from the moment we had a sight of the all so special Taj mahal at Agra to the bright & fresh snow covers of the peaks of Manali, it was a treat for the eyes.

It was my third visit to the Taj but the Taj Mahal in all its grandeur mesmerized me yet again with its architectural & romantic beauty. The dainty looks & the grandness of the monuments becharms every tourist.

Manali on the other hand fascinated us with it vividly brilliant snow covers. The beauty of the mountains intrigues me due to its physical & natural attributes. The change of climate & weather refreshed my mind & body away from the hustle & bustle of the polluted cities.

Given a chance & a welcome break, I'll surely shoot for another trip of a hill station - perhaps not during winter ;-) !

Here are some wonderful captures of the trip.

Wednesday, April 9, 2008

Introduction to Spring

I believe that Spring is unique, for several reasons:

* It addresses important areas that many other popular frameworks don't. Spring focuses around providing a way to manage your business objects.

* Spring is both comprehensive and modular. Spring has a layered architecture, meaning that you can choose to use just about any part of it in isolation, yet its architecture is internally consistent. So you get maximum value from your learning curve. You might choose to use Spring only to simplify use of JDBC, for example, or you might choose to use Spring to manage all your business objects. And it's easy to introduce Spring incrementally into existing projects.

* Spring is designed from the ground up to help you write code that's easy to test. Spring is an ideal framework for test driven projects.

* Spring is an increasingly important integration technology, its role recognized by several large vendors.

The Spring framework is a layered architecture consisting of seven well-defined modules. The Spring modules are built on top of the core container, which defines how beans are created, configured, and managed, as shown in Figure below:


Each of the modules (or components) that comprise the Spring framework can stand on its own or be implemented jointly with one or more of the others. The functionality of each component is as follows:

* The core container: The core container provides the essential functionality of the Spring framework. A primary component of the core container is the BeanFactory, an implementation of the Factory pattern. The BeanFactory applies the Inversion of Control (IOC) pattern to separate an application's configuration and dependency specification from the actual application code.

* Spring context: The Spring context is a configuration file that provides context information to the Spring framework. The Spring context includes enterprise services such as JNDI, EJB, e-mail, internalization, validation, and scheduling functionality.

* Spring AOP: The Spring AOP module integrates aspect-oriented programming functionality directly into the Spring framework, through its configuration management feature. As a result you can easily AOP-enable any object managed by the Spring framework. The Spring AOP module provides transaction management services for objects in any Spring-based application. With Spring AOP you can incorporate declarative transaction management into your applications without relying on EJB components.

* Spring DAO: The Spring JDBC DAO abstraction layer offers a meaningful exception hierarchy for managing the exception handling and error messages thrown by different database vendors. The exception hierarchy simplifies error handling and greatly reduces the amount of exception code you need to write, such as opening and closing connections. Spring DAO's JDBC-oriented exceptions comply to its generic DAO exception hierarchy.

* Spring ORM: The Spring framework plugs into several ORM frameworks to provide its Object Relational tool, including JDO, Hibernate, and iBatis SQL Maps. All of these comply to Spring's generic transaction and DAO exception hierarchies.

* Spring Web module: The Web context module builds on top of the application context module, providing contexts for Web-based applications. As a result, the Spring framework supports integration with Jakarta Struts. The Web module also eases the tasks of handling multi-part requests and binding request parameters to domain objects.

* Spring MVC framework: The Model-View-Controller (MVC) framework is a full-featured MVC implementation for building Web applications. The MVC framework is highly configurable via strategy interfaces and accommodates numerous view technologies including JSP, Velocity, Tiles, iText, and POI.

Thursday, March 13, 2008

Social Networking - How Safe Are We !

Misuse & abuses of social networking sites is nothing new & we have been an audience to several instances of such cases through the daily newspapers & journals. Well, every action has some reaction & hence if you are seeking for glamor & publicity, you ought to dodge the hurdles!

In relation to the recent phenomenon of Social Networking websites, it appears, that individuals are more concerned with the aspect of socialising than being “let alone” on the internet. An immense amount of personal information is uploaded by users onto these websites, and this indicates an apparent lack of concern for privacy. However, privacy issues bear importance only when privacy is breached, and when the socializing no longer allows for a personal life.

The question of the liability of the website or an individual for a breach of privacy only arises once we establish that there is information on these websites which is liable to be misused. The broad range of information provided on these sites ranges from the type of information revealed or elicited often orbits around hobbies and interests, but can stride from there in different directions.

These include: semi-public information such as current and previous schools and employers (as in Friendster and Facebook, private information such as drinking and drug habits and sexual preferences and orientation as in Orkut and open-ended entries as in LiveJournal.
While users’ have an apparent control of the sharing of their personal information, this extends only to viewing by other users (which in itself poses several threats to privacy as discussed later). The information once in the possession of the site, is itself liable to being misused by third parties who come in contact with the owner of the websites. For example, the privacy policy of both Facebook and Orkut, contain a Section on the sharing on personal information with third parties and allow for this in the ambiguous terms of “to provide you with a better experience and to improve the quality of our services.” Facebook also states that "We may be required to disclose user information pursuant to lawful requests, such as subpoenas or court orders, or in compliance with applicable laws. We do not reveal information until we have a good faith belief that an information request by law enforcement or private litigants meets applicable legal standards. Additionally, we may share account or other information when we believe it is necessary to comply with law, to protect our interests or property, to prevent fraud or other illegal activity perpetrated through the Facebook service or using the Facebook name, or to prevent imminent bodily harm. This may include sharing information with other companies, lawyers, agents or government agencies. ”

Thus, having established, that all of the information users upload on Social Networking Websites is not necessarily only accessible to other users, but to unknown third parties who may use it to monitor customer habits , it is the submission of the researcher that there is breach of privacy and an unreasonable intrusion into ones personal life on these sites.

Shared by one of my friends !

2D arrays in Javascript

Folks, here is an example of creating a 2D array in javascript:

var polygon = Array(10);
for (i=0; i <limit; i++)
polygon[i]=new Array(10);

Here, 'polygon' is a 1D array. Each array element of this 1D array is initialized to be arrays which

subsequently makes 'polygon' as a 2D array.


Keep posting... :)

Wednesday, March 5, 2008

Does networking sites make profit?

Social networking sites like Facebook/Orkut does benefit by increasing users, how?

1. The higher the users, the more coverage each ad gets. These sites get ads from ad providers & have a robust ad tracking software which tracks the ad coverage, frequency, benefit for ad provider in addition to a plethora of other factors. Hence if ebay provides an ad on facebook, ebay will have an ad tracking software to understand the advantages ebay is having by placing ads. Users click on the adverts on the site & get lured to buy products sometimes. The discussion goes on how ads help in form of banners/lists/flash on sites.

2. These sites track user's behaviour & deliver specific ads which in directed towards each individual depending on his/her behaviour. Thus, the success of ads being potential increases.

3. Today, such networking sites are just one of the many applications provided by software giants. Like Google having orkut, Microsoft having Myspace, etc etc. What they try to do is to maximize users in order to market themselves & attract those users to other products of their's like mail apps, chat apps, etc etc. After all. its an era of marketing gimmicks !

The most popular of the ad provider/consumer products are offered by Google. These are adsense & adwords.

Keep adding inputs.

Tuesday, March 4, 2008

What is Web 2.0?

Since a long time there has been quite a lot of confusion on the definition of Web 2.0. Exactly, what is it? The confusion is caused due to various reasons. One of the major reasons is that whenever anything new comes up in technology, people tend to derive the source of the invention assuming that its something new & fresh. Well, thats not the case with Web 2.0 - it was always there. Just the way its being consumed now has made headlines and brought the buzzword Web 2.0 in the forefront of application developments.

Conceptually, its a knowledge-driven environment. Its the idea, the way, the process rather than anything solid & real and delivers user-rich interactivity. It is also a marketing gimmick to focus on the Web 2.0 techniques in order to collaborate & deliver such contents.

Web 2.0 sites often feature a rich, user-friendly interface based on Ajax, Flex or similar rich media.

The features of this buzzword are:
  • Rich user experience
  • User participation
  • Dynamic content
  • Web standards
Some of the technologies used to render Web 2.0 applications are:
  • Html / javascript / ajax
  • Flex / java / silverlight
  • Tags / meta data
  • Cascading style sheets
  • Xml / json based api
  • Weblogs / blogs
  • Syndication feeds in rss / atom
  • Wiki
  • Mashups
Google is perhaps the pioneer of Web 2.0 but they did not invent Web 2.0. They made use of such techniques which later got termed as standards for Web 2.0 experiences.

This is the definition from my end - will appreciate & acknowledge inputs.

Sunday, March 2, 2008

Flex cross-domain security problem

In this blog I comment on one of the hurdles I faced while executing flex-flash based apps on the net. By a thumb rule flash apps cannot directly access outside urls. I was in this case trying to consume some feed urls for my site and had a hard time understanding the problem initially since I was relatively new to flex.

I had come across the Flash cross-domain security problem & hence my flex apps were not able to connect to outside urls. This is one of the security features on the internet to disallow direct flash access to resources.

There are two ways to avoid this:
1. To allow access to the flash app by giving permission in the crossdomain.xml of the site being accessed.
2. Indirectly access the resources via a php/asp script.

The first option is not feasible since none of the site will expose holes in their security by allowing access to flash apps.

Here, I write about the second feasible option whereby we access the resource (rss feed / web service) via a php/asp script. This PHP script takes a "url" parameter, which is the XML file (or XML-RPC service) you are trying to reach. If you're trying to load http://rss.google.com/rss/topstories.rss, the new url you would access would be something like:
http://www.my_website.com/xml_proxy.php?url=http://rss.google.com/rss/topstories.rss.

Here the name of the php file having the script is xml_proxy.php.

Here is the content of the php file:


$post_data = $HTTP_RAW_POST_DATA;

$header[] = "Content-type: text/xml";
$header[] = "Content-length: ".strlen($post_data);

$ch = curl_init( $_GET['url'] );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

if ( strlen($post_data)>0 ){
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}

$response = curl_exec($ch);

if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
print $response;
}

?>

This is a simple script taking the url as the input parameter, hits the remote server, gets the response & prints it out to be consumed by our flex app.
By the way, do remember that your hosting web server should support php executions. Even I got this script from one of the sites on the net. Cheers !

Thursday, February 28, 2008

Google Sites finally launches in Google Apps

Google has finally launched Google Sites. This product comes after buying the wiki company - JotSpot sometime back. They have bundled it with Google Apps & I managed to see the changes today on my extended website on google apps. Its very much like any other web based page editing tools primary having two main features:

First, you can set it up so anyone you want can edit a Google Sites page (or you can keep it private).
And second, it records all changes and lets you change things so you can un-do these edits.

This serves the purpose of multiple people editing pages or creating sites. Also, you dont have to know html in order to publish pages through Google Sites. Google Sites makes it easy to embed other elements from its Apps or Doc suite, including spreadsheets and presentations, and also YouTube videos and iGoogle widgets!

Finally, its Google yet again with a feature packed tool bundled into their spectrum of innovative products. Go Google Go !

J2ME - Item State Listener

How can you find out when the value in the TextField has been changed?

You must use the ItemStateListener interface and register the listener to the form. The easiest way is to implement ItemStateListener on the form that contains your TextField and put your code into the itemStateChanged method.

class MyClass extends Form implements ItemStateListener
{
public MyClass()
{
setItemStateListener(this);
}

public void itemStateChanged(Item item)
{
...
}
}

Another approach would be to create an anonymous class and register it with the form:

public class MyClass extends MIDlet
{
public void startApp()
{
Form form = new Form("My Test");
// an anonymous class
ItemStateListener listener = new ItemStateListener()
{
public void itemStateChanged(Item item)
{
// do something
}
};

// register for events
form.setItemStateListener(listener);
...
display.setCurrent(form);
}
}


This is just one of the concepts of J2ME I have been learning for the last few days. Will keep posting more...

Sunday, February 24, 2008

J2ME Mobile Network Usage - Avoid deadlock

Avoid deadlock situations while connecting to network resources from mobiles. I used to get the following warning while trying to use network resources during a j2me application development:

Warning: To avoid potential deadlock, operations that may block, such as
networking, should be performed in a different thread than the
commandAction() handler.

Here is the way to counter this problem by using a separate thread in order to connect to the network. This ensures avoidance of deadlock situations in your application. In the run method I am calling the getConn() method which connects to the network resource. The next switchDisplayable method was a business requirement to goto the next screen.

new Thread(new Runnable() {

public void run() {
try {
getConn();
switchDisplayable(null, getWaitScreenRegRoom());
} catch (Exception e) {
}
}
}).start();


Comment with better approaches.