Author Archive

tip: Single symfony project serving multiple domains via separate apps

Wednesday, November 5th, 2008

Problem: You have a symfony project with 2 applications ‘customers’ and ‘resellers’. You want www.myretail.com to use ‘customer’ application and www.myresellers.com to use ‘resellers’ application.

here customers app is your default ‘frontend’ app with index.php and resellers app has say ‘reseller.php’ and ‘reseller_dev.php’ controller files.

Solution:
Separate the web folder for each domain you want handle.

so customers content is in /project/web folder and resellers content is in /project/web-reseller/ folder. Move your reseller.php to web-reseller folder and rename it to index.php

You will need to create two virtual host for each domain with document root pointing to their respective folders.

Another solution is to have different .htaccess files. In case you do not want to create separate web folder you can create another .htaccess_reseller file in the web/ folder and redirect all request to reseller.php instead of index.php

Date manipulation using GNU date

Saturday, February 9th, 2008

GNU date command lets you do just about everything related to date and time but date manipulation is something not well documented.

# get date 2 weeks from now
date –date “now 2 week”

# 2 months earlier
date –date “now -2 month”

you can give any date in place of ‘now’ or use a variable.

# what day is it after 10 days?
date –date “now 10 day” +%A

Interesting information from Google trends

Saturday, October 27th, 2007

I was waiting for our designer to show me some htmls so in the meantime I thought of ‘browsing’ Google Trends
I looked at the home page for couple of minutes thinking how can this be helpful, after looking at the listed examples first thing that caught my attention was “Tip: You can compare searches by separating with commas.” and I clicked on “music, fashion, sex“. Ok, so I saw a big graph and the searches per region. India was at number six but what was interesting to see was the orange bar. Indians are googling way more for word ’sex’ than anyone else in the world. It instantly made me think if searches on google are indication of people’s interest then I can find other interesting information for eg.
- Which country is most likely to be shopping online? Gift, shopping US, UK, Australia
- What sells more jewellery, clothes, flowers? - clothes.
- What about India? - Flowers. And guess what punjab is on the top.
- Which country might be having most Java programmers. India and Bangalore on top.
- Which is more common java, .net, php, ruby, python. Java wins by clear margin and again India and Bangalore
- Which place in India might have most struts programmers. Noida and Pune.
- Mysql more famous or postgreSQL Mysql
- Where are most people searching for jobs? India, UK
- Most Kerala people are looking for matrimonial sites.
- Some obvious ones India, Pakistan searches most on cricket and US, Canada on baseball

I couldn’t make sense to following searches.
- Why is India searching for India?
- Also ‘outsourcing’?
- What could this mean? startups

GlassFish Auto Deployment and Hot Deployment

Tuesday, October 23rd, 2007

There are several ways to deploy a GlassFish application. To speed up development/debuging we need a way to instantly deploy web applications. One of the ways is to use hot deployment feature, another lesser known feature is ‘directory deployment’. You simply point GlassFish to your development directory and let it pick up and deploy application from there. No packaging and re-deoploying hassles. The catch is whenever you want to re-deploy your application you just need to ‘touch’ a file called ‘.reload’ which should be present in your web folder.
Following is the command and directory structure you can use.
–|myproj
–|–|src
–|–|web
–|–|–|WEB-INF
–|–|–|–lib
–|–|–|–classes
–|–|–|–web.xml
–|–|.reload

GLASS_FISH_HOME/bin/asadmin deploydir full_path_to_you_web_folder

If you are using Eclipse or NetBeans make sure that they put the class files in web-inf/class folder after compiling.

Evaluating / Comparing NetBeans and Eclipse EE for Java EE development

Friday, October 19th, 2007

Although we are ‘big’ Eclipse fans and have been using it for many years for everything (PHP/symfony, Java, XUL, HTML) and have even contributed plugins but we decided to evaluate NetBeans to see if it gives any extra features that might help/speed up development for our forth coming Java EE project.
Technologies we are going to use in our application are:

Preferred IDE requirements:

  • CVS integration
  • Integration with GlassFish - so that we don’t have to leave the IDE to deploy etc
  • Should support debugging of web application
  • Support for profiling
  • XML/JSP editor
  • Context sensitive help and auto completion for tags

