Tuesday, 18 September 2012

Installing Internet Explorer On Ubuntu

I.E. is something which you really can't do without. You need to test your presentation code on it whether you like it or not :) .

So, here are some steps which helped me get the job done. Hope it helps you as well.

1) Install wine. 
Open a terminal by Applications > Accessories > Terminal
or Alt + F2 , then type gnome-terminal, press enter.
2) Type sudo apt-get install wine
3) [sudo] password for nikhil: my-password-here
4) Next, open winetricks by (Applications->wine->Winetricks)
5) Choose the already selected option, which says "Select the default wine prefix", and press OK button.
6) Choose the option, "Install a Windows DLL or component" and click OK.
7) Now you can choose a whole host of things including I.E. 6,7,8 and others. Just pick any one and install.
8) To test, go to Applications -> wine -> Browse C: Drive -> Program Files -> Internet Explorer -> Run "iexplore.exe" with "wine"
 9) Congratulations !!!! You are a proud owner of I.E. on Ubuntu.

Hope it helps.
Keep Blogging. 

Saturday, 8 September 2012

Setting up public keys in Ubuntu

1) Check for SSH keys
     cd ~/.ssh
   If there is already an SSH directory you'll want to back the old one
   up and remove it: 
2) Backup and remove existing SSH keys
     ls
    mkdir key_backup

    cp id_rsa* key_backup
3) rm id_rsa*
4) Generate a new SSH key
    ssh-keygen -t rsa -C "your_email@youremail.com"
5) Add your SSH key to GitHub

6) Test everything out
7) ssh -T git@github.com
    
Thanks For Reading. Keep Blogging !!!    

Installing git on Ubuntu

Well I had to re-install my computer, I lost all my data, I was so disappointed but then I thought what rifiki said in the Lion King "The past does hurt, but the way I see it you can either run from it or LEARN from it."

So, I thought I will install some bare minimum things I need in daily development and share all with you. Maybe some one gets some help and I feel happy :)
 
Lets get started:

1) sudo apt-get install git git-core
2) Provide the sudo password.
3) Test it, just type git
4) Done. Congratulations !! 


Installing Idea In Ubuntu

Well I had to re-install my computer, I lost all my data, I was so disappointed but then I thought what rifiki said in the Lion King "The past does hurt, but the way I see it you can either run from it or LEARN from it."

So, I thought I will install some bare minimum things I need in daily development and share all with you. Maybe some one gets some help and I feel happy :)

This is my sixth on the to-do list:

1) Go to the website here .
2) Download your edition Linux remenber :).
3) Open a terminal by Applications > Accessories > Terminal
or Alt + F2 , then type gnome-terminal, press enter.
4) Move the file from Downloads to ~/softwares.
5) Untar the file tar -xvmf ideaIU-11.1.3.tar.gz
6) Make a alias in .bashrc file.

alias idea11=~/softwares/idea-IU-117.798/bin/./idea.sh

7) Test it, type on a new terminal idea

idea11
8) Congratulations !!!! Happy Coding..
Installing GRAILS on Ubuntu 11.04

Well I had to re-install my computer, I lost all my data, I was so disappointed but then I thought what rifiki said in the Lion King "The past does hurt, but the way I see it you can either run from it or LEARN from it."

So, I thought I will install some bare minimum things I need in daily development and share all with you. Maybe some one gets some help and I feel happy :)

This is the fifth thing on my to-do list, so lets get started.

1) Download the appropriate zip folder from here .
2) Open a terminal by Applications > Accessories > Terminal
or Alt + F2 , then type gnome-terminal, press enter. 
3) Go to Downloads folder by cd ~/Downloads, unzip grails distribution, mine was 1.3.4 so, I did unzip grails-1.3.4
4) cp -r grails-1.3.4 ~/softwares/
5) Make a new variable in .bashrc file
6) GRAILS_HOME=~/softwares/grails-1.3.4
    export GRAILS_HOME
    PATH=$PATH:$GRAILS_HOME/bin
    export PATH
7) Test it
     grails
