Monday, February 21, 2011

Kolkata's date with Bloggers, Feb 20, 2011

Feb 20, 2011 was a fun filled day for many bloggers of Kolkata. Probably for the first time here we had two back to back blogging events organized separately in two separate venues. The day for us started at about 12AM with the IndiBlogger's meet, which was carrying the Akshaya Patra Foundation's message across to bloggers in Kolkata and around.

The Akshaya Patra Foundation is a non profit organization which provides mid day meals to students in schools. Its program is the largest of its kind in the world by a non profit organization. Akshaya Patra Foundation wants to spread its message across the world through online media: citizen journalism and word of mouth. Its cause is to solve one of th fundamental issues of our country, the battle of education with hunger. Students from very poor financial background can not continue education since they are more hungry for bread than books. What mid meal programs do is reverse the effects of poverty a little bit by providing healthy, tasty food to children who attend school. This message is very strong and the effort is one which can shape India's future.

With the help of bloggers from around the nation Akshaya Patra Foundation can attract more people (donors or volunteers) to its cause. The IndiBloggers meet gave a chance to all kinds of bloggers to meet and discuss on social, technical and general issues. Networking and launch was of course a part of this. Overall a great meet which ended around 5 PM with a band performance.

Right after IndiBlogger meet we head straight to Salt Lake Stadium grounds where Kolkata Blogger's Meet was to start from 6PM. People had already gathered by the time we reached and introductions rounds were just about to start. The crowd here too was filled with enthusiastic bloggers who were eager to show off their blog and learn from others. We had a few prominent bloggers take the stage and talk on what it meant for them to blog. The variety of bloggers including Android fan boys to poets and everyone in between.

Kolkata Bloggers' Meet had some speakers on the important point of monetizing a blog so people can take blogging as a career option. There were discussions on SEO and content quality of a blog too. Overall a great take back and of course nothing beats the networking in a city which waits a while to get an event. But it seems recently that events are catching up in Kolkata. I am really optimistic about this all and would like to hint there is a plan for a monthly meet for IT professionals which will have design, content and technology tracks. Hurrah for us!

Saturday, February 19, 2011

Buzzwords: Cloud, Mobile, Social

The list of the hottest buzzwords in the industry would certainly include Cloud, Mobile and Social. The impact they each of these have is immense, and when combined they practically are changing our lives. In early days of the web applications (even dynamic websites) the notion of cloud based computing was not as popular as it is now. People had to predict their infrastructure requirements and allocate large budgets upfront for hardware and networking. This meant considerable amounts of funding money (for startups) going into silicon chips and their families. In the last half a decade that has changed dramatically. Scaling applications without budgeting upfront is not just possible, but is being done everyday by so many.

The lowering of upfront costs for startups and the means to handle traffic on shoestring budgets are really empowering entrepreneurs across the spectrum of applications. Large on-demand platform providers like Amazon, Google, Microsoft, Salesforce are leveling the playing field for funded and bootstrapped companies from the technology platform perspective. You can write a data intensive application and actually demo it to a prospective client or launch it publicly without raising much capital.

Mobiles are getting smarter by the quarter (month maybe?). The most recent ones like Motorola Atrix and Samsung Galaxy S II are comparable to Intel Atom based mini laptops from hardware perspective. And on top of it mobiles like Atrix allow you to dock the deice with keyboard, mouse and monitor for a desktop experience. Or take a laptop shell and dock the Atrix for a laptop usage. Same will come out of Samsung and other handset makers very soon. Our working environment thus really shrinks into our pocket. Take your work with you in your pocket, plug into your office keyboard, mouse, monitor and work there. This is again a game changer in the industry.

The last point, social is something which most of us understand better. Being social is a basic human quality. Word of mouth has always worked with us. Now on the web, content that is share-worthy becomes famous. People who are domain experts are becoming our online help-desks. Even corporates are reaching out through social media to the wide audience. But social is yet to touch a few sectors which it should. Like banking, which is still a number based industry. Banking could move to a more social form, where transactions are noted against people, not numbers. Even in its current forms if you join cloud, mobile and social, you immediately get a glimpse of a future that is driven by applications which cater more to "me" and "us"; and are available wherever we need them. The browser is the window to the world. And the browser is mobile, more customized and richer than ever.

Thursday, February 17, 2011

Good code, great code

