$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! ';
}
Thursday, June 12, 2014
Validate Email Domain in PHP
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
,(?=(?:[^,]*,){16}[^,]*$),(?=(?:[^,]*,){15}[^,]*$)
Tuesday, August 21, 2012
Problem with File.renameTo in java file io
renameTo method in java.io.file 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 java.io.file -renameTo
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 org.apache.commons.io.FileUtils .
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.
copyFile
Overriding struts validate method for showing custom error message
@SuppressWarnings("unchecked")
public void validate()
{
List<String> uploadErrors = (List<String>)getActionErrors();
if (getFieldErrors().get("upload") != null)
{
uploadErrors.addAll((List<String>)getFieldErrors().get("upload"));
}
for (String err : uploadErrors)
{
if ( err.startsWith("Enter the Error Message to be overridden"))
{
clearErrorsAndMessages();
addActionError("Enter new error message");
break;
}
}
}
Tuesday, August 07, 2012
Eliminate Duplicate In Javascript
function eliminateDuplicates(arr) {
var i,
len=arr.length,
out=[],
obj={};
for (i=0;i
Ref :- Link Here
Sunday, August 28, 2011
GrabText Chrome App
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 (http://twitter.com/#!/KK_Webdesigner)
Monday, July 11, 2011
Dimensions for Android
Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi (dots per inch) screen, so160dp is always one inch regardless of the screen density. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. You should use these units when specifying view dimensions in your layout, so the UI properly scales to render at the same actual size on different screens. (The compiler accepts both “dip” and “dp”, though “dp” is more consistent with “sp”.)
sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user’s font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and the user’s preference.
pt
Points - 1/72 of an inch based on the physical size of the screen.
px
Pixels - corresponds to actual pixels on the screen. This unit of measure is not recommended because the actual representation can vary across devices; each devices may have a different number of pixels per inch and may have more or fewer total pixels available on the screen.
mm
Millimeters - based on the physical size of the screen.
in
Inches - based on the physical size of the screen.
To make it absolutely clear – never use any of the above but sp or dp unless you absolutely have to. Using sp / dp will make your Android applications compatible with multiple screen densities and resolutions.
Ref: -http://developer.android.com/guide/topics/resources/more-resources.html#Dimension
Monday, September 13, 2010
Print Mysql Database Structure Using PHP
<?php
$HOSTNAME = 'localhost';
$USERNAME = 'root';
$PASSWORD = '';
$DBNAME = 'rizvi_test_db';
mysql_select_db($DBNAME, mysql_connect($HOSTNAME, $USERNAME, $PASSWORD)) or die(mysql_error());
$result = mysql_query("SHOW TABLES;") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row[0]; //print the table name
$result2 = mysql_query("DESCRIBE ".$row[0].";") or die(mysql_error()); //get details schema for each table
echo "<table border='1' width='70%'>";
echo "<tr><td>Field</td><td>Type</td><td>Null</td><td>Key</td><td>Default</td><td>Extra</td>";
while($row2 = mysql_fetch_array($result2)){
for($i=0; $i<6; $i++){
if($row2[$i] == "" || $row2[$i] == NULL){
$row2[$i] = " ";
}
}
echo "<tr>";
echo "<td>".$row2[0]."</td><td>".$row2[1]."</td><td>".$row2[2]."</td><td>".$row2[3]."</td><td>".$row2[4]."</td><td>".$row2[5];
echo "</tr>";
}
echo "</table>";
echo "<br/>";
}
?>
Wednesday, September 01, 2010
How to remove mootools.js and caption.js from Joomla1.5 ?
<script type="text/javascript" src="/media/system/js/mootools.js"></script>
<script type="text/javascript" src="/media/system/js/caption.js"></script>
To remove above javascript's import, you just need to
add the following code at the top of your template's index.php file.
<?php
//remove mootools.js and caption.js
$headerstuff=$this->getHeadData();
reset($headerstuff['scripts']);
foreach($headerstuff['scripts'] as $key=>$value){
unset($headerstuff['scripts'][$key]);
}
$this->setHeadData($headerstuff);
?>
Thursday, May 27, 2010
മെയ് 26 2009
Btech കഴിഞ്ഞിട്ടു ഒരു മാസം ആകാറായി , നാലഞ്ച് interview ഒക്കെ അറ്റന്ഡ് ചെയ്തു ചൊറിയും കുത്തിയിരിക്കുന്ന സമയം , മേനിയാന്നത്തെ പത്രതില്ലേ പരസ്യം കണ്ടു ഒരു PHP interview ന്നു എറണാകുളം പോകാന് നില്ക്കുന്നു . കഴിയ്യില്ല് w3schools ന്നും അടിച്ചുമാറ്റിയ ചില PHP നോട്ട്സ് മാത്രം .
ഒരു തുള്ളി ജല പാനം പോലലും കഴിക്കാതെ intercity യിലല് ചാടി കയറി ..... 10 30 യോഒടെ EKM എത്തി ........... interview ക്ക് എത്തിപെട്ടത് ഒരു കൂതറ സ്ഥലത്ത് ....... അവര്ക്ക് 6000 രൂ വേണമെന്ന് ........ പോയി പണി നോക്ക്കാന് പറഞ്ഞു ..
ഞാന് ഇറങ്ങി .......... 2 : 15 ന്റെ നേത്രാവതിക്ക് .......കയറാം ...എന്ന് കരുതീ...എറണാകുള തില്ലേ ...ഒടുകത്ത ട്രഫ്ഫികും താണ്ടി .............2 : 15 ന്നു ......എത്തിയപോഴേക്കും ......ട്രെയിന് അതാ പോകുന്നു
........അവസാനത്തെ boogie യും ലക്ഷ്യം വെച്ച് ഒരു സിനിമ style chasingനടുത്തി ............ ട്രെയിന് ഇല്ലെക്ക് ചാടിയപ്പോഴേക്കും ........ റെയില്വേ പോലീസ് ന്റെ ലാത്തി ...എന്നെ വിഴുത്തി.......platform ഇല്ലെക്ക് തെറിച്ചു വീണ എന്നെ ഒരുത്തനും mind ചെയ്തില്ല .........പോരാത്തതിനു .......പോലീസ് കാരന്റെ ........തെറിയുംമ്മം
........ഒരു വിധം കഷ്ട്ടപെട്ടു .......bench ഇല്ലിരിന്നു ......... എന്നെനി അടുത്ത ട്രെയിന് 4 :20 ന്നെ ഉളു ..... സമയം പോക്കന് വേണ്ടി ...... ജോസ് jn ....left ഇല്ലോട്ടു ഒരു പിടിത്തം പിടിച്ചു ........ ഒരു ഒന്നൊന്നര കിലോ മീറ്റര് ..... കഴിന്നു ... കൊച്ചിന് Shipyard എതിയപോള് ..... ഒരു ആഗ്രഹം .........shipyard കാണണം ..............
തൊട്ടടുത്തുള്ള ....vallamattam estate 5th floorillu കയറി ........Shipyard കണ്ടു ..... കൊള്ളാം !!! ......... തിരിഞ്ഞു നോക്കിയപ്പോള് ..അതാ അവിടെ ....ഒരു സോഫ്റ്റ്വെയര് കമ്പനി .........
e2Mars ............ഏതായാലും അവിടെ എത്തി ..........ഒന്ന് കയരികളയാം എന്ന് കരുതി ............ Central Manager സതിഷ് ഫിലിപ്പ് ....... ഇന്നേ കണ്ടു ......കൊറേ സമസാരിച്ചു ....... .... ആദ്യം ഇംഗ്ലീഷ് ആയിരുന്നു ...പിന്നെ .......എന്റെ അവസ്ഥ കണ്ടു അങ്ങേരു മലയാളം ആക്കി .........
എന്റെ കാഴിച്ചപടുക്കള് ....നന്നായി ബോധിച്ചു ........അങ്ങനേ എന്നെ അവിടെ ........ എടുത്തു ....... ഒരു മാസം ........ അപ്പ്രെന്ടിസയിട്ടുഇ .......... 5 ദിവിസം കൊണ്ട് php , html , css ..തുടങ്ങിയവ....പടിച്ചുവര്ര
1st ജൂണ് ഇന് DOJ തന്നു ............
ഇന്നു "മെയ് 26 2010 " ........ ഒരു വര്ഷം .......... കഴിഞ്ഞ 21 വര്ഷം ജീവിച്ചതിനെക്കള് കുടുതല്ല് ...ഞാന് ജീവിച്ചു
............ കഥ തുടരും ........
Saturday, April 17, 2010
change all text in a column to caps
Sub change()
Dim rng As Range, cell As Range
Set rng = Range("A1:A" & Cells(65536, "A").End(xlUp).Row)
For Each cell In rng
If (cell.Value <> "") Then
cell.Value = UCase(cell.Value)
End If
Next cell
End Sub
Load any module within a joomla 1.5 content article
One of the questions that often gets asked is "How can I load a Joomla! 1.5 Module into a content Article? This is in fact an easy thing to do, and can provide useful solutions such as:
By default, Joomla! Modules can be placed in any Module Position of the Template, but they do not load into Content Articles. This tutorial will explain how to enable and use Module loading within your Joomla! Articles, Here are the steps: Step 1 - Create a new Module or Copy an existing one.Within your Joomla! Administration, navigate to Extensions > Module Manager. If you are creating a new Module, click on the New button at the top right of the screen, or you can put a tick in the box next to an existing Module and copy it using the Copy button. If you copy an existing Module, the new Module will be created or copied and placed within the Module listing. Step 2 - Edit the Module
On the left side of the Module Edit Screen you will see some properties such as Module Title, Enabled, Module Position etc. Here is where the power of Joomla! shows itself. Usually we would just click on the Module Position field and select an available Module Position, but it is also possible to enter in your own value here as believe it or not, this field is editable! We need to edit this field and enter in a custom Module Position Name which will be used for our in-content use. Instead of clicking on the Arrow next to this field, click on the text within the field, and enter in your own value such as, content_custommod If you need to make other changes to your Module parameters then do so and when you are finished, make sure you click the "SAVE" button at the top right of the screen. Your new custom module position will then be saved with this Module. Step 3 - Check the Plugin
Step 4 - Load Module in ArticleNavigate to the Article Manager Screen, and Edit the Article you wish to load the Module within. Click on it's title to load the Article Edit Screen. Within the desired location of the Article, enter the following syntax in, which is code to tell the Module to load.
IMPORTANT NOTE: Do not enter in a common Template Module Position such as "Top" or "Left" into your loadposition tag. This may display all of the modules that are then set to show in that Position. |
Monday, April 05, 2010
Tiny Mce Joomla 1.5 Editor Image Browse Is Not Working [SOLVED]
Well the problem is with flash. So if it is not working for you just do this
Go to: administration mode
Menu: Site, Global Configuration
Choose: Enable Flash Uploader [No]
Friday, April 02, 2010
Get Menu Alias in Joomla
$theMenu = JSite::getMenu();
$theActiveMenu = $theMenu->getActive();
return $theActiveMenu->alias;
}
Thursday, April 01, 2010
Access joomla session from external pages
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
$session =& JFactory::getSession();
$myUser = $session->get( 'myUser', 'empty' );
Wednesday, March 31, 2010
php-smtp-email-validation
Example :
// include SMTP Email Validation Class
require_once('smtp_validateEmail.class.php');
// the email to validate
$email = 'user@example.com';
// an optional sender
$sender = 'user@mydomain.com';
// instantiate the class
$SMTP_Validator = new SMTP_validateEmail();
// turn on debugging if you want to view the SMTP transaction
$SMTP_Validator->debug = true;
// do the validation
$results = $SMTP_Validator->validate(array($email), $sender);
// view results
echo $email.' is '.($results[$email] ? 'valid' : 'invalid')."\n";
// send email?
if ($results[$email]) {
//mail($email, 'Confirm Email', 'Please reply to this email to confirm', 'From:'.$sender."\r\n"); // send email
} else {
echo 'The email addresses you entered is not valid';
}
Tuesday, March 30, 2010
Load the Joomla scripts in a Non-Joomla PHP Script
define( '_JEXEC', 1 );
define( '_VALID_MOS', 1 );
// JPATH_BASE should point to Joomla!'s root directory
define( 'JPATH_BASE', realpath(dirname(__FILE__) .'/' ) );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
$user =& JFactory::getUser();
$session =& JFactory::getSession();
Joomla User Authentication Script For External websites
$result = mysql_query($query);
if (mysql_num_rows($result)>0){
$dbpassword=mysql_result($result, 0);
mysql_close($link);
list($md5pass, $saltpass) = split(":", $dbpassword);
if ((md5($_POST["passwd"].$saltpass))==$md5pass) {
echo "Success" ;
} else {$messaggio="Password error:";}
}