8) Congratulations !!

Thanks for reading. Keep Blogging !!






Installing Groovy on Ubuntu 11.04

Well I had to re-install my computer, I lost all my data, I was so disappointed but then I thought what rifiki said in the Lion King "The past does hurt, but the way I see it you can either run from it or LEARN from it."

So, I thought I will install some bare minimum things I need in daily development and share all with you. Maybe some one gets some help and I feel happy :)

This is the fourth thing in my list.

1) Go to groovy wesite here.
2) Download the zip and the documentation as well (it does help).
3) Open a terminal by Applications > Accessories > Terminal
or Alt + F2 , then type gnome-terminal, press enter.
4) Unzip the folder, move it to some other location, I keep it in ~/softwares folder.
5) Add a new variable in .bashrc file
GROOVY_HOME=/home/nikhil/softwares/groovy-1.8.7
export GROOVY_HOME
PATH=$PATH:$GROOVY_HOME/bin
export PATH
6) Test it on a console, don't forget to open another terminal and type
     groovyConsole
7) Happy Testing Groovy Code.

Thanks . Keep Blogging !!!!
Installing JAVA 1.6 on Ubuntu 11.04 

Well I had to re-install my computer, I lost all my data, I was so disappointed but then I thought what rifiki said in the Lion King "The past does hurt, but the way I see it you can either run from it or LEARN from it."

So, I thought I will install some bare minimum things I need in daily development and share all with you. Maybe some one gets some help and I feel happy :)

This is the third thing on my to-do list. Please follow the following steps:

1) Open a terminal by Applications > Accessories > Terminal or Alt + F2 , then type gnome-terminal, press enter.
2) sudo add-apt-repository ppa:ferramroberto/java
[sudo] password for nikhil: my-password-here
3) sudo apt-get update
4) Then, install java jre:
 sudo apt-get install sun-java6-jre sun-java6-plugin
5) Install Jdk by the command:
 sudo apt-get install sun-java6-jdk

6) sudo apt-get install sun-java6-jdk
7) Now, setting the JAVA_HOME variable in .bashrc file 

JAVA_HOME=/usr/lib/jvm/java-6-sun (Don't give spaces between = and /usr)
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH

8) Test it by javac -version
javac 1.6.0_26
9) Congratulations !!!











Install VIM editor on Ubuntu 11.04

Well I had to re-install my computer, I lost all my data, I was so disappointed but then I thought what rifiki said in the Lion King "The past does hurt, but the way I see it you can either run from it or LEARN from it."
So, I thought I will install some bare minimum things I need in daily development and share all with you. Maybe some one gets some help and I feel happy :)

Well, this is the second thing in my todo list. I really like the editor, too powerful and so light weight.

Just follow the steps:

1) Open a terminal by Applications > Accessories > Terminal
or Alt + F2 , then type gnome-terminal, press enter.
2) Type sudo apt-get install vim
3) [sudo] password for nikhil: my-password-here
4) Say 'y' to download the required packages.
5) If you get :
Setting up vim-runtime (2:7.3.035+hg~8fdc12103333-1ubuntu7) ...
Processing /usr/share/vim/addons/doc
Setting up vim (2:7.3.035+hg~8fdc12103333-1ubuntu7) ..

Congratulations !!
6) Test it with vim myfile
7) Escape out of it by : q
8) Search for a pattern /pattern

Thanks for reading. Keep Blooging

Install Skype In Ubuntu 11.04

Install Sype In Ubuntu 11.04

Well I had to re-install my computer, I lost all my data, I was so disappointed but then I thought what rifiki said in the Lion King "The past does hurt, but the way I see it you can either run from it or LEARN from it."

So, I thought I will install some bare minimum things I need in daily development and share all with you. Maybe some one gets some help and I feel happy :)

This is the first thing I would like to install, more to come .

