Find the Geopgraphical Location of an IP Address

There are a few applications that give the geographical location of an IP address *. My favorite one is VisualRoute. It not only maps the location of the source and destination IP addresses, but also all the hops in between. The down side to it is that it is not available for Linux and it costs $50 per user.

The http://mapulator.com site gives you pretty much the same information online for free, but it has been down for quite some time now.

Lately I have been using http://whatismyipaddress.com/ip-lookup. But it only maps the destination IP address.

If anyone knows of a Linux application that would map all the hops and the final IP destination, please leave a comment!

* IP addresses do not have a geographical location per se. Any program that maps IP addresses can only give you where the whole class of IP addresses (that the specified IP address belongs to) is registered to be located at. They do this by querying a database that has that information. This is accurate down to a city level at best. Do not expect to find where someone lives by their IP address!

Monday, June 28th, 2010 Linux, Networking No Comments

Install Subversion and Subclipse for Eclipse on Ubuntu

If you do not have Eclipse installed yet, run:

sudo apt-get install eclipse

Install Subversion

sudo apt-get install subversion

Install the Subversion plugin for Eclipse

Get the Java bindings for Subversion:

sudo apt-get install libsvn-java

Now we are ready to install the plugins in Eclipse.

Open Eclipse.

Go to Help -> Install New Software

Then hit the “Add” button.

Put “Subclipse 1.6.x (Eclipse 3.2+)” under Name and “http://subclipse.tigris.org/update_1.6.x” under Location:

Add the libraries for Subclipse

Add the libraries for Subclipse

The above is for Elclips 3.2+ and Subversion 1.6.x.

If you have different Eclipse or Subversion versions, check this list and substitute accordingly:

Name: Subclipse 1.6.x (Eclipse 3.2+)
URL: http://subclipse.tigris.org/update_1.6.x

Name: Subclipse 1.4.x (Eclipse 3.2+)
URL: http://subclipse.tigris.org/update_1.4.x

Name: Subclipse 1.2.x (Eclipse 3.2+)
URL: http://subclipse.tigris.org/update_1.2.x

Name: Subclipse 1.0.x (Eclipse 3.0/3.1)
URL: http://subclipse.tigris.org/update_1.0.x

More info about the different versions: http://subclipse.tigris.org/servlets/ProjectProcess?pageID=p4wYuA

Then hit “OK”. You will now be presented with these options:

Subclipse Installation Options

Subclipse Installation Options

If you are unsure what Subclipse component you will need, you can check all of them. Also, keep in mind that you can always go back to this in the future and install/uninstall any of the components as needed.

Then “Next” and “Finish” on the subsequent screens.

After the plugins are installed, it will prompt you to restart Eclipse. Go ahead and do so.

You are not done yet. You need to fix the JavaHL.

Edit the eclipse.ini file:

sudo vi /usr/lib/eclipse/eclipse.ini

Add the following line under -vmargs:

-Djava.library.path=/usr/lib/jni

Here is what my eclipse.ini file looks like:

$ cat /usr/lib/eclipse/eclipse.ini
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.0.200.v20090520
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-startup
--launcher.library
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-startup
/usr/lib/eclipse/plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
/usr/lib/eclipse/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.0.200.v20090520
-vmargs
-Djava.library.path=/usr/lib/jni
-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=//usr/share/eclipse/dropins
-Xms40m
-Xmx256m
-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=//usr/share/eclipse/dropins

For more info on fixing JavaHL if you need it: http://subclipse.tigris.org/wiki/JavaHL#head-bb1dd50f9ec2f0d8c32246430c00e237d27a04fe

You should be able to use Subversion with Eclipse for your projects at this point.

Thursday, June 17th, 2010 Eclipse, Linux, Ubuntu 3 Comments

How to connect your Android phone to Ubuntu to do development, testing, installations or tethering

If you do any Android development in Ubuntu it is much better to test your applications on a real device rather than just relying on the emulator.

If you just connect the phone to the computer through USB and run adb devices you will find out that your phone is not recognized:

$ adb devices
List of devices attached
???????????? no permissions

This is easily fixable in Ubuntu. You have to add a line to a file in the /etc/udev/rules.d directory.

What line in which file depends on the manufacturer and model of the device. You can find out the Vendor ID number and Product ID number of the device by running (after you connected it via USB of course):

$ lsusb

For example, if you had a Nexus One connected you would get:

Bus 002 Device 004: ID 18d1:4e12

In this case the Vendor Id is “18d1″ and the Product ID is “4e12″. Please keep in mind that the Vendor ID for HTC changed from “0bb4″ to “18d1″. The older HTC phones like the G1 have a Vendor ID of “0bb4″.

Here is how to set up some of the major Android phones:

Step 1. Enable Unknown sources and USB debugging:

Go to Settings -> Applications and check the Unknown sources check-box, then go to Development and enable the USB debugging.

