Tuesday, July 17, 2012

Getting Ready with Python-PIP

As I mentioned in my earlier post on Python in Eclipse [PyDev Plugin for Eclipse], that I am new to Python. I decided to post the issues I face during my Python experience. And for this post the motivation was python-pip. 

What is Python-pip?

pip is a tool for installing and managing Python packages, like the ones which can be found under the Python Package Index. It's a replacement for a previous tool, easy_install. More details can be found here.

Dependencies of Python-pip

  • Python 2.7: If you don't have python installed then you can follow the instruction from Tutorial Point.
  • Python setup tools.
    In case if you don't have python-setup-tools then:
    • Download the RPM installer package for python-setup-tools. In my case I am on Linux Fedora 14 and downloaded the RPM package file from here.
    • Once you have downloaded the python-setup-tools RPM package file. Install it with RPM command from shell:
      rpm -i python-setuptools-0.6.14-3.fc14.noarch.rpm
    • And its done for python-setup-tools.

Installing Python-pip

After getting all the dependencies, you are all set to install the python-pip package. The first thing to do now is to download the python-pip RPM installer for your linux version. As mentioned earlier that I am using Fedora 14, I downloaded the rpm package file for python-pip from here.
rpm -i python-pip-0.8.3-1.fc14.noarch.rpm
After this, the you are ready to use python-pip to install python packages.

Using Python-pip

The list of package that can be installed using python-pip can be found here.

To get packages:

To get and install a package using python-pip, simply run following command: 
$ pip install {package_name}
 or if that doesn't work then try:
$ pip-python install {package_name}


To uninstall a package:

To remove a python package, run following command:
$ pip-python uninstall {package_name}

To upgrade a package:

To remove a python package, run following command:
$ pip-python --upgrade {package_name}

I hope this helps you. Feel free to share your experience/issues.

Sunday, July 15, 2012

Configuring Maven Local Repository

What is Maven Local Repository?

Maven local repository is the place on your machine where all the dependency libraries of your project which have been downloaded using Maven are stored. These files usually include plugin jars. 

Maven Configuration File:

Maven local repository is defined in it's configuration file which is usually located under directory \conf with name settings.xml.

Changing Default Maven Repository:

By default on windows 7, the maven local repository is set for C:\Users\user_name\.m2\. You can change this by editing the settings.xml. 
In the settings.xml look for the commented localRepository definition which looks like:
 

Either un-comment it or add the following line:
D:/dev/maven_repo
Save the file and you are done. Now all the future dependencies will be downloaded to the path you set. 


Refer to the Maven Repositories and Configuration post to see what types of Maven repositories are there and how you can configure them.

Thursday, July 12, 2012

Translate This for Firefox

Like most of the people (internet users), I spend a lot of time surfing internet. And one of the important part of surfing internet is?? Any guesses

 A WEB BROWSER (ta da).

There are many browsers which are available out in the market like the ancient INTERNET EXPLORER, THE MOZILA FIREFOX and the latest GOOGLE CHROME. I started my internet surfing life with MS Internet Explorer and then moved to the mighty FOX and finally moved to CHROME and stayed to it for a long time because of many of its nice features but since last few days chrome started eating up a lot of memory and it makes my PC F**KING slow and to be honest, I hate that. Also, what's with the frequent crashes, and its making me loose the love I have for Chrome.

But even with all this bulls**t, I stayed with chrome and that was because of one reason which I miss in Firefox or Internet Explorer and that is Chrome's Web Page Translation feature. Its very handy and lets you break the barrier of language. I tried to look for some Add-ons for Firefox which can provide this web page translation feature but all of them are not as good as Chrome's web page translation.

Then I came across a Firefox addon which I find better than other available addon is "Translate This". It's easy to install with no restart required to your Firefox and by using a simple shortcut you can get your page opened in the same tab or another tab translated to your language. At the end, it uses the Google Translate website.

You can get this plugin from here.


Once it's downloaded and installed, you can see it's icon at the status bar of Firefox




Hold the SHIFT button and then right click on the "Translate This" icon on status bar and the following window will appear. Configure the addon based on your preference.



Now everything is set and you just need to use the shortcut to translate a page. In my case I opened a french website "lemonde.fr" and after using the shortcut (CTRL+ ALT + t), I get this:

Friday, July 6, 2012

VirtualBox Guest Additions

What is VirtualBox Guest Additions?

VirtualBox Guest Additions are a package of programs and drivers which are installed on a guest OS running in VM. It helps to improve guest's performance and make integration much more seamless. There are many other features like Host/Guest Time sync, shared folders, Mouse pointer enhancements and many more. 
Here, I will focus on how to install VirtualBox Guest Additions and how to configure Shared Folder for a Fedora virtual machine?

Installing VirtualBox Guest Additions

All the commands here are run with root privileges. Get the root privileges by logging in as root or use sudo in the beginning of the commands. 

Getting required packages: 

Once you have the Linux guest machine installed on virtual machine, install some additional packages required for VirtualBox Guest Additions like dkms, kernel-devel, etc.

To install all the packages required run the following command: 

yum install dkms binutils gcc make patch libgomp glibc-headers kernel-headers kernel-devel

