Tuesday, December 23, 2008

g:remotelink and Delete Confirmation

While developing the sample ajax grails application which is available on github, I encountered this problem on g:remoteLink

Everything works good, but if I need to add a delete confirmation on the

<>, the confirmation dialog appears but g:remotelink still goes ahead and compeltes the ajax call even if the user has selected the

<> action="ajaxdelete" id="${contact.id}" before="return confirm('Are you sure?');" update="contactsElement">Delete

Jeff Brown at Spring Source. and his friend Rhyolight, lead developer on GrailsUI, Helped put a wonderful soluction to get around this problem.
Solution is to use Grails UI (Yui plugin), as grailsUI has this wonderful capability to passthrough the config params which grails does not understand it works well.

Here is what the above code was replaced by

&lt gui:dialog
title="Please confirm!"
triggers="[show:[type:'link', text:'Delete', on:'click']]"
form="true"&gtAre you sure you want to delete ${contact.name}?&lt/gui:dialog&gt

Looks like grails UI is very powerful to be ignored.

Wednesday, December 17, 2008

Sample application for AJAX and Grails

I am very impressed with the rapid development Grails Offers, the power of AJAX which grails offers has made it even more powerful. Grails offers many AJAX frameworks which can be added as plugins.

I started with a sample ajax in grails application, which demostrates the following capabilities of grails,
  • g:formRemote : How to use g:formRemote , within and Outside the controller
  • g:formRemote along with g:remoteLink for inline Editing
  • JQuery Validator Plugin : Demostrates JQuery works with conflicts with ScriptAculo and Prototype
  • Grails YUI : Replaced g:remoteLink with grails UI Dialog, for Delete confirmation.
I would like to thank Jeff Brown at Spring Source Inc. and his friend Rhyolight, lead developer on GrailsUI. Without with this demo application would have been incomplete

Please find a link to sample example, which includes all the scenarious of AJAX.


Please send me any pull requests, if you guys make some changes

Thursday, December 11, 2008

Using GIT with Amazon S3 on Windows

As I mentioned in my last blog, I was having some problems pushing changes to GITHUB, which have been resolved (I guess was due to my slow internet connection).
So I thought, we will give a shot to Amazon S3 and to my suprise we got it working in 30mins. OfCourse, it may be as powerful as GitHub in terms of features, but can be the cheapest way to maintain repositories

I did search for some these blogs which guided me,
Also, tobharris has a excellent reference to Toolman Tim

Following are the steps are in detail on how to setup

  1. Signup for a Amazon S3 account , click here
  2. Install Jungle Disk, which will map your s3 storage to local drive say y:
  3. Install CYGWIN git and open it
  4. Go to y: from your MSysgit or Cygwin of your GIT, and perform following commands
  5. mkdir var/git/sample.git
  6. git --bare init
  7. go to your project directory, which needs to be pushed on sample.git
  8. git remote add s3origin /cygdrive/y/var/git/sampleajax.git
  9. git push s3origin master //This will push your project to master branch of s3origin
Testing if it on Windows
  1. Open Cygwin
  2. Go to say c:\temp
  3. mkdir sample
  4. cd sample
  5. git config --global user.email youremail
  6. git clone /cygdrive/y/var/git/sampleajax.git
Voila!! You are all setup with GIT on Amazon S3.

GIT and Amazon S3 combination can be used to make cheap backups as well as for maintaining projects.

Wednesday, December 10, 2008

GitHub Issues, GitHub Support

Github source repository is very good to store projects, but sometimes aftermaking lot of changes to my source code when I try to push the changes to repo back, I get the following error.

Not sure what the reason is, is it the size or something else. I have opened a ticket with GitSupport, once I recieve a response I will update it

$ git push origin master
Counting objects: 147, done.
Compressing objects: 100% (138/138), done.
Writing objects: 100% (146/146), 179.11 KiB, done.
Total 146 (delta 8), reused 0 (delta 0)
Read from remote host github.com: Software caused connection abort
fatal: The remote end hung up unexpectedly

I dont think size should be an issue as as 180Kb is not big

Finally, I was able to resolve this issue though mysteriously, after 5 hours when I tried to push again with a different internet connection at home, everything went smoothly. I guess it was a connection issues with my internet at office.

GitSuppot did try to help me out on this one, though they came little bit late to pitch in, they suggested to try msysgit instead of cygwin. If it had not worked, I would have give that a shot.

Monday, December 8, 2008

Git And GitHub Frequently Used Commads

GIT is a Distributed Version Control System, it is rapidly gaining popularity on other version control systems namely Subversion, CVS, due to its easy of use, and its rapid commit speed.
It creates a new way of adressing complexties on a OpenSource Project, where earlier developers had to wait for days to checkin their code and deal with complex merging issues.

With GIT, all those are things of the past, we can focus on pure business logic or the code we are concerned. We just have to merge the changes with trusted resources and not get bothered by tons of other people changes.

