Tuesday, October 26, 2010

Get map for latitude & longitude using Google Maps API

Google provides a FREE Java Script map API for longitude & latitude. Simple demonstration is given below. Position marker, mouse wheel zooming, Map view/Satelite view/Hybrid view controls are enabled in the example.

NOTE :- Map searching is commented.

<html>
<head>
<script type="text/javascript"
src="http://www.google.com/jsapi?key=ABCDEFG"></script>
<script type="text/javascript">
google.load("maps", "2");
// google.load("search", "1");
// Call this function when the page has been loaded

function initialize() {
var map = new google.maps.Map2(document.getElementById("map"));
map.setCenter(new google.maps.LatLng(7, 80), 13);
map.enableRotation();
map.addControl(new GOverviewMapControl());
map.enableDoubleClickZoom();
map.enableScrollWheelZoom();
map.addControl(new GMapTypeControl());

map.addControl(new GSmallMapControl());

var marker = new GMarker(new GLatLng(7, 80));
map.addOverlay(marker);
map.setMapType(G_SATELLITE_MAP);

// var searchControl = new google.search.SearchControl();
// searchControl.addSearcher(new google.search.WebSearch());
// searchControl.addSearcher(new google.search.NewsSearch());
// searchControl.draw(document.getElementById("searchcontrol"));
}

google.setOnLoadCallback(initialize);
</script>
</head>
<body>
<div id="map" style="width: 500px; height: 500px"></div>
<!-- <div id="searchcontrol"></div> -->
</body>
</html>

Reference :- http://code.google.com/apis/ajax/documentation/ 

Tuesday, October 12, 2010

Shell Script to load data from a TableA to TableB in mysql

Suppose you have to select custom fields in TableA and insert those fields into TableB in mysql, then the following shell script command would be appropriate.

mysql -u user -p -D database -e 'insert into TableB select id, addr from TableA;'

Insert above code in a file and save it as ".sh" file extension. Then run it as "./Test.sh".

NOTE :- Test.sh must be stored in the server that mysql db server is running.

Thursday, October 7, 2010

Remove non empty directory in linux

Use the below command to remove non empty directory in Linux without prompting for verification "yes" or "no".

rm -rf directory

This will remove all the contents in the directory without asking further verifications for files deletion.