Thursday, July 19, 2012

Remove all alpha-numeric characters from a phone number

Hi Friends,

To remove all alpha-numeric characters from a phone number.. in php simple one line code..


$phoneStr = "+91-23223-24232";

$phone = preg_replace('/\D+/', '', $phoneStr  );


resulted phone number will be plain number like 912322324232


Enjoy!!!
Ravi

Remove Yahoo Search from Firefox

Hi Friends,

Yahoo messenger sometimes installs yahoo search in firefox. And when we search something from address bar, it displays yahoo search results. I never want so.. I wanted google back and here it is how to do so..

1. Open about:config in firefox. Just type about:config in address bar.
2. It will ask whether you will be careful or not.. say I'll be careful, I promise!
3. In the search bar search for keyword.url
4. Modify the value to your favorite search engine. I wanted google so I modified the value to
http://www.google.com/search?q=
Now it will be searching google only.. enjoy!!!

-Ravi

Thursday, May 17, 2012

Change Author Name in Eclipse for JavaDoc

Hi Everyone,

I got my system from office with some strange username and the same username is taken by eclipse while adding documents. I wanted to change that to my proper name. Here is how we can change it..

Open Eclipse installation folder and modify the file eclipse.ini
Add this line in the file..
-Duser.name=your name

Restart Eclipse and it should work fine.

Cheers!!!
Ravi Kumar Gupta 

Tuesday, March 6, 2012

Disable Input Type Text using JQuery

Hi Friends,

Here is how you do it..
Disable a text box which is given id as username.
$("input#username").attr('disabled','disabled');


Enable a text box which is given id as username.
$("input#username").removeAttr('disabled');


Cheers!!!
Ravi Kumar Gupta

Saturday, March 3, 2012

[PHP] Error Reporting : Turn off Warnings/Errors/Notices

Hi Friends,

Recently I was writing a simple personal site. I had to add some php script as well to communicate with mysql server. For any error, warning, I used to see messages in browser which can be frustrating at times. If you are looking for a way to disable those messages.. here it is.

We are going to use error_reporting($level) function of php. Syntax is:
int error_reporting ([ int $level ] )

Write this in php file where you want.
<?php
// Turn off all error reporting
error_reporting(0);

// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);

// Report all PHP errors (bitwise 63 may be used in PHP 3)
error_reporting(E_ALL);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

?>

Thats how you do.. Cheers!!!

-Ravi -aka- D'Maverick