Posted by Admin
on April 01, 2009
.NET /
1 Comment
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.Clear()
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)
grdGridView.RenderControl(HtmlWriter)
Response.Write(strWriter.ToString)
Response.End()
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
Posted by Admin
on April 01, 2009
Shell /
No Comments
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\”
BEGIN {
printf(\”%15s %s\\n\”, \”BYTES\”, \”FILE\”);
}
# test for 9 fields, files begin with \”-\”
NF == 9 && /^-/ {
++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][,.]/, \”,&\”, num);
}
sub(/\\..*/, \”\”, num);
printf(\”%15s %s\\n\”, num, $9); # print size and name
}
END {
num = sprintf(\”%.2f\”, sum);
while (num ~ /[0-9][0-9][0-9][0-9]/) {
sub(/[0-9][0-9][0-9][,.]/, \”,&\”, num);
}
sub(/\\..*/, \”\”, num);
printf(\”\\n%15s total bytes in %d files\\n\\n\”, num, filenum);
}\’
Posted by Admin
on April 01, 2009
Oracle /
No Comments
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,
used_blocks,
free_blocks,
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
SELECT
b.tablespace,
b.segfile#,
b.segblk#,
b.blocks,
b.username,
b.blocks*16/1024/1024 as GB,
a.SID,
a.serial#,
a.status
FROM v$session a, v$sort_usage b
WHERE a.saddr = b.session_addr
ORDER BY b.username, b.tablespace, b.blocks;
Posted by Admin
on April 01, 2009
Oracle /
No Comments
user1@testserver : /home/firestorm => sqlplus
SQL*Plus: Release 9.2.0.7.0 - 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 9.2.0.7.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.7.0 - 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;
Explained.
dbserver:SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
————————————————————————————————-
——————————————————————————————————–
| 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;
Posted by Admin
on April 01, 2009
Shell /
No Comments
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.
#!/bin/ksh
#Script to remove the ugly DOS ^M characters
for readfiles in $@
do
tr -d ‘\r’ <$readfiles > $sometempfile.tmp
mv $sometempfile.tmp $readfiles
done