When you do software development (or any other work for that matter), getting to the first 60% is comparatively easier than the rest 40%. The initial 60% work usual is bulk work, broad plans, overviews from 3000 feet high and all. But the more you cross that mark of broad planning and go into the details, work becomes art. The first lot is almost always science. The last part is true craftsmanship. This is something that any team must consider when they work on projects of any size where quality matters. Of course if you can pass your project with just coarse details then do not even bother to read this blog.

I have myself been programming with web languages (mainly PHP) for the last 7 years at least. Before that I had C, C++ in school and college. And even before that BASIC in lower classes in school. And it all started with LOGO when I was just 6 years old perhaps. Yes these many years and it still takes time to think through a large project. The initial outline comes within the first 30 seconds. But as I go deeper into the details, the architecture shifts. It is not always performance that you need to take care of. Code maintenance is also a big headache. You do not want to be stuck with code which is difficult to hand over to team members. That is basically dead code.

Also the modern stack of code for the web has changed dramatically. It has become a habit to think in terms of APIs. This enables loosely coupled architecture which is probably the best thing about the web itself. When designing web software though one thing I had to learn the hard way is that UI is most important. I have always thought of it, but still failed many times to stick to that rule. Slowly we have almost got to that point though and soon it will be better. But it is very essential to understand usability in user facing software. Code comes later.

A good software product is made of many components. Raw lines of code are just a part of it, very important ones though. But a very efficient data crunching tool will fail if it allows only XML files to be imported. People may have Excels, CSVs and what not. So it is most important to understand the audience. All these go in that ultimate great piece of code. In the end a product is also the packaging, the color, the logo, the manual that comes with it right? Same for software.

So from the next time you start a project by coding, think. Do the above points apply to it? If so try avoiding mistakes noted here. Go make some new mistakes :P

Wednesday, February 16, 2011

Free web hosting with Amazon Web Services (AWS)

I have deliberately titled this blog post such that it gets more hits when people search one of the most common issues related to hosting: free web hosting :D. Of course Amazon does not provide just free hosting, its much more that than. But the general blogger, community leader, shop owner or similar is still more interested in hosting a WordPress, Drupal, Joomla or some e-commerce application. Let me explain a bit what Amazon Web Services is all about and what this free deal means.

Amazon Web Services is a collection of products offered by Amazon (yes the original book seller on the web) which allows users to avail compute power, storage, database, content delivery and other stuff with no up front commitment. You pay for what you use. These allow you to have your application hosted on Amazon infrastructure whenever you need. You do not need to buy resources in advance since Amazon gives you access to them when needed and charges you only for what you use. Lets take WordPress as an application. It runs on PHP, uses MySQL for storage. You may also need normal disk storage if you upload audio/video content or file attachments. What Amazon gives you is building blocks. You have EC2 for running WordPress. It behaves like a complete machine which you can log in to. You buy bandwidth on a per use basis. So basically you install PHP, MySQL and necessary stuff and then throw in WordPress and hurrah! Your own blog on Amazon's servers!

Now you may be interested in hosting your blog (WordPress) or content management system (Drupal, Joomla), custom website (on PHP/Python/Ruby, MySQL etc.) or e-commerce application (Magento, Ubercart). What we are going to do is get to use Amazon's products and run our website on them for free. How free? Well Amazon is giving a free tier to every new customer till about end of this year (2011). Go and sign up for the free tier; you may also read through their product details.

Confused about how these stuff enable to host your website? Well I will agree it is not as simple as buying a hosting account from a web hosting company. Amazon gives you lower level platform on which you can build your own application. But no need to worry, you can look at services like JumpBox who provide you easy starting points and ready to start machine images for most popular software. They are even supporting the free AWS tier with ready to lunch solution for WordPress, Drupal, MediaWiki and Joomla.

Tuesday, February 15, 2011

Templates with Mustache in JavaScript and PHP

For a long time I have used PHP as the template language with nothing else on top of it. No template engines ever. This was all fine till the point that we wanted a full AJAX UI in forums.com and also support basic view in non JavaScript mode. We also wanted to also change to a template structure which is more graphic designer or HTML developer friendly where only knowledge of HTML/CSS is needed. Thus we needed a logic-less no-frills template engine which has support in JavaScript and PHP at the minimum.

After searching a little we came across Mustache, a logic-less template engine with support in many more languages than we needed. But we were certainly happy to see support in Python and Scala, just in case... Well a brief look at the readme in JavaScript version and PHP version will tell you the story: it is damn simple.