1) Go to the skype website here.
2) Click on Get Skype and choose Linux.
3) Hovering on Download Now and select Ubuntu Distribution, Ubuntu 10.04 Skype will also work for 11.04 :)
4) New skype version 4.0 gets downloaded usually in Downloads folder.
5) Copy that to any convenient folder I have softwares folder under my home folder, I copy it there.
6) Open the terminal Application > Accessories > Terminal.
7) Go to the folder where you have the .deb file for me the file name is skype-ubuntu_4.0.0.8-1_i386.deb . For me the rest of the steps were :
8) cd softwares
9) chmod +x skype-ubuntu_4.0.0.8-1_i386.deb (This gives executable rights to the file).
10) sudo dpkg -i skype-ubuntu_4.0.0.8-1_i386.deb
11) Provide your password [sudo] password for nikhil: my-password
12) Press enter.
13) If successful, go to Step 21
14) If you got something like
 Processing triggers for python-support ...
Errors were encountered while processing:
15) sudo apt-get install -f
16) The following comes
 Correcting dependencies... Done
The following extra packages will be installed:
  appmenu-qt libaudio2 libdbusmenu-qt2 libmng1 libqt4-dbus libqt4-network libqt4-xml libqtcore4 libqtgui4
17) As you can see the -f option tries to correct the unmet dependencies you encountered at Step 14, press 'y' to install the dependencies.
18) If you get the following :
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Happy News :)
19) Now, try again sudo dpkg -i skype-ubuntu_4.0.0.8-1_i386.deb
20) If you get the following :
Rebuilding /usr/share/applications/desktop.en_US.utf8.cache...
Processing triggers for python-support ...
Congratulations !!!!!
21) Go to Applications > Internet > Skype > Agree the terms and enjoy.


* Please do not follow the procedure for ubuntu 11.10, if you already have then
  you may be getting an error similar to below ..

 dpkg: warning: 'ldconfig' not found in PATH or not executable.

 This is really bad but there is an alternative to fix this at here.


Thanks for reading.

Keep Blogging.

Monday, 30 January 2012

Git Remote Add


We can track multiple repositories from a single location in your local machine. Consider the steps

1) cd <my-fav-dir>
2) git init
3) git clone git@github.com:myOrg/myRepo.git
 Sets up to track the default branch of the repository just cloned with the alias origin, usually tracking master
4) Make sure by git remote show <repo_name>
origin 

Now, we want to track one more repo.
5) git remote add another_repo git@github.com:myOrg/anotherRepo.git

Now, create a local branch to track any branch in anotherRepo

6) git checkout -b anotherRepo_master another_repo/master

Now , you have made a new local branch named anotherRepo_master tracking anotherRepo's master branch and also switched to that branch.

To make sure everything is good do,

git remote -v

origin  git@github.com:myOrg/myRepo.git
another_repo  git@github.com:myOrg/anotherRepo.git

7) git add
8) git commit -a

Now, you want to push in the right repository, the syntax is

git push <repo-to-push> <local-branch-alias>:<remote-branch-to-push>

git push another_repo anotherRepo_master:master

Hope it helps.
Cheers.
Keep Blogging

Sunday, 29 January 2012

GIT PATCH FILE

Well , this is quick and dirty. Probably, I will add more information to it. But suppose consider the following:

Your manager says that he/she wants the digest of the commit you have just made before pushing the code to the repository. He/She will review it and tell more about it. You can probably zip your changed files and send him/her to review.

Git comes with a really nice alternate, the git patch files. To come up with it, just
do:

1) git add
2) git commit -a
3) git format-patch -1

-1 says that you want to create a patch file(containing all the git diffs) for the last commit.

-2 creates a patch file for 2 most recent commits and so on.

Now, he/she can just do

git apply <patch file path which you probably emailed>

That would create an exact same commit at his end and then she can see all the code that you have just written for a new critical feature/bug.
Please post any questions or updates.

Hope it helps.
Keep blogging
Cheers

Tuesday, 22 November 2011

Things I Like About Ubuntu

Recently I was asked this question why Ubuntu over Windows??

I think I did not justify my answer . I think I could have answered better .
Just some of the things that are coming to my mind , I can write it down.. I will update it further for sure as my understanding of the system grows..

1) Its free (god , we all like free things..)

