Monday, July 27, 2009

facebook's box alike

After quite long doing research on how to display a popup like what is in facebook, I found a way to do so. It is a jquery plugin which name is facebox (you can google this). Basically, the basic functionalities of this plugin is poping up a window which contains an information from certain dom. Start from this understanding, it can be improved to insert an information from another page (using xhr). Of course, when i say using xhr, it can only fetching data from the same domain as xhr cannot be used to fetch data from different domain.

Well, in this blog, i would like to share the way it works in a bit high level for the operation of fetching data from another page. Basically, this plugin only fetch the data from another page and insert it in a dom. Of course, it will be hidden. After fetching the data, there will be a decorator manipulation which is the popup window itself and grab the information from the dom and put it in the popup window. Well, that's all. Its simple, isnt it? Of course, for my need, I tweak it a bit.

Below is the picture of my try where the information is grabbed from Twitter.

Sunday, July 26, 2009

Transaction, maintainability and performance

Transaction management strategies on high performance application. This is an interesting topic, I guess, since many of enterprise applications have such problem.

Most of the enterprise applications are having a problem of performance because they maintain ACID in every of their transaction. Thus, the transaction will be atomic. Imagine that we have a few transactions, 100 transactions maybe, that we need to maintain the atomic-ity of these transactions for only one action of user (clicking certain button). And definitely, the user of some applications are not only 1, so it will cost more slowness. The more users who access your application at the same time, the more slow of your application will be.

Sometime, we sacrifice performance for application's design. we usually choose to have a good design of the application rather than a high performance of application. For example, the use of ORM, let's say hibernate. Using this kind of ORM, definitely, will slow down your application. But, it will make your application more portable if you want to use another database and also, it will make the code of your application much more maintainable.

This kind of trade off cannot be avoided. It will always exist in every of software development. However, it needs to be assessed and evaluated so that those factors can benefit end user.

One thing that may come on your mind is the use of stored procedure to leverage the performance. Why does stored procedure can be used to leverage the performance instead of having plain sql? Because stored procedure is a precompiled sql statement and also less data being transferred between application and database server. Unfortunately, not many ORM fully support store procedure. The only ORM that I know which supports store procedure is Hibernate. For detail about store procedure can be seen on the link below:

Saturday, July 25, 2009

YQL open data table

So that, you can use a service of YQL, you need to configure open data table. This table is in xml format which tells YQL what service that you want to expose and also it tells you also on how to use the service. Thus, this open data table will determine how is your query looks like.

YQL provides you 4 operations to deal with any public webservices, such as Twitter and Facebook. They are select, insert, update and delete. Yeps, pretty much similar with sql query. They are very powerful to deal with those public webservices.

I am gonna explain a little bit about those operations

  • select, this operation is to fetch data from webservices that you point in YQL. The things that you need to be aware is the format that you expect YQL to send to you. The available format are JSON, XML and the combination of both.
  • insert, this operation is to add/insert a new data through YQL.
  • update, this operation is to update certain data through YQL
  • delete, is to delete data in public webservice through YQL.
In SQL query, as we know, there are parameters, we need to supply so that they behave like what we expect. Below is the piece of code as an example:

The parameter of YQL is specified inside tag inputs. The thing that you really need to be aware is about the paramType. It determines how is the behaviour of the variable. paramType variable means that the input is accessible in javascript as the above. Yeah!!! it is one of the interesting thing of YQL, it allows you to do javascript to tackle the problem of basic authentication. It's nice, isnt it?

For a complete referece, you can see on YQL documentation. Overall, Its a gift to know that YQL comes. It is really helpful service.

Thursday, July 16, 2009

YQL rocks

