Sunday, June 14, 2015

Run Apache As "Specific User" in Ubuntu

Access Below Command From Terminal

         sudo nano /etc/apache2/envvars


Modify Below Lines

         export APACHE_RUN_USER=specific_user
 export APACHE_RUN_GROUP=specific_user


Tuesday, June 09, 2015

Convert Mysql Time Stamp To Formatted Date


         Select DATE_FORMAT(FROM_UNIXTIME(`created_date`), '%e %b %Y') AS 'date_formatted';


Find The Distance Between Two Lat/Long using mysql functions


CREATE DEFINER=`root`@`localhost` FUNCTION `mm_calc_distance`(`lat1` double, `long1` double, `lat2` double, `long2` double) RETURNS double
 DECLARE distance_in_km double;
           111.1111 *
           * COS(RADIANS(lat2))
           * COS(RADIANS(long1 - long2))
           + SIN(RADIANS(lat1))
           * SIN(RADIANS(lat2)))) into distance_in_km;

        RETURN distance_in_km;


Gist Github Url For Source Code 

Thursday, June 12, 2014

Validate Email Domain in PHP

        $email_domain = preg_replace('/^.+?@/', '', $email).'.';
 if(!checkdnsrr($email_domain, 'MX') && !checkdnsrr($email_domain, 'A')){
    echo $email.' doesnot exist';
 } else {
  echo 'Email Domain '.$email_domain.' exists! ';

Tuesday, April 22, 2014

Sublime Text - Parse CSV - Find Nth and N-1 th comma from EOL

In Sublime Text - Do A Find [using regular expression] - Apply the below expression


Tuesday, August 21, 2012

Problem with File.renameTo in java file io

renameTo method in may not work always [For eg: During File Upload - if destination and source is in different file system, renameTo fails]
As per the documentation of -


public boolean renameTo(File dest)
Renames the file denoted by this abstract pathname. Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file with the destination abstract pathname already exists. The return value should always be checked to make sure that the rename operation was successful.

Alternative approach is you can use .


public static void copyFile(File srcFile,
                            File destFile)
                     throws IOException
Copies a file to a new location preserving the file date.This method copies the contents of the specified source file to the specified destination file. The directory holding the destination file is created if it does not exist. If the destination file exists, then this method will overwrite it.

Overriding struts validate method for showing custom error message

Overriding struts validate method for showing custom error message during FileUpload
      public void validate()  
       List<String> uploadErrors = (List<String>)getActionErrors();  
       if (getFieldErrors().get("upload") != null)  
       for (String err : uploadErrors)  
        if ( err.startsWith("Enter the Error Message to be overridden"))  
         addActionError("Enter new error message");  

Tuesday, August 07, 2012

Sunday, August 28, 2011

GrabText Chrome App

Check out Chrome App GrabText we developed
GrabText Chrome App

GrabText V 0.1 is a Free Chrome App to Grab the Text to your phone.

Scan the QR Code and Grab the Text. 
An easy way to copy any text in webpages to your smartphone.

This is based on HTML5/JS/Chrome Handle/Google Infographic charts.

Please download and write your review for the app

Version 1.0 is under construction. V1.0 will have feature to categorize phone number/url/email/text

Logo Designed By KK (!/KK_Webdesigner)