STORY:
My friend recently bought a laptop for himself HP Intel Core I5(ahhh.. chuck the specs), etc.. The vendor told him the machine is worth 31k but you would need to add another 4k to install Windows 7..
My friend said thank you , I am a ubuntu lover , I will save my 4k for clubbing or better things in life..

2) I like to obey the law..(Well mostly same as above , but I can continue the story)

STORY:
Another friend of mine took the same machine in 31k but now he installed pirated windows .. Pirated office.. Pirated softwares.. And he left automatic updates ON.. [Big Mistake]
Now his OS keeps bugging (begging) him to update to the original version..

3) sudo apt-get install <anything>

Well this is the most loved command of any Ubuntu person.. It can install anything.. It just recently installed my Reliance 3G datacard..

sudo apt-get install  libqglviewer-qt3-2

Then just ./install.sh great..

4) Greater UI experience than windows .. Its a personal thing but well.. I believe 11.04 is killer , guess what they have 11.10

5) I can delete .IntelliJIdea10/ folder from my home location and it renews again for 30 days.. I just broke my point 2..

6) Aliases... Love creating them in my .bashrc
alias grapport8090='grails clean;grails -Dserver.port=8090 run-app'




7) get all the youtube content I ever see..

just cd to your home folder , then 

cd .cache/chromium/Default/Cache , you can find all the videos you are currently watching present with some odd name there.. Copy them to wherever you like and enjoy !!!

I will update it once I know more..
Till then keep blogging..



Wednesday, 27 July 2011

ICE PUSH PLUGIN EXAMPLE EXPLAINED


Recently in one of my project i was given the task to create a sort of notification area in my web page , some call it reverse-ajax , the thing i am talking about is like suppose you are on yahoo chat and some of your friend comes up and you are notified that your friend is available now to chat..

So in our grails world i searched a little but and found out about this plugin ICE PUSH which catered to my need just fine ..
So i will explain it in a form of an example..

Suppose i have a page whose name is actionToCall(wierd name i know.. silly me) , when a user hits the page it just shows how many instances are there of a particular table say User table , it just displays the number of instances of the users present in the system ..

So for that i need a controller UserController and action page
here's the code of UserController::

class UserController {

    def index = { }


    def actionToCall = {
        new User(name: 'nikhil').save(flush:true) // just makes a new User object
    }

}

Now the page ,

<%@ page contentType="text/html;charset=UTF-8" %>
<html>
  <head><title>Simple GSP page</title>
 
  </head>
  <body>
  Place your content here
  </body>
</html>

SO there is nothing on the page right now .. WHAT i want to do is if any user hits this page , i want to just save a new User to be added and also show up how many Users are there in the database.. I will clarify it further.

Suppose i login from chrome browser and hit this page , assuming that there are no Users present in the User table currently. I want 1 to come up in the page showing that there is 1 User row in the table..
Next when i start another browser like Mozilla or start a private session in chrome (can be done via ctr+shift+n key) , and hit the same page , i want the user count to show me 2 , ofcourse it would because before coming to the page i had hit the action like (http://localhost:8080/SampleApp/user/actionToCall) { you must be thinking what's cool in that huh..}
but what i also want here is that when i open up my previous window WITHOUT REFRESHING THE PAGE (yeah important thats why in caps) and i want the User count to be shown as 2 as well..

Try to understand the difference .. Normally the ajax call is intitiated by some event that the user initiates like clicking a button , clicking a link or so on .. But the magic here is that what seems to happen is the server actually pushes the content to the browser (server's client) automatically.. This is however not possible , its just an ILLUSION that it happens..

Actually we want to do something like Polling the server continuosly via Ajax calls and then that way the server can give us the new thing on that page ..
Polling is well like continuously asking someone for something .. Like when i used to do with my mom every time she called from office i would ask her that what she will bring for me today?? ..( Most of the times she did , lucky ME)..

So we do must do this polling (continously asking the server if there is anything new with him) ,
hmmm.. ok so when should we poll him ??
Well the obvious answer is that when someone comes at this page right ?? So we have 2 options .. the polling code should be written either
1) in the interceptor blocks (yeah.. same old things which either do something either before when request comes in or does something after the action has completed before view)
2) in the filter right .. hmmm.. same thing but scalable much easily so i will write the code in one of the filter class..