Mustache supports Number, String, Array or Object like data structures as its data source (view). It can also check for Boolean and function returns. Well that is more than sufficient for our needs. The major benefit was not that though. If you continue using any PHP based template system which you may end up having some PHP logic stuff somewhere in your templates after a while. This happened to us and we hated it. Our design team obviously wants to keep templates to themselves and thus the need to move to very clean templates.

Now how do we deal with PHP and JavaScript versions? We make one file per module in our system. So say discuss.html for templates related to discuss (Gab) system. Similarly user.html and usermanage.html and so on. Each file contains multiple individual templates which correspond to the sub-feature being requested. These are separated by HTML comments. The files are read in by a PHP code and provided as PHP array of strings to the PHP rendering engine or as JSON array of strings to the JavaScript rendering engine. This rendering engine is not Mustache, its a layer on top of it, which collects templates and data (view in Mustache language) and then send them for rendering.

The major difference between the PHP and JavaScript version of rendering is the way the layout is built. In the case of PHP, every sub-template is parsed, every inch of data prepared and then actual Mustache rendering starts. All this is synchronous. Smaller parts are fed to larger ones as strings, and so on. So we use View Partials in Mustache. But in the case of JavaScript rendering it is a different world. We only render outer portions first. For partials we render them later and modify DOM to insert them back to the page once the partials are rendered. So this allows us to have partials request their own data in totally asynchronous manner which is what we wanted.

We are still in process of developing this whole system. Of course we threw away hundreds of lines of old code to put this new system in place. And much of utility has shifted to JavaScript mode only. Also the back-end now behaves more like an API which just server JSON/PHP arrays.

Monday, February 14, 2011

A simple clean good looking pagination

We are re-writing few base codes in forums.com and one of things re-written is the pagination logic. We needed something very simple, good looking, yet works.

The logic boiled down to having 9 slots in total for the pagination labels. First and last ones were fixed at page number 1 and n. They were labelled "First" and "Last" too. Then we chose to keep 5 slots around the current page. So if page 8 was selected, then the labels (and corresponding pages) were 4, 5, 6, 7, 8. This allows users to browse nearby pages. The rest two slots we simply divide equally on both ends. We fill the gaps between the segments with '...' which links to nothing (FALSE here).

If the current page was near the start or end then we simply print 5 slots in that end and put the rest remaining 2 slots at the other end.

If the total number of pages is 9 or less then of course no use of all this logic, simply print them serially.

Well that's it! Here is the code, we build an array of the pagination slots.
  if($num_of_pages > 9) {
    $pagination_slots = $num_of_pages > 9 ? 9 : $num_of_pages;
    $selected_slots = array();
    if($page > 3 && $page < ($num_of_pages - 3))
      $selected_slots = array_merge(array(2, '...'), range($page - 2, $page + 2), array('...', $num_of_pages - 1));
    elseif($page < 4)
      $selected_slots = array_merge(range(2, 6), array('...', $num_of_pages - 2, $num_of_pages - 1));
    elseif($page > $num_of_pages - 3)
      $selected_slots = array_merge(array(2, 3, '...'), range($num_of_pages - 5, $num_of_pages - 1));
    $pagination = array();
    $pagination[] = array('url' => '?page=1', 'title' => _('First'));
    if(count($selected_slots) > 7) {
      foreach($selected_slots as $s) {
        if($s == '...')
          $pagination[] = array('url' => FALSE, 'title' => $s);
        else
          $pagination[] = array('url' => '?page=' . $s, 'title' => $s);
      }
    }
    $pagination[] = array('url' => '?page=' . $num_of_pages, 'title' => _('Last'));
  } else {
    $pagination[] = array('url' => '?page=1', 'title' => _('First'));
    for($i = 2; $i < $num_of_pages; $i++) {
      $pagination[] = array('url' => '?page=' . $i, 'title' => $i);
    }
    $pagination[] = array('url' => '?page=' . $num_of_pages, 'title' => _('Last'));
  }

Sunday, December 12, 2010

Users! Where are they?

In our effort to build forums.com there are a lot of things that we must learn, one of them being the art/science of getting users. First of all I must tell you that we are in Kolkata, India, where the traditional software business is mostly small to medium projects for clients. Very few companies build or work on projects spanning multiple years where they are involved in every aspect of the product they build. Although technically we build forums.com for a client, but it's an independent venture. So it's constant learning for us as to how we can build a product for the masses to appreciate.

