Saturday, November 24, 2012

The Universe and Our Solar System




Solar System is pretty much everything found around the Sun, which includes the Sun, planets, satellites (moons), asteroids, comets and anything else that is the area (dust and debris is pretty much all that remains). Scientists around the world are doing various observations and  tests to understand the birth of the solar system and the universe plus what the future would be for our sun and the universe. The discovery of ‘Higgs Boson’ in July this year completed the missing puzzle for most of the questions that scientists had about various speculations about the birth and evolving process of the universe. On top of all this the universe is full of various picturesque astronomical objects like quasars, black holes, galaxies, star nebulas, etc..

The power-point slide show that is attached here is a modified version of the presentation done by me at the Inaugural IFS TechIgnite event that was held on 9th November 2012 at Waters Edge, Battaramulla.

More details about the content of this slideshow will be added to this blog post later on. 


Generating the Email content with a Template based mechanism

Emailing is one of the most critical as well as important functionalities in any software service or a system. Furthermore the email content may well change depending on the issue you are addressing at a given time. Having to handle such scenarios via the code could be messy and it would take lot effort to maintain such a code. Furthermore when new email content gets added or the content of an existing email format changes, then you may have to go into the code level to do the necessary changes.

To overcome the above mentioned drawbacks it would be really great if there is a way where we can feed the email format as a template from outside, bind the relevant information to the template variables via the code and at the end convert the template into the email body. In one of the ongoing projects in our team we had exactly the same requirements as well as the same drawbacks. So in order to find a good solution to this I did some Goggling and tried to find out a way where we can get things done through a template based mechanism.
 The two prominent solutions that appeared in the search results were ‘FreeMarker’ and ‘Apache Velocity’. After going through each of them I noticed that ‘Apache Velocity’ fulfills all our requirements and resolves all our drawbacks.

‘Velocity’ is a Java based project that operates under Apache and like many apache projects ‘Velocity’is backed up by a pretty strong development and user community.
 Apart from supporting template based email content generation it also supports the features that are listed here. 
  •  Servlet-based Web applications 
  • Java and SQL code generation
  • XML processing and transformation
  • Text processing, such as RTF file generation
Mentioned below is a quick description on how velocity can be adapted in to your project. This is a screenshot of a template that is used by Velocity. The template file extension is ‘vm’. 



It is a template that supports HTML based content; therefore you have the option of formatting the outlook of your email body in whatever way you want. Furthermore it supports basic programming stuff like for loops,foreach, if-else statements, etc... This makes the template much easier to generate.




After initializing the velocity engine you can bind the values to the variables in the template as you are adding items into a Java hash map through the ‘VelocityContext’ object. 


When adding content to the HTML table, its rows should be added to a Hashmap where number of elements in the hashmap would represent the table columns. Then each row(HashMap objects) should be added to a ArrayList and then as the final step that array-list object should be added to the context object .

After filling the variables in the template now it is time to convert the template in to something that can be added to your email body.


Now the template with its bound variables is filled in to a StringWriter which can be used as the body of your email.
When using the downloaded Velocity.jar as a library of your project you need to have couple of runtime libraries from the Apache-Commons library collection (commons-collections-3.2.1.jar, commons-lang-2.6.jar).  For those who are not so familiar with apache-commons it is a collection of reusable Java components, which has libraries for scenarios like String manipulation, Database operations, logging and many more.
In case you need more information there are lots of articles in the internet for Velocity as well as for Commons.

Saturday, July 14, 2012

Software and Interesting Times ahead

Welcome again..
In this blog post we will try to bring forward some information about programming languages and how there futures are planning. In here we will do an analysis on two of the most widely used languages  in Java and C#. How their future plans out could be a decisive factor when we think about programming in the next 5 years to come. Being the two most familiar programming languages to me I think I have fairly good idea about how each one of them operate. This post will not be a highly technical one, but something that would do a more of a comparison in to these programming giants Java and C#.

When considering the history of these two, both these languages have evolved a lot during the last decade or so. And it is fare to say that both languages have their strengths and areas where they have an edge over the other. Both being Object Oriented Programming Languages, both provide rich array of libraries for the developers to use. As for the current stable versions of the respective languages Java has SE7 where as C# has 4.0 which was released along side Visual Studio 2010.

Saturday, May 26, 2012

Inspiration and Taking up Challenges

First I must convey that I am no positive thinking guru or anyone who had studied deep in to this area. These are some thoughts that came into my mind and here I try to express them using a simple real world scenario. 

Let me ask me you a simple question first, who is the most inspired person in your life. For many it would be their parents. And for some young people it could be Bill Bates, Steve Jobs or any other successful businessman. If I give you my answer to that same question, mine is somewhat different, he is neither a businessman nor IT guru. His name is ‘Lance Armstrong’. And he is a cyclist. Well if some of you have already heard about Lance and his life you might have already guessed what I am trying to bring up here.

“On October 2, 1996, then aged 25, Armstrong was diagnosed as having developed stage three testicular cancer (Embryonal carcinoma). The cancer spread to his lungs, abdomen and brain. On that first visit to an urologist in Austin, Texas, for his cancer symptoms he was coughing up blood and had a large, painful testicular tumor. Immediate surgery and chemotherapy were required to save his life. Armstrong had an orchiectomy to remove his diseased testicle. After his surgery, his doctor stated that he had less than a 40% survival chance.” Source Wikipedia

In middle of all this ambition to competitive racing didn’t disappear. After discovering the cancer, he competed in many races and won. His famous victories being the 7 Tour de France titles from 1999 to 2005. The point that I am trying to bring out here is that many of us face different problems in our lives at different stages. That could be either family matters, issues related to your work place or any other problem. We might get direct solutions to some while some problems may take a long time to solve; they say “Time is the best healer” isn’t it. The negative aspect of all these is that when many of us encounter such issues we would try hang to those and mess up every other important thing in our lives. I have seen this happen to many people in our time. What I am not trying to say here is to forget everything in your life and start all over everything. The simple way to look at problems is to think that we all are humans. Such things are part and parcel of our lives and try to fight over it.

After getting to know that he has stage three cancer and his death is inevitable Lance Armstrong could have stayed on a bed for the rest of his life without doing nothing. If he had done so he may had received compensation from the government as well. Instead he took the hard way, fought his way through everything and achieved something that so other cyclist has ever achieved. Humans are a very special and very talented kind of species. If a human being put his mind into something and try to achieve it, it could be done easily. Prime example is the Enlightment of Prince Siddhartha. To read the amount of effort he had put in and the kind of sacrifices he had done in getting there just resembles the potential of a human being.

We may only live for 70-80 years, who knows it may be even shorter. So why we don’t want to enjoy life and experience the true beauty of it. Before I wrap this up I just want to give a simple advice, if you are someone who have problems and some who think that your life is in complete misery, just Google for ‘Lance Armstrong’ and go through one of many articles that describes his life. When going through it in a matter of minutes you would realize that the problems you are having are nothing.