Step 2. Depending on your phone follow these instructions:

  • G1
    Create/edit a file in /etc/udev/rules.d called 51-android.rules:

    $ sudo gedit /etc/udev/rules.d/51-android.rules

    Add the following line to it and save it:

    SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0c01″, MODE=”0666″

  • HTC Hero

    Add to the file (or create it if it does not exist- see above) /etc/udev/rules.d/51-android.rules the following line:

    SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0c02″, MODE=”0666″

  • HTC EVO

    Add to the file (or create it if it does not exist- see above) /etc/udev/rules.d/51-android.rules the following line:

    SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0c8d”, MODE=”0666″

  • HTC EVO Shift

    Add to the file (or create it if it does not exist- see above) /etc/udev/rules.d/51-android.rules the following line:

    SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0ca5″, MODE=”0666″

  • HTC ThunderBolt

    Add to the file (or create it if it does not exist- see above) /etc/udev/rules.d/51-android.rules the following line:

    SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0ca4″, MODE=”0666″

  • LG OPTIMUS LG-P506

    Add to the file (or create it if it does not exist- see above) /etc/udev/rules.d/51-android.rules the following line:

    SUBSYSTEMS==”usb”, ATTRS{idVendor}==”1004″, ATTRS{idProduct}==”618e”, MODE=”0666″

  • Motorola Xoom

    Add to the file (or create it if it does not exist- see above) /etc/udev/rules.d/51-android.rules the following line:

    SUBSYSTEMS==”usb”, ATTRS{idVendor}==”22b8″, ATTRS{idProduct}==”70a9″, MODE=”0666″

  • Motorola Droid
    Create/edit a file in /etc/udev/rules.d called 10-motorola-droid.rules:

    $ sudo gedit /etc/udev/rules.d/10-motorola-droid.rules

    Add the following line to it and save it:

    SUBSYSTEMS==”usb”, ATTRS{idVendor}==”22b8″, ATTRS{idProduct} ==”41db”, MODE=”0600″

  • Nexus One
    Create/edit a file in /etc/udev/rules.d called 99-android.rules:

    $ sudo gedit /etc/udev/rules.d/99-android.rules

    Add the following line to it and save it:

    SUBSYSTEM==”usb”, ATTRS{idVendor}==”18d1″, SYMLINK+=”android_adb”, MODE=”0666″

Step 3. Restart udev:

$ sudo restart udev

Check if the device is recognized:

$ adb devices

You may need to stop and start the adb server:

$ adb kill-server
$ adb start-server

Update: Please note that some devices require to disconnect the usb cable at this point and then reconnecting it.

You should be good to go…

Wednesday, May 12th, 2010 Android, Eclipse, Java 47 Comments

Extract Audio (.mp3) from Video Files Like .flv, .mov, .avi and Others with Ubuntu

It is very easy to extract the audio track from video files using Linux. All you need is ffmpeg and some codecs.

Let’s get started…

Note: The commands below are for Ubuntu (or Debian derivatives) but you can do the same with any other Linux distribution provided you can install the necessary packages.

1. Add the Medibuntu’s repository to your sources.list:

sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update

2. Install ffmpeg:

sudo apt-get install ffmpeg

3. Let’s get the restricted packages and some codecs installed:

sudo apt-get install ubuntu-restricted-extras libmp3lame0 libdvdcss2 w32codecs

The above command is for i386 architecture. If you have an amd64 architecture, substitute w32codecs with w64codecs.

Note: This is not a complete list of codec packages by any stretch of the imagination. It will get you started though and you will be able to do most formats, but you might have to add codecs as you go along.

4. Now we are ready to extract the audio from the video files:

ffmpeg -i input_file.flv output_file.mp3

The above command will extract the audio from a Flash video file. You can do the same for a QuickTime file as well:

ffmpeg -i input_file.mov output_file.mp3

Or for an Audio Video Interface file:

ffmpeg -i input_file.avi output_file.mp3

YouTube and other video web sites:

Having done all this, now we can download flash files from places like YouTube and strip the audio from them. All you need besides the steps above is a way to save the Flash files (.flv) from YouTube. An easy way to do that is by using Firefox Add-ons like Download Flash and Video or Flash Video Downloader.

The quality of the audio in the YouTube videos for example is 64 bit/sec. Most of the mp3 files are normally compressed to 128 bit/sec or above. Obviously the quality will not be the same, but a human year cannot tell the difference.

The quality of the extracted mp3 will depend on the quality of the audio track in the video file. So the above statement about the 64 bit/sec audio is mostly the case for the files on some video sharing sites.

Wednesday, January 20th, 2010 Linux, Ubuntu 8 Comments

How to Resume Partial File Transfers

I work primarily with UNIX and Linux machines and scp is my main choice to transfer files with. It is both convenient, short and secure.

Example:

scp localfile user@remotecomputer:/path/to/target/dir

Recently I was transferring an 8GB file and due to a network issue, the transfer was interrupted at nearly 40%.

I have learned over the years that there is often little which can be done to prevent such interruptions. I know that many people go to great lengths to find Broadband which is reliable, but sometimes disruptions simply cannot be avoided. Of course, this can be both frustrating and time-consuming, but there is a quick fix. Although such disruptions can’t be prevented, there is a fast and easy way to resume them. Resuming has relatively few system requirements, and can save a lot of time and hassle when transferring large files.

I found a solution at joen.dk ,which uses rsync to resume the transfer:

rsync --partial --progress --rsh=ssh host:remote_file local_file

Now we can improve this slightly by shortening the above command. We can substitute –rsh=ssh with -e ssh, and use -P instead of –partial –progress. Also, you can add user@host if you need to specify a different remote shell user:

rsync -P -e ssh user@host:remote_file local_file

This above example will work with any file that was partially transfered. How the transfer was started does not really matter. It could be through scp, nc or even ftp. After you execute the above command it will take rsync a little time to verify the previously downloaded part before it continues with the rest. Be patient, depending on your network speed rsync could take some time to go through what you have already transfered. Of course this is much faster than if you were to start the download all over again and it shows you the progress in percentages.

Keep in mind that there have to be a couple of requirements in place in order to resume the file transfer with rsync:

1. You should have remote shell access.
2. The remote machine should have rsync installed. Since rsync is by default on most Linux distributions that generally should not be an issue.

Friday, January 8th, 2010 Linux, MacOS X, Networking, Ubuntu 2 Comments