So back to the point of users. forums.com is a common single word in English and thus we have some direct hits to the site to start with. The numbers were around 300 visits a day about 4 months back. Now we are about 900. On an average we get 10 new forums each day. That is not a bad count. But we want to have more of them. That is what every software builder wants. But instead of spreading the name to more masses we must think of our current scenario. We have absolutely NO brand now. forums.com is a hosted forum/group communication application. So you can imagine we have zillions of competitors including big ones like Google Groups, Yahoo! Groups and Facebook Groups. We are tiny (even smaller) compared to them. But why are people still opening forums on forums.com?

The only way I could personally answer that question is my own experience: people sometimes like to try new stuff. forums.com may seem a new toy to some onlookers. And that's it, they start a forum and use it. Good for us. But then that means we should get more onlookers? Yes and no. Yes because it would obviously help us, no because we need some background check. Think of these 10 new forums opening daily. Once of them, each month at least, could become a 100 folk (member) forum. But we are not having that. Reason? Software.

The same software which made someone create a forum may not be living up to their expectation afterwards. On the internet a person who tries out forums.com is probably an average connected folk in her community but unless we wow! her, the person would not invite 10 of her friends. That is why the ball is not rolling. People have high expectation from software nowadays and maybe we are not delivering that.

Then the question is: do we suck? The answer is no. We may be doing a good job if you compare forums.com to Google Groups. But when a user goes to Google Groups, she is part of the Google experience and that helps. She feels there more in the offering. Thus our offering in forums.com has to be stronger and make someone feel more cared, more served. User's time is important, and she will not hesitate to change to another provider. Thus the job of a product developer would be, at our stage at least, to satisfy the initial user-base. They are already here, so why not make them part of our family, forever.

Wednesday, October 27, 2010

To startup or not to startup

Just yesterday and day before a friend came up to me and said he was confused. He was building iPhone apps and was earning very well. But he was not sure if he wanted to start a company as such. He is young and can easily continue to be a one-man army and build applications and sell them. But he is not sure if he will feel good about building a team, managing it and so on. One thing he feels though is that he wishes to stay a product developer and not handle marketing or even team building.

This is a common situation many come across at least once in their lives. You do something you like doing, get some results, then what? Do you grow that, build a team, build a business? Or do you continue the direction you are on and be independent. Yes independence is an important term here. To start a team means responsibility. You may (and probably will) get partners along the way. These will be like your friends, the "gang" who combine their strengths to manage the company. These will be the group with transparent communication among themselves. And you will also build the team, the employees in traditional terms. You will also need help from your existing contacts, your family and so many other people. But it takes time.

Partners: Think of them as the closest people you know related to the business. You work together to keep the day bright and sunny, to make sure you have your work coming in, that the finances are right. But its more than just that, its about having a vision, a common vision together. You are the core of the family that you will create. If any of the non-partner team members have a doubt or a problem they should be able to approach any of you. Partners can be 2 or 3 or even as many as you need. But think about what are the core values of each of you. You want to have a team where each one brings in some quality which is required at the core of your business. This is although not how you always start out. Sometimes you just start out as a group of friends building a company. And that is fine. But then you will need to start thinking about who does what.

Team Members: At the heart of any successful company is the group of people who build it brick by brick each day. It takes time and effort. It takes a team. You need to build your product, choose the color that suits the best, select a tagline for it, contact the first possible client, market it, support your clients, and do hundreds of other things. Also you need someone to take care of your team. Someone has to make sure people are not working too much. But all this must have a reason. In my opinion the only thing that will make people come back each day and work on your business is the vision. It is the promise of a better tomorrow. Not all team members will get noticed, a tiny fraction will possibly get to come to the level of a partner. But they will all fight, with you, each day to make it a brighter tomorrow. But you are responsible for their well being, you will have to make sure they get what you promised them. This is what makes you different from other founders out there. Always remember it is the team that makes those big companies we read about.

So eventually it is one's decision to either fly alone, or build a team. Both have different modes of operation. They are very different in what you get as result. And one thing I have learned from my experiences is that building a team is toughest job you can take up. It takes a lot of time understanding the intricate details of humans. And its a slow process, taking each day and learning more, but progressing work at the same time.

Monday, October 25, 2010

Kolkata adda at AD38, Nov 3, 2010

We have planned a Kolkata meetup (adda) at AD38, Salt Lake Sector 1, on November 3, 2010, from 6PM onwards. Its a no agenda meet, the original adda, Bengali format. With a traditional menu accompanying it:
Luchi, Chola dal, Kosha mangsho, salad (type not yet fixed), mishti (probably pantua and rosogolla), chatni, papad.

