Tuesday, May 18, 2010

cloud hosting monthly costs comparison

Most of the cloud providers charge hourly. Its easier to compare costs if we can get a monthly pricing. However the hardware they provide is difficult to compate.
The simple monthly pricing formula is [cost per hour] x running 24 hrs per day x 30 days = [cost per hour] x 720 hours a month
Here is an attempt for linux as of may 2010:

 

Amazon EC2:(Standard On-Demand Instances)
Small $0.085/hr => $61.2/month
Large $0.34/hr => $244.8/month

rackspacecloud
256MB/10GB 0.015/hr => $10.95/month
512 MB/20GB 0.30/hr => $21.90/month

opsourcecloud 

0.26/hr => $191/month
http://www.opsourcecloud.net/getstarted/pricing/

Amazon does provide the Pay only for what you use. But how does it identify our usage and what it exactly means is not clear ? Yet to figure it out. Somewhere I did read that till your app is shutdown it means the CPU is used..Would it make any sense for web app...I may be wrong..

Google App engine:
-cant write to disk.
-blacklisted set of java APIs, so few apps dont work
- cant use hibernate . So most open source apps built on hibernate wont work.
- 30 seconds HTTP response limit. So cant use streaming.
- Shutsdown app if not used for certain hours. So will give you screen deaths after first access.
- Use it only if you are ready to get tied to google ORM and big table. Also no joins..duplicate your data and...grrr..
-Then why use it ? Hmmn .. But it gives basic usage stuff for free. If you are ready to align your apps to what GAE provides and live with its limitations, then you are good to go.

Cloud is still evolving i think.
For my basic app needs, I would rather prefer to setup my own boxes and network infra to cut costs and have full control.

Reference:
http://www.raditha.com/blog/archives/cloud-hosting-making-sense-of-the-pricing.html

Tuesday, May 11, 2010

jQuery gotchas

1. Playing with checkboxes:
To get all the checked checkboxes from a group use :
$("input.selectArticleCheckBox:checked");

2. To hide multiple elements in a screen with the same name use class instead of id:
$('tr.filterSection').show();
This shows all elements with class filterSection in a tr

3. Iterating through an array:
       $.each(
                    articles,
                    function( intIndex, obj ){                 
                        alert(obj.value);
                    }
         );

4. Check if element is visible: $('.classMessage').is(":visible")

5. Email validation using regex:
var regexEmail= /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z0-9]{2,4})$/;                          
if(!regexEmail.test(currentFieldValue)) { }

6. Manipulating select fields
$('#selectList').val();$('#selectList :selected').text();

7. Debugging jquery on stupid IE
//global catch all
function
handleError(e)
{
alert(’An error has occurred!\n’+e);
return true;
}
window.onerror = handleError;
Use stacktrace.js as a life saviour : stactrace.js
  Nice link here
  More

8. CORS - cross site ajax call using jquery.
Browsers restrict from making cross site calls. Alternative is to use JSONP (JSON with padding)
The web server hosting the JSON, should wrap the json with  the function name which needs to be implemented in the javascript/jquery code. Also the jquery should send
jsoncallback=? parameter. Also older jquery version doesnt support .ajax based jsonp.

var flickerAPI = "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?";
$.getJSON( flickerAPI, null)
.done(function( data ) {
alert("gotdata");
});
*update : the above didnt work, so tried with $.ajax() by passing jsonCallBack: "functionName"

9. show()/hide() in jquery is too slow as it does some data caching. also setting $().css("display","none") is slow.  Hence used CSS based hiding :
       $('tr.tableStyleRow').addClass("rowShowClass");
        $('tr.tableStyleRow').removeClass("rowHideClass");

.rowHideClass{
    visibility:hidden !important;;
    display:none !important;;
}
.rowShowClass{
    visibility:visible !important;;
    display:block !important;;
}



Ref:  Jquery cheat sheet :
Build your own jquery plugin tutorial
spring mvc with jquery ajax
restful spring mvc

Tuesday, May 4, 2010

Liferay 5+

  • Liferay experiences thread link
  • Public render parameter(JSR 286) in liferay to read a request parameter: link 
  • Website search (page search based on meta tags : link
  • Building a hello word portlet using plugins SDK:link
  • Liferay and opensso integration:(quite neat) : link
  • Organization vs community : link
  • Adding validation messages in liferay : link
  • Popup in liferay : link
  • Liferay hook plugins : link : Hooks are event handlers and they are Good stuff !.  Liferay provides the following events : Application Startup Events, Login Events, Service Events                                               Gotchas : Better to use hooks as plugins. Tried in ext once and it broke other hooks.
  • Customizing labels(internationalized): Done in Language-ext.properties
    : link
  • A good review of liferay 5.x is here
  • Liferay architecture is SOA based :

* Above image is taken from book Liferay Portal 5.2 Systems Development.pdf