There are very excellent articles and videos which Cover GIT in detail, My goal here is to display those commands which our team has been using more often

Initialization Commands
  • git config --global github.user <>
  • git config --global user.email <>
  • git config --global color.branch "auto"
  • git config --global color.status "auto"
  • git config --global color.diff "auto"
  • git clone
General Commands
  • git log
  • git status
  • git diff, shows the difference between curret and head version
  • git diff "@{yesterday}" , shows changes since yesterday
  • dit whatchanged --since="2 weeks ago"
  • gitk, to open the git GUI
Branch Commads
  • git checkout -b $samplebranch , Creates a branch named samplebranch and switches to it
  • git checkout $samplebranch, Just switches to a new branch
  • git branch -d $branch, deletes the branch
  • git branch -a : shows all branches local and remote
  • git branch -r : show all remote branches
Remote Repo Commands
  • git remote add <remoterepo> git@github.com:>/>.git , Adds a remote repository (e.g forked one from the main) to your machine
  • git remote rm deletes the remote directory
  • git remote -v : displays all the remote repositories
Adding & Reverting & Commiting Changes on GIT
  • git add . , adds all the changed /new files to the repo
  • git reset --hard HEAD , Reverts all uncommited changes
  • git clean -df , Remove any files in your working directory that were not added to git e.g autogenerated files.
  • git revert , Reverts to previous commit.
  • git commit -m "my first commit" to commit the files
  • git checkout <>, to revert a individual file
Adding Tags at Regular Intervals
Its good to add tags lets say at different phases of project or while branching out,
  • git tag -a -m "branched out version1" version1 , this will tag the last commit with the tag version1
  • git tag , will display the tags
  • git push origin --tags , will push the tags to the remote origin
Pull and Merge Changes from other repos
The following steps summarize the commads need to pull changes from other forked branches to your local branch and push it to your remote github repo
  • git remote add auserepogit@github.com:auser/arepo.git
  • git remove -v
  • git checkout -b auser/master
  • git branch
  • git pull auserrepo master
  • git checkout master
  • git merge auser/master ,Note: if there are any conflicts open the files and resolve them
  • git add . , This step is need to add any resolved conflict files
  • git commit -m "your commits about successful merge"
  • git push origin master , to push your changes to the github origin repo
Creating Remote Branches
To create a remote branch, there are many ways to approach
  • Create a local branch
  • git push origin master:refs/heads/R1.2 : to create a branch name R1.2 on remote origin
  • git checkout -b R1.2
  • git pull origin R1.2 : to pull changes from remote R1.2 branch

Git Ignore
echo stacktrace.log >> .gitignore , adds stacktrace.log to .gitignore directory
Note: I haven't seen this working yet, hopefully soon it should work

Some Good Articles on GIT

Friday, December 5, 2008

Tips to Improve Peformance of Your Blog

I have been blogging for a while, but how stupid I am to see if anybody is reading up the blog or my goal in this blog is to, keep adding information on How to Improve the Performance of you blog.

Improvement in terms of addding different tools / utilities to imrpove the performance.
I will keep on adding the links as I get it, but if you guys have any please feel free to add it.

Most of my information will be geared towards the Blogger , but should be able to apply to Wordpress or any other blogging tools for the matter.

1. Add Google Analytics, to your Blog

Followling links give the information on how to add track your performance of your Blog.
Note : In the following blogpost, you need to post the JavaScript to your body tag, which is far below in the template.

Click Here To Add Google Anaylytics to Your Blog

2. Add Label Cloud To Your Blog

A tag cloud is a visual depiction of content tags used on a blog. In a tag cloud, tags are typically listed alphabetically, and tag frequency is shown with font size or color. The tags are usually hyperlinks that lead to a collection of items that are associated with that tag.

Click here to add the LabelCloud to Blogger

3. Allows Users to BookMark and Share Your Blog
Add AddThis Button to allows viewer to easily bookmark your blog.

Click here to get Started

Top 10 Java Interview Questions

Out of the experience of so many interviews, I see following Core Java Interview Difference Questions keep on getting asked on repeatedly, Making them on my popular list.

Here is the list of Questions

1. Abstract Class And Interface
2. Runtime(UnChecked) and CompileTime(Checked) exceptions
3. Deadlock and Race Condition
4. String and StringBuffer
5. List and ArrayList
6. Hashtable and Hashmap
7. Static and Non Static
8. Difference between Vector and ArrayList
9. Difference between Array and ArrayList
10 Write an example for Singleton Design Pattern

Please find the following links to explore their answers



Combining All Blogs to one

Initially I was following the practice of creating a new Blog for each topic, so was having differenct blogs like

After a sometime, it becomes difficult and error prone to main all the blogs as well as, it I need to give anybody a blog address I really don't have one, it was depending on topic.

From, today I will use this blog as my Final Blog address for my postings.. finally found a new way out. http://markatharvest.blogspot.com