A few of us were discussing having a meet for sometime but we could not have it for past few months. So lets meet and have fun!

Address is AD38, Salt Lake Sector 1.
Its near No. 4 Water Tank, 10 mins from City Center Salt Lake.
And if you know, its Pixlie and Web Prachar's office.

Sunday, October 24, 2010

Movie: Letters to Juliet

I had a fine opportunity to catch two movies back to back today all by myself. The movies were "Letters to Juliet" and "The Other Guys". "The Other Guys" wasn't very good, just a decent watch. If you have other movies as choices you may miss this one and not regret.

Anyway heading to "Letters to Juliet". The movie opens with Sophie (played by Amanda Seyfried) as a fact checker. She is verifying a picture of a kiss at NY Times Square taken just after the end of WWII. Trying to figure out whether it was spontaneous.

Sophie successfully figures out it was a spontaneous kiss and submits it to her Editor (I guess) and tells him about her pre-wedding honeymoon plan. She is engaged, and they are going to Italy before their wedding. Victor (Sophie's fiancé, played by Gael García Bernal) is starting a new restaurant and is always busy with food. From the very beginning he seems to be more obsessed with food and wine and vineyards than anything else in the world. But off they go to Italy.

Italy is where almost all of the plot takes place. Victor is, as predicted, busy with some contact over the phone and discussing wine, and food, and wine auctions and tours to vineyards while Sophie misses out her romantic time. After getting bored with Victor and his wine they part ways, Victor continues his quest for fine wine and Sophie starts wandering about places. Suddenly she comes into the Verona courtyard of Juliet and finds out women leave letters to Juliet. She follows a young lady taking those letters and discovers the "secretaries of Juliet" who reply to all the letters that have return addresses.

Sophie is intrigued by the whole concept and wants to know more. The next day she herself finds a letter which was left untouched for 50 years. It was about a young girl, Claire who had fallen in love with a boy in the countryside but had to return to England to her parents. She had to leave her love behind in Italy. Sophie decides to reply. To her surprise, Claire, now a grand-mom (played by Vanessa Redgrave) comes to Italy with her grandson Charlie (actor Christopher Egan) to find her long lost love. Thus Sophie, Claire and Charlie (unwilling) start their journey to search true love that once was and still is.

Sophie uses her skills to narrow down the search for Lorenzo (Claire's love) from about 74 possibilities to 15 or so. Everyone they met was not a match but Sophie pushed on, and so did Claire. Charlie stood out as the one who does not believe in true love, and thought the effort was not worth anything; that Claire may end up hurting herself because they may not find Lorenzo or he may be dead.

Victor is still engrossed in his wine and its auctions. This gives Sophie the chance to be part of the journey initially but it also brings in the realization that the couple, soon to be wedded, did not mind not staying separate on their romantic holiday. Charlie on the other hand is now presented as a man involved in humanitarian activities. He expresses his concern for his grand-mom but at the same time is thankful to Sophie. He also likes to read Sophie's writing about this journey and tells her to publish it. There is this other side to him. Slowly he feels they like each other. The fact that Sophie is engaged gives Charlie reason not to express any feelings for her, but then it happens. In a garden below the starry night they have their first kiss. Charlie is sorry after all this but things have already changed now. And things have also changed in their quest for Lorenzo.

Claire is almost given up in her journey and wants to return back. While doing so they cross a vineyard where Claire sees a boy who reminds her of Lorenzo. They find out he is the grandson of the man that Claire has been searching for. Lorenzo comes riding a white horse as you would expect in a fairy tale and it seems like a happy ending. But Sophie has snapped already. She manages a quick return to New York, home, with Victor. But the feeling is already deep inside her by now. "We did not mind being without each other". This was not her love story. Charlie on the other hand tried to talk to Sophie for the last time, to convince her that he was her true love, but did not the chance.

Sophie's Editor agrees to publish her writing of this journey. but Victor did not have the time to read it. Sophie gets an invitation to Claire and Lorenzo's wedding and decides to leave Victor. At the wedding she meets Patricia, Charlie's girlfriend who had not been in his life for a year. Sophie understands she has nowhere to go and runs from the wedding, with Charlie behind her. Charlie catches up and explains this is not his girlfriend but his cousin who is also Patricia.

Well happy ending as you can imagine after this with Tailor Swift's song "Love Story" playing in the background.