Sunday, March 22, 2009

PERL round function

Following is the round function in PERL, which you can put into your script and actually call to round numbers instead of cutting them with ceil or cut.

In the following round function, you can specify the number to round and the number of digits to show after the decimal.

sub round {
my $number = shift || 0;
my $dec = 10 ** (shift || 0);
return int( $dec * $number + .5 * ($number <=> 0)) / $dec;
}

$result = round(123.4567,3);

it would return 123.457




About url in firefox

There are few special URLs which begins with about: that you can type into the firefox location bar:

about: => The same page as Help -> About
about:blank => A blank page
about:cache => Displays cache statistics and directory location
about:config => GUI for modifying user preferences
about:plugins => List all plugins
about:logo => Displays the firefox logo

There is an extension available for firefox to save advanced preferences. gui:config makes it easier to change preferences that can only be found in the “about:config”. This add on can be downloaded from https://addons.mozilla.org/en-US/firefox/addon/5523

Friday, March 20, 2009

TOAD: Tips and Tricks

Tips for TOAD's sql editor

  • Tired of typing long column/table name while writing a sql query? Use Auto Complete feature of TOAD. Type a part of the table/column name and then press CTRL + . (period). TOAD will automatically identify the name of the table/column and fill in the rest of the word. If there is more than one option available then TOAD will list all the available options and you can select from there.
  • Forgot the queries which you ran in past? In TOAD's sql editor Press ALT + UP/DOWN key and it will show you the past queries (similar to SQL recall feature , F8)
  • You constantly making spell mistakes while writing queries? Right click in the editor and select “Editing Options”. On this new option screen click on the “Auto Replace” button in the bottom right hand corner. Here you will see a list of the common misspelled words our user’s experience. If there are words you constantly misspell, then you can add them to the list by using the “Add” button. So, now in the editor if you mistype the word “select” as “seelct” … it will automatically fix itself once you hit the spacebar.
  • Wanted to control number of rows in your grid? Use OCI array size option to tell toad how many rows you want retrieved at a time. If you want to only see first 100 rows of an table, set this option to 100.
  • Generating Schema Documentation- From the Database menu, select Report -> HTML Schema Doc Generator.