Sunday, August 14, 2011

Getting Nth highest salary (will work for all databases)

SELECT * FROM employee e1 WHERE (n-1)=(SELECT COUNT(DISTINCT salary) FROM employee  e2 WHERE e2.salary>e1.salary)

*n - Nth highest salary

Wednesday, July 20, 2011

How to get Latitude and Longitude of a location

  • Open maps.google.com.
  • Point the position, which latitude and longitude require.
  • Place the below JS code in address bar of your browser.
javascript:void(prompt('',gApplication.getMap().getCenter()));
  • A popup alert will show you the latitude and longitude of the selected location.

Friday, July 1, 2011

Linux - Useful commands

Search any software and its version:
apt-cache search software_name


Install software:
sudo apt-get install software_name

Install sh file:

sudo sh file_name.sh

Saturday, June 25, 2011

Perl - How to install and configure Perl with Apache web server on windows

1. Install ActivePerl on your windows machine as per your OS.

2. Downlaod "mod_perl.so" file and place under "Apache/modules" folder.

3. Create "startup.pl" under "apache at your system/conf/extra".

use ModPerl::Util ();
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::RequestUtil ();
use Apache2::ServerRec ();
use Apache2::ServerUtil ();
use Apache2::Connection ();
use Apache2::Log ();
use Apache2::Const -compile => ':common';
use APR::Const -compile => ':common';
use APR::Table ();
use Apache2::compat ();
use ModPerl::Registry ();
use CGI ();
1;

4. Create "httpd-perl.conf" under "apache at your system/conf/extra".

LoadFile "Perl/at/your/system/path/bin/perl-x.dll"
LoadModule perl_module modules/mod_perl.so
PerlPostConfigRequire "apache at your system/conf/extra/startup.pl"

AddType text/html .pl

SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders

SetHandler cgi-script

5. Restart your apache and write the below test perl code under your web-root as "demo.pl"

print "Content-type: text/plain;\n\n";
print "Hello Perl"

6. Run the code in web browser as

http://web-root/demo.pl