We are comparing
NetBeans 6 Beta 1 and Eclipse 3.3 Java EE

Creating a new web project is pretty straight forward. Both IDEs create more or less same directory structure only difference being the location where Java source files are stored. Eclipse keeps them under src where as NetBeans keeps them under src/java.
Next thing I wanted to do was import (share) my project to CVS. Found it more user friendly in Eclipse although NetBeans was equally straight forward.

JSP/XML Editor
NetBeans editor is lot more advance and friendly.
Editing Web.xml in Eclipse
Editing web.xml in NetBeans

Other differences
- In Netbeans you don’t have to click on ‘fast views’ just mouse over brings the window.

- Can’t easily change destination of compiled class files in NetBeans. We wanted to try directory deployment feature of GlassFish so that we don’t have to create .war every time, this required us to compile and put the class files in WEB-INF/class folder. This setting is pretty straight forward in Eclipse whereas you have to change projects.properties file in NetBeans. (Or it was not easy to find how to change it via UI)

- One of the biggest inconveniences was not having auto import while writing Java Code. Eclipse will auto import a class if you use it (Ctrl+space) but in NetBeans you have to manually add imports. There is fix imports also but thats an extra step.

- Eclipse UI in general is more user friendly. As an example ‘output console’ had a title bar and then some tabs. Each of these tabs are (or at least look) like individual windows with separate x (close) buttons. Its very natural to double click on the title to maximize it, hence you would try to double click on title ‘GlassFish v2′ but it will not do anything. You will have to double click on the bar above it ‘Output’. This is understandable but not ‘really’ as expected. On the other hand eclipse is pretty straight forward.
NetBeans console windowEclipse console window

- Eclipse kept on crashing (giving out of memory error) on my colleague’s laptop which has 1GB RAM, this happens when he tries to run GlassFish from Eclipse. Trying to run GF outside of Eclipse doesn’t crash it. This is actually a show stopper, or he needs to upgrade RAM

- I couldn’t figure out how to auto compile and auto deploy application on NetBeans. Every time you change a class file you need to ‘build’ and ‘run’ or ‘deploy’ on the other hand Eclipse will compile and deploy automatically on save. On the other hand auto deploying can also become a problem when application size grows. But this made it very smooth on Eclipse to build/test.

We also evaluated how to create a project so that it can be opened in both the IDEs so that we can either switch or let programmers choose whatever they want. There was no ‘huge’ difference of features or one IDE helping a LOT. On the other hand as we are comfortable with Eclipse shifting on NetBeans can be counter productive as we have to learn/get used to the new IDE. We know that we will need NetBeans for debugging and profiling but development will be faster with Eclipse using directory deploy and .reload feature of GlassFish.

Visualizr - Yahoo! Open Hack Day Bangalore, India

Tuesday, October 9th, 2007

Over the weekend we went to the open yahoo! hack day at Bangalore ….and what……

Hack Day - visualizr

Here are the ideas we thought of

  1. A service which will take your favorite blogs, your linked in profile or/and your favorite articles as input and create a mash-up of articles you might be interested in from Amazon or images from flickr or events from upcoming. Will also try to make a guess as to what kind of person you are.
  2. Visualizr, what we initially called as pic-story and the one we finally built.
  3. Travel Helper - Give us your travel dates and cities you are visiting and we will tell you what are the events happening during that time on those places and we will also show you interesting pictures from flickr taken in those cities so that you can decide what you want to do if you have free time.
  4. Tell us what you want to buy and we will give you all the relevant information. for e.g. items from different shopping sites, review sites, news, flickr etc
  5. Pictorial how to? Give us step by step procedure of creating or doing anything and we will return the same how with pictures to understand better.

Creating visualizr was fun and we really like the idea as it could actually be applied in lots of things like

  • Make your own cards
  • Build an ad campaign
  • With more comprehensive image access a new way of communication
  • Evolve as a How to tool? Ask 10 questions and see how Images can answer for you
  • May give a whole new way of learning difficult concepts
  • Or just brighten up your day

So what are you waiting for, go check it out visualizr