Wait i was here to tell you about this nice plugin right ??

Ok let me go step by step

Step1) Install the plugin
grails install-plugin icepush (http://www.grails.org/plugin/icepush) Now i have icepush plugin hahahaha.. so whats great in it use it silly me ..

Step2) Ok.. i want ice push capabilities in my page shown above .. so i modify the code of the page to..Spot the difference:

<%@ page contentType="text/html;charset=UTF-8" %>
<html>
  <head><title>Simple GSP page</title>
  %{--TO GET ICEPUSH CAPABILITIES AT THIS PAGE--}%
  <icep:bridge/> (JUST THIS LINE)
  </head>
  <body>
  Place your content here

  </body>
</html>

Step3) This is the hard part , i told you that we would make ajax calls to the server automatically when we would be notified
       or did i ?? Sorry if i didn't.. (This amnesia thing) ..
     
       Ok so we want a region from where we can make ajax calls so the plugin has it.. Do i need to say spot the difference again..


<%@ page contentType="text/html;charset=UTF-8" %>
<html>
  <head><title>Simple GSP page</title>
  %{--TO GET ICEPUSH CAPABILITIES AT THIS PAGE--}%
  <icep:bridge/>
  </head>
  <body>
  Place your content here

  %{--rendering from util controller's alert action--}%
  <icep:region group="notifyGroup" controller="util" action="alert" /> (ONLY THIS MUCH)

// THIS JUST CREATES A region from where ajax calls would be made to the action whose name is alert which is present in controller util (yeah... i need to create that as well ..)

hmm.. you would be thinking how it works , actually when the page loads up for the first time , it just loads the content initially from this controller action but subsequent Ajax GET (yes GET method) calls are made to this action (alert) when this region is notified by its GROUP-NAME attribute (did i say notify.. ??)

</body>
</html>

Well now with the notify part , well i gave you a hint earlier that notify code part i would put in a filter class..
Here is the code :

import org.icepush.PushContext
import org.codehaus.groovy.grails.web.context.ServletContextHolder as SCH


class FlowcheckFilters {

    def filters = {
        all(controller: '*', action: '*') { // NOW you can easily customise this for a specific controller action

            after = {
                push 'notifyGroup' // This is how the push call is made to a specific group named notifyGroup
            }
        }
    }

    def push(String s) {    // yeah the function definition..
     
        PushContext.getInstance(SCH.servletContext).push s // Now we call the method getInstance on the                                                                                     //                                                                 class  PushContext provided by the plugin which needs
//                                                              a ServletContextHolder and we call the actual
 //                                                             push method of the plugin easy right ??
    }
}

and yes , the util controller , well you can put anything here .. but as per our use case , this is the code:


class UtilController {

    def index = { }

    def alert = {
        render "${User.count()}" // Just renders the User count and we are done !!!
    }
}

yippi.. I thought i would not to be able to complete this blog .. Eaten up quiet some time of yours right..
So heres the flow::

User1 logs in from chrome , hits the page , the page loads up initially the user count rendered is 1
User2 logs in from firefox , hits the page , the page loads up and shows user count 2
But when you switch to chrome window it shows 2 there automatically because ---->
When user2 from firefox hit the action it also hit the after filter block which notified the grou i.e. told the browser to make a fresh ajax call in to the given controller - action pair as in the <icep:region> tag , so it made the request without user1 who is on firefox automatically on his behalf and thats why without refeshing the page , we also get User count is 2 on the firefox window.. Yippi we are done..

Now we can create some features from use of this plugin.. I know the demo is the most simplest it could have been but  if i get across the point , as one of my friend says ITS AWESOME . pls do refer to the plugin page http://www.grails.org/plugin/icepush
you will find a whole lot more there ..

Thanks for reading
Keep blogging