Removes the ^M character in Unix/Linux

This script removes the ^M character from the file. Mainly for those who use windows editor to edit Unix/Linux text files. I would definitely recommend VI or emacs if you are messing with Unix/Linux text files. Create a shell script file and copy paste the code below.
#Script to remove the ugly DOS ^M characters
for readfiles in $@
tr -d 'r' < $readfiles > $sometempfile.tmp
mv $sometempfile.tmp $readfiles

Fast tutorial for explain plan on Oracle

user1@testserver : /home/firestorm => sqlplus
SQL*Plus: Release - Production on Wed Jul 2 15:27:33 2008
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
Enter user-name: user1
Enter password: **********
Connected to:
Oracle9i Enterprise Edition Release - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release - Production
dbserver:SQL> @?/rdbms/admin/utlxplan
dbserver:SQL> truncate table plan_table;
Table truncated.
dbserver:SQL> commit;
Commit complete.
dbserver:SQL> explain plan for
2  select count(*) from schemaname.tablename;
dbserver:SQL> select * from table(dbms_xplan.display);
| Id  | Operation              |  Name            | Rows  | Bytes | Cost  |  TQ    |IN-OUT| PQ Distrib |
|   0 | SELECT STATEMENT REMOTE|                  |     1 |       | 26979 |        |      |            |
|   1 |  SORT AGGREGATE        |                  |     1 |       |       |        |      |            |
|   2 |   SORT AGGREGATE       |                  |     1 |       |       | 20,00  | P->S | QC (RAND)  |
|   3 |    TABLE ACCESS FULL   | TABLENAME        |   309M|       | 26979 | 20,00  | PCWP |            |
Note: fully remote operation, cpu costing is off
11 rows selected.
dbserver:SQL> exit;

Temp space check in oracle

Ever got this issue in oracle ... ORA-01652: unable to extend temp segment by x in tablespace TEMP_TS Here is a way to find out if you are really out of temp space
--Temp space total size, free space and used space
SELECT tablespace_name,
total_blocks*16/1024/1024 AS Total_GB,
used_blocks*16/1024/1024 AS Used_GB,
free_blocks*16/1024/1024 AS Free_GB
FROM   v$sort_segment;
--Temp space utilization by user
b.blocks*16/1024/1024 AS GB,
FROM v$session a, v$sort_usage b
WHERE a.saddr = b.session_addr
ORDER BY b.username, b.tablespace, b.blocks;

Unix script to find the total size of files

Create a shell script file and copy paste the code. Please let me know if you find any bugs
awk '
# filesum: list files and total size in bytes
# input: long listing produced by "ls -l"
printf("%15s %s\n", "BYTES", "FILE");
# test for 9 fields, files begin with "-"
NF == 9 &amp;&amp; /^-/ {
++filenum;            # count files
sum += $5;            # accumulate sizes
num = sprintf("%.2f", $5);
while (num ~ /[0-9][0-9][0-9][0-9]/) {
sub(/[0-9][0-9][0-9][,.]/, ",&amp;", num);
sub(/\..*/, "", num);
printf("%15s %s\n", num, $9);    # print size and name
num = sprintf("%.2f", sum);
while (num ~ /[0-9][0-9][0-9][0-9]/) {
sub(/[0-9][0-9][0-9][,.]/, ",&amp;", num);
sub(/\..*/, "", num);
printf("\n%15s total bytes in %d files\n\n", num, filenum);

Converting a grid to excel document in

A little script to convert a gridview to an excel document. This always came handy when someone needed to create a report right out of gridview ... You can call the function like this ...
ExportGridToExcel(grd, "report.xls")
---Copy the code below and paste it in your script
Public Sub ExportGridToExcel(ByRef grdGridView As GridView, ByVal fileName As String)
Response.AddHeader("content-disposition", String.Format("attachment;filename={0}.xls", fileName))
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Dim strWriter As New StringWriter()
Dim HtmlWriter As New HtmlTextWriter(strWriter)
End Sub
Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
'You will need this part else you will get error like "runat=server needs to be before ....."
End Sub