Mount the VirtualBox Guest Additions

Once the package installation is done and we have the packages required by Guest Additions, lets start installing the actual thing. 
Mount the Guest Additions ISO from VM menu using Device -> Install Guest Addition.


Make sure there is no other CD already mounted on your virtual machine, if there is one, then unmount it. 

Install the VirtualBox Guest Additions

Once the mount is done, go to the shell and open the mounted Guest Additions ISO. 

You can see different installer files, run the one which suits your requirement with following command: 
sh VBoxLinuxAdditions.run
Restart the machine and we are almost there... 

Setting up the Shared Folder

Shared Folder functionality is one of the features that comes with the VBox Guest Additions. Once VBox Addition is well installed, the next is to setup a shared folder with the host machine.
First you need to setup shared folder. From the VBox menu open:  Devices -> Shared Folder. 

Then choose the folder from the host machine to share with your guest machine (in my case host is Windows and guest is Linux Fedora 9).


After this, you need to mount the shared folder on Linux guest machine.
Create a folder where you want to mount the shared folder by 
 mkdir share-host
then mount the folder onto the shared folder share-host.
mount -t vboxsf share-host
 

To do an auto-mount on each boot put the command in the /etc/rc.local or whichever script is run at the end of boot processes. 

Sunday, July 1, 2012

Apache Maven - Setting up

What is Apache Maven?

In simple words Maven is a build automation tool for Java projects. 
There are many things which can be written for maven but to get more theoretical details  visit Apache Maven-Wikipedia page or can refer to the official Apache Maven website.


Setting-up Apache Maven:

Setup - Windows:

  1. First download the latest version maven form here. For this tutorial, I have downloaded maven-3.0.4.
  2. Unzip the downloaded apache-maven-3.0.4-bin.zip. In my case, unzipped it in C:\dev\maven3.0.4.
  3. Set a new environment variable M2_HOME pointing to the directory where maven is installed or  unzipped. In case if you don't know how to set an environment variable in windows, follow the link. 
  4. Set another environment variable M2 with value %M2_HOME%\bin. In the same way create/update the PATH variable with value %M2% so that Maven can be accessed from command line. 
  5. Check if the PATH variable also has the value of JAVA_HOME pointing to the installed jdk.
  6. Open command prompt (WinKey + R and type cmd) and execute the command mvn --version to see if its installed well.

Setup - Eclipse:


For this there is a plugin for Eclipse called M2E which can be used to launch Maven builds from within Eclipse and other stuff which maven can do.
Follow the steps given below to get M2E on eclipse:
  1. Open Eclipse.
  2. From the eclipse menu list, go to help -> Install New Software...
  3. Get maven from the update site "maven - http://download.eclipse.org/technology/m2e/releases".
    • Add the maven update site and get the list of plugins provided by it.
    • Select the plugin Maven Integration for Eclipse and press next and next.
    • Read and accept the terms of license agreement and press finish.


    • Restart eclipse.

More on Maven:

Feel free to share your experience/issues. 

Thursday, June 28, 2012

Windows Environment Variable

Setting Up Windows Environment Variable

Following steps are for Windows 7.

  1. Open system properties either by using shortcut WinKey + Pause or right click on My Computer -> Properties.
  2. Open Advanced System Setting. 
  3. Go to the Advanced  tab.
     
  4. Open Environment Variable. by using the button at the bottom right with the same name.
  5. Now depending on your requirement either add a new variable or use the existing one.
      
And that's done. 


Cheers,
fLiCkEr.

Tuesday, June 26, 2012

Python in Eclipse [PyDev plugin for Eclipse]

While learning python, one question I had was, which python IDE to use? There are many options but being a Java developer I wanted to have something like Eclipse and it turned out that there is a plugin for eclipse which can be used for Python development with the auto-suggest, run, debug and many other features.

The plugin for eclipse is called PyDev and it's very easy to configure. 
Note: I work on a windows machine, so all the instructions are around a windows machine. 
  • Get Python:
    • Download the recent version of python from python.org.
    • Run the setup file (python-.msc) and follow the install insrtuction. 
    • Once the installation is complete, set the windows environment variable to point to the python installation folder.
      • Right click on "My Computer".
      • Select "properties". 
      • Click on the button "Environment Variables" under the tab "Advanced".


      • Add the path of python installation to the PATH variable, in my case its "D:\Python27\".


    • Go to dos command line and type the command ">python", if it takes you to the python command line, then it works.


  • Get Eclipse and install the PyDev plugin.
    • Download a version of Eclipse IDE from here do the setup you need for other dev. 
    • Now from Eclipse menu go to Help -> Install New Software. 
    • Add the PyDev update site http://pydev.org/updates.


    • Install the plugin. 
  • Configuration of Eclipse. 
    • From eclipse menu, open Window -> Preferences.
    • Look for PyDev -> Interepreter - Python.
    • Click on new and add the python.exe.
      • For windows, it was under the python installation i.e. d:\python27.
      • For linux, find it by running the command >which python






And all done, you are good to go... Play with python in eclipse.


Also check out my new post on Python-pip tool.