Skip to main content

Posts

Display dynamic content in Google Earth using KML

Keyhole Markup Language (KML) is a xml standard which can be used to define what and how to present geographic data in Google Earth and Google Maps. Useful examples to start can be browsed via https://developers.google.com/kml/documentation/kml_tut . I have to display KML data in googleearth. And the KML file has to be loaded dynamically and the updates in the kml file should be shown in the googleearth on the fly. For this we have to Create a Network Link. Goto Add -> Network Link Then specify the details as shown in the figure. To specify the frequency of updating the data, go to Refresh tab. The code for dynamicKML.kml is as follows: junk.kml onInterval 5 Note that, we are using a local file junk.kml   ( junk.kml and dynamciKML.kml reside in the same directory) to define the content to be displayed in the google earth interface. This can even be a remote file in which case we have t...

python code for querying own IP address

The  socket.gethostname() function is supposed to give the IP address of the machine but it may not give the real IP address but gives 127.0.0.1 . Even it is said that removing 127.0.0.1 from the /etc/hosts file (in ubuntu) can give the real IP but it could not help in my case. import socket nodeName = socket.gethostname() info = socket.getaddrinfo(nodeName, None, 0, socket.SOCK_STREAM) print [x[4][0] for x in info]   # prints 127.0.0.1 I came through another way which can print the real IP as well: import commands NodeIPS = commands.getoutput("/sbin/ifconfig | grep -i \"inet\" | grep -iv \"inet6\" | " +                          "awk {'print $2'} | sed -ne 's/addr\:/ /p'") print NodeIPS  # prints 127.0.0.1 and realIP(eg. 202.145.12.22) Note: code worked for ubuntu 12.04 and python 2.7 Sometimes its handy to have the IP address as list items. The following code does the work. impo...

Open file with unlisted application in ubuntu 12.04

In ubuntu 12.04, While browsing files in nautilus, if we want to open file with unlisted applications, for e.g. open a file with idle(but idle is not listed in the list of open with ). Enter the following command in the terminal: gksudo gedit /usr/share/applications/idle.desktop Then remove the line: Exec=/usr/bin/idle -n Replace it with: Exec=idle %U Now we can see idle listed in the list of open with applications. To set it as default application to open a file. Go to the file properites, select idle and click set as default.

Metaheuristics

Generally speaking heuristics aim to find a good enough solution to a problem in a reasonable amount of time. These are mostly based on experiences and common sense. Metaheutistics iteratively tries to improve a candidate solution with respect to a given measure of quality.They rarely make assumptions about the problem being optimized They can search very large spaces of candidate solutions. Whereas they do not guarantee the finding of an optimal solution. Some of the popularly used metaheuristics for optimization problems are: • Simulated Annealing (SA), • Particle Swarm Optimization (PSO), • Differential Evolution (DE), • Genetic Algorithm (GA), • Evolutionary Strategy (ES).

secure shell (ssh)

Two machines running a server and a client running respectively can be connected securely via ssh.  ssh user@serverIP example: ssh tom@203.159.11.42 Every time a user logs in to the server user have to provide password for getting into the server.Whereas passwordless authentication using the public key is considered more secure while loggin to a remote server. For that the following steps should be followed: 1. Generate public/private rsa key pair: ssh-keygen -t rsa When password is asked just hit a "ENTER" to leave it empty 2.Now use ssh to create a directory ~/.ssh as user (e.g. "tom") on server(e.g. 203.159.11.42). ssh tom@203.159.11.42 -p .ssh 3.Copy key to remote server cat .ssh/id_rsa.pub | ssh tom@203.159.11.42 'cat >> .ssh/authorized_keys' After finishing these three steps, login to the remote server with ssh will not require password.

Installing NS-3 in Ubuntu

Installing testing it and running NS-3 in Ubuntu 10.04 NS-3 is a discrete-event network simulator basically for simulating Internet systems. #The list of Dependency for ns 3.12(sorry if something is missing): sudo apt-get install gcc g++ python sudo apt-get install gcc g++ python python-dev sudo apt-get install mercurial sudo apt-get install bzr sudo apt-get install gdb valgrind sudo apt-get install gsl-bin libgsl0-dev libgsl0ldbl sudo apt-get install flex bison sudo apt-get install g++-3.4 gcc-3.4 sudo apt-get install tcpdump sudo apt-get install sqlite sqlite3 libsqlite3-dev sudo apt-get install libxml2 libxml2-dev sudo apt-get install libgtk2.0-0 libgtk2.0-dev sudo apt-get install libgtk2.0-0 libgtk2.0-dev sudo apt-get install vtun lxc sudo apt-get install uncrustify sudo apt-get install doxygen graphviz imagemagick sudo apt-get install texlive texlive-pdf texlive-latex-extra texlive-generic-extra texlive-generic-recommended sudo apt-get install python-sphinx dia t...