Service and product innovation - customers can help

Friday, June 29th, 2007

A recent law suit against Dell by the attorney general of New York, says a lot about how important customer service has become. Its interesting to observe that having a good product line alone does not guarantee company’s success, rather what makes a difference is how well you are serving your customers. Innovating on how to service your customers has become as important as innovating on technology and your product.

Innovating in any field is very challenging and when it comes to customer satisfaction it becomes even more difficult because of the diverse and dynamic nature of your customer base. One way of doing this is by involving your customers in the process. Co-create. Taking help of your customers in letting you innovate on your offering, let them tell you what they need and what they don’t. Make them feel as if they belong. This instills a strong sense of loyalty. This is the focus of our new product ValueJini.

FireFox extensions I cannot work without

Tuesday, January 23rd, 2007

Firefox, Eclipse, Thunderbird, Kopete/GAIM, OpenOffice, konsole, tomboy this is where I spent over 95% of my computer time.

Best thing about all these applications/products is that you can install additional plugin/extension/addons to enhance their usage. Following is the list of firefox plugins I use almost daily.

Firebug - A must have, very helpful js/html debugging tool.

Web Developer - Very helpful for finding html/form related problems. Also a good place to learn how to build firefox extensions.

JSView - Lets you view source of externs js, css files. Very handy.

Load Time Analyzer allows developers to measure and graph how long web pages take to load

Server Switcher It allows you to easily switch between sites on your development and live servers Very helpful.

SearchStatus Display the Google PageRank and Alexa popularity score

del.icio.us
Next: Eclipse plugins I cannot work without :)

Why do I use Frameworks and Design Patterns?

Sunday, August 13th, 2006

I have been designing and developing for over 10 years now. I have never worked on same technology for more than 2 years. This gave me oppurtunity to learn new stuff but at the same time it made my job very challenging. Time to market is still a key differentiating factor and in this competitive world where for once money and skills are available in abundance, speed is something which can make you stand tall among the crowd. So how do you develop FAST making sure your design is extensible, your application can handle unlimited change requests, you can scale to increasing demand, you can modify look and feel every x months and lot more :) . How do you design a critical system in less time and still be confident that you are moving in the right direction?

Nothing can replace experience, now if you do not have experience yourself how can you take advantage of other people’s experience? This is where frameworks and Design patterns come.

Framework helps you start fast and Design patterns help you design right and fast. You are confident because you are using a tested and proven solution. When you have to do more in less time you have to pay more attention to issues that can become big later. Design patterns help you identify those too, it lets you identify those issues. Another side-effect of using frameworks / patterns is that it helps you communicate better. This is really helpful when you are working in a distributed enviornment. If both teams have some knowledge of both lots of times its very easy to communicate/discuss a technical problem and their solutions. Frameworks provide you some common set of features that you need in every application like session handling, logging, error/exception handling, i18n, templating etc. Most of the frameworks implement common design patterns.

more on some of the frameworks we use Struts, symfony, RCP

Enabling Java support in PHP

Saturday, March 11th, 2006

Note: This article was written after implementing Java (1.4.2_06) support on PHP 5.1.2 (cli) (built: Feb 28 2006 06:21:15)

As written on php.net there are two ways of integrating:

  1. Integrate PHP into Java
  2. Integrate Java into PHP

We will be talking about “Integrating Java into PHP”. This again can be done in two ways

  1. Re-compile php using –with-java=$JAVA_HOME (Ample of documentation availbale on net on how to compile php)
  2. Use php-java-bridge.

Enabling php-java-bridge is fairly easy and recommended as you wont have to compile php which might be already customised.

  • Get source for php-java-bridge from sourceforge
  • Decompress
  • cd to “php-java-bridge” source folder
  • phpize
  • ./configure –with-java=$JAVA_HOME
  • make
  • make install

This will install libraries in some folder eg /usr/lib/20050922 copy JavaBridge.jar java.so libnatcJavaBridge.so to php modules folder eg. /usr/lib/php/modules restart apache (service httpd restart) Look at out of phpinfo() and confirm that you see “java running” You can either write a php file and access it from your browser or quickly type echo ” | php | fgrep java at command prompt