A few days ago, I was doing research on how to perform cross domain ajax. I was hitting a lot of problem as this method (as in cross domain) was not supported by xhr. This object will definitely hit into a problem of security as you are trying to do a cross domain ajax. However, after google around, I found that jquery has a plugin named flxhr. This plugin claims that it can do a cross domain. I read the documentation, it says that it uses flash as a proxy to do request. But, it needs a configuration file in the machine to be planted. I dont think, it is a good way to implement my plugin. Hence, I leave away this plugin.

That time, I really gave up to find a way on using xhr. It is definitely not the right way to get data from another domain. However, I found a way to fetch data from different domain. We can fetch data from domain using technique called JSONP. This technique is actually a script to create or inject another script dynamically. The destination website needs to provide a service in JSON format and wrap it in a function. By then, we can do JSONP. As I need to deal with twitter and I see twitter provides service in JSON format. Then, I can definitely use this way.

Again, all the things do not go as smooth as what I expected. Some of the provided services need basic authentication. Arrgghh, again, I cant use JSONP for this. Feel so damn curious on how to resolve this problem. Upon googling around (again, I dont want to use this word, actually :P). I found out about a new service provided by yahoo. This service is called as YQL. It stands for yahoo query language. It acts like a proxy for any open webservice provided by well known website such as facebook and twitter. Also, this service provides you a way on how to modify header of the request using javascrip. Finally, I can fetch data from twitter using the great YQL.

Here is the snippet of my javascript to use YQL webservice.

social repository Github

Today, I just got a way on how to checkout a code in github. well, let me introduce what is github actually. it is a repository for community. Yeah, you can sign up yourself in the following address:

I have registered myself in the following:

Well, you will see a few test project there. Well, as I am noob, it should be not a matter. :D

However, this repository is quite unique compare to the others. it provides you almost the same featurea as subversion, the only thing which makes this different is about the command. The command's name is different. Just a few things are the same.

The thing that I did is to clone a project of yql-tables from spullara and then try to perfom add and edit on this clone project. Well, it is successfully being updated there. What does this mean? it means I can start to develop my plugin as yahoo service can reach open table in github.

Yatta!!! the next plugin will be coming shortly.

Wednesday, July 8, 2009

Ajax Cross Site

Now, I am trying to develop a Confluence plugin which needs an Ajax cross site. This plugin is actually need a data from outside. It means that I need to open and maybe hold the connection during the data fetching process. If I do this in server side code, it will burden the server a lot. Thus, I need to distribute the burden among the client. Thus, Confluence will not be complained to be slow anymore.

Upon googling around, it seems that it is impossible. A lot of people hit into a security problem. As xhr (XmlHTTPRequest) does not allow any script crossing site. However, I was finding clue which reveal the script of doing cross site. JSONP!! Yeay... By using JSONP technique, it is possible to fetch data from outside using javascript. The idea of JSONP is actually to have a dynamic insertion on function. As you may know that we are allowed to import a script from outside. For example:
< type="text/javascript" src="">

But, the application which you want to fetch data from, should provide a way so that the json which is a return value of rpc, wrap the return value in certain function. The following is a piece of code which does JSONP:

var surl = baseurl + "&callback=?"
$.getJSON(surl, function(data) {
var res = '<>The data: '+data.screen_name+''

Monday, July 6, 2009

Releasing plugin using maven

I was having difficulties on how to release plugin in maven since this is the first time I develop plugin for open source. A new knowledge for me indeed. My plugin which is about RPC using JSON in Confluence, now has been released. You can have a look at the following page:

I hope that many feedback from Confluence users to this plugin.

Anyway, back to the topic. Releasing the plugin is a bit complicated work for beginner. First thing that you need to do is to configure your pom.xml so that it points to the right repos. The configuration that you need to aware of is distributionManagement. DistributionManagement will have a link to servers' configuration in settings.xml. The following pages may be better to explain more on distribution tag:

Just to sum up the 2 links above. The distributionManagement tag defines what server to be used as a remote repository (this configuration is defined in pom.xml) and servers tag specifies the credentials or anything so that maven can write and install plugin in the remote repository.