by http://webgeektutorials.blogspot.com

Monday, May 21, 2012

jQuery: Disable context menu on right click

Using jQuery you can disable context menu when you right click on any HTML page. To do so add a very small   script in <HEAD> section of HTML page after linking it to jQuery.

Here is the script : 

<script type="text/javascript">
 $(function(){
 $("form").form();
 $(this).bind("contextmenu", function(e) {
e.preventDefault();
 });
});
</script> 

Monday, May 14, 2012

Oracle DBA Script : Monitor User

Displays the user and the text of the statement the user is executing

Code:
SELECT OSUSER,SERIAL#,SQL_TEXT
FROM V$SESSION, V$SQL
WHERE
V$SESSION.SQL_ADDRESS=V$SQL.ADDRESS 

AND 
V$SESSION.STATUS = 'ACTIVE';

Oracle DBA Script : Display DB uptime

Displays DB start time, and calculates how long the DB has been up.

Code:
set head off pages 0
Select
'Current System time and date is '||
To_Char(sysdate,'HH24:MI:SS " on " ddth
FMMonth YYYY')||chr(10)||'Database
'||NAME||' has been up since '||
To_Char(To_Date(a.value||b.value,'JSSSSS')
,'HH24:MI:SS " on " ddth FMMonth YYYY')
||chr(10)||' ( Which is
'||Trunc(sysdate-to_date(a.value||b.value,'JSSSSS'))||' days '||To_Char(To_Date(trunc(86400*(
(sysdate-to_date(a.value||b.value,'JSSSSS')
)-trunc(sysdate-to_date(a.value||b.value,'JSSSS'
)))),'SSSSS')
,'HH24 "hours" MI "mins and" SS "seconds )"')
from v$instance a,v$instance b,v$database
where a.key='STARTUP TIME - JULIAN'
and b.key='STARTUP TIME - SECONDS';

Oracle DBA Script : Detect Possible next extent failures

Script: 


Select
substr(sg.tablespace_name,1,30)Tablespace,
substr(sg.segment_name,1,30) Object,
sg.extents extents,
sg.next_extent next,
max(sp.bytes) available
From dba_free_space sp, dba_segments sg
Where sp.tablespace_name = sg.tablespace_name
Having max(sp.bytes) < sg.next_extent
Group by sg.tablespace_name,
sg.segment_name, sg.extents, sg.next_extent
Order by 1,2;

Oracle DBA Script : Mapping Database

Maps out the database physically with sizes and paths of all the physical files .It will give the names and sizes of rollback segments also..

Code:
spool dbmap.rpt
start title132.sql "Database Layout " "dbmap.sql"
prompt ================================
prompt Tablespace/Datafile Listing
prompt ================================
prompt
prompt
column "Location" format A60;
column "Tablespace Name" format A15;
column "Size(M)" format 999,990;

break on "Tablespace Name" skip 1 nodup;
compute sum of "Size(M)" on "Tablespace Name";
SELECT tablespace_name "Tablespace Name",
file_name "Location", bytes/1048576"Size(M)"
FROM sys.dba_data_files
Order by tablespace_name;
Prompt
Prompt ================================
Prompt Redo Log Listing
Prompt ================================
Prompt
Prompt
column "Group" format 999;
column "File Location" format A50;
column "Bytes (M)" format 99,990;

break on "Group" skip 1 nodup;

Oracle DBA Script : Export table data into text file

Creating a ascii text file of oracle table data with pipe delimited columns.

Code:
#!/bin/ksh
#First line in the .txt file is column names
USR=username/password
echo "set feedback off\n set pagesize 0\n
select 'XXTT' || table_name from user_tables ;" | sqlplus -s $USR | grep '^XXTT' | cut -c5- |
while read TABL
do
STR="nothing"
STR1="nothing"
echo "desc $TABL\n" | sqlplus -s $USR | tail +3 | grep "^[A-Z,a-z]" | awk '{print $1}' |
while read COLUM
do
if [ "$STR" = "nothing" ] then
STR=$COLUM
STR1=$COLUM
else
STR="$STR || '|' || $COLUM"
STR1="$STR1|$COLUM"
fi

Oracle DBA Script : Check error message in alert log

This Script search for Oracle error messages in last 100 lines in the alert log file , send a email message to concerned and keep log to a file.
You should pass name of ORACLE_SID as a parameter.
For eg: Ck_alerlog FINL


Code:
#!/usr/bin/sh
# Script Type: Shell (Bourne)
#
# Script name: ck_alertlog.sh
# Comments: Script checks last 100 lines of
# the alert log for specific
# Oracle errors, then pages or e-mails depending #on the error.
# Parameter: ORACLE_SID
# -------------------
# Revision Log
#
# 00/00/00 : Name of modifier - description
#of Modifications
#
#--------------------------------------------------
#-------------------------
SID=$1
DIR=/usr/local/bin/dbabin
ORACLE_SID=$SID; export ORACLE_SID
ORACLE_HOME=`grep -v "^[#]" /var/opt/oracle/oratab|grep $ORACLE_SID|cut -d: -f2
export ORACLE_HOME
cd $ORACLE_HOME/../..

ALERT_DEST=`pwd`
ALERT_DEST=$ALERT_DEST/admin/$SID/bdump
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
COLLECTOR=`tail -100 $ALERT_DEST/alert_$SID.log |egrep "ORA-255 |ORA-255:|ORA-0255|ORA-214|ORA-214:|ORA-00214|ORA-270|ORA-270:|ORA-00270|ORA-272|ORA-272:|ORA-00272|ORA-600|ORA-600:|ORA-00600|ORA-1122|ORA-1122:|ORA-01122|ORA-1578|ORA1578:|ORA-01578|ORA-1628|ORA-1628:|ORA-01628|ORA-1630|ORA-1630:|ORA-01630|ORA1631|ORA-1631:|ORA-01631|ORA-1632|ORA-1632:|ORA-01632|ORA-1650|ORA-1650:|ORA01650|ORA-1652|ORA-1652:|ORA-01652|ORA-1653|ORA-1653:|ORA-01653|ORA-1654|ORA1654:|ORA-01654|ORA-1655|ORA-1655:|ORA-01655"`
for i in $COLLECTOR
do

Oracle DBA Script : Change Sql Prompt

When you connect to sqlplus, you see the the following sql prompt. SQL>
By using this sql in the glogin.sql, you will see a prompt similar to the following:
SCOTT@DB-01>


Code:
The following code works on Oracle 8i (8.1.5, 8.1.6, 8.1.7).
You have to insert the following line of code in glogin.sql which is usually found in $ORACLE_HOME/sqlplus/admin

set termout off
set echo off
define X=NotConnected
define Y=DBNAME

Column Usr New_Value X
Column DBName New_Value Y
Select SYS_CONTEXT('USERENV','SESSION_USER') Usr From Dual;

--- The following does not work in 8.1.5 but works --- in 8.1.6 or above
Select SYS_CONTEXT('USERENV','DB_NAME') DBNAME From Dual;

Oracle DBA Script : Find out duplicate records in a Table

Code: 

SELECT primary_key FROM table_name
MINUS
(
SELECT DISTINCT primary_key
FROM table_name
)

You can also use * instead of the primary_key.
18. Description: This Script will help you to find out which Database you are presently
Connected to? If You are working on multiple Databases on different Servers using SQL*Net or Net8.
Code:

Oracle DBA Script : Return Information about constraint

Script prompts for a constraint name then it returns information about the constraint.

Code:

set lines 120
set serveroutput on size 100000
set scan on
clear buffer
set verify off
set feedback off
declare

l_constraint_name varchar2(30);
l_constraint_type varchar2(1);
l_table_name varchar2(30);
l_search_condition long;
l_related_constraint varchar2(30);
l_related_table varchar2(30);
l_rcolumn varchar2(30);
l_column varchar2(30);
l_query varchar2(400);
l_column_count integer;

cursor lc_constraint (p_constraint_name varchar2) is
select *
from dba_constraints
where constraint_name = p_constraint_name;

cursor lc_related_constraint(p_r_constraint_name varchar2)
is

Oracle DBA Script : Find Child table for given parent table

set echo off
set verify off
accept xTable prompt 'Enter Table Name: '
TTITLE LEFT 'Child Tables for the table: '&xTABLE
break on TABLE_NAME
SELECT B.TABLE_NAME, C.COLUMN_NAME,
C.POSITION
FROM USER_CONSTRAINTS A,
USER_CONSTRAINTS B,
USER_CONS_COLUMNS C
WHERE
A.CONSTRAINT_NAME=
B.R_CONSTRAINT_NAME
AND
A.TABLE_NAME = C.TABLE_NAME
AND
A.CONSTRAINT_NAME = C.CONSTRAINT_NAME
AND
A.TABLE_NAME = UPPER('&xTable')
ORDER BY B.TABLE_NAME, C.POSITION;

TTITLE LEFT 'Parent tables for the table: '&xTable

SELECT A.TABLE_NAME, C.COLUMN_NAME,
C.POSITION
FROM USER_CONSTRAINTS A,
USER_CONSTRAINTS B,
USER_CONS_COLUMNS C
WHERE
A.CONSTRAINT_NAME=B.R_CONSTRAINT_NAME
AND
B.TABLE_NAME = C.TABLE_NAME
AND
B.CONSTRAINT_NAME = C.CONSTRAINT_NAME
AND
B.TABLE_NAME = UPPER('&xTable')
ORDER BY A.TABLE_NAME, C.POSITION;

Oracle DBA Script : Find out two top values from a table

1. Finds the two highest salaries from table "emp".

Code:
select a.empno,a.sal
from emp a
where 2>
(
select count(*)
from emp
where sal>a.sal
);


2. Finds the two lowest salaries from table "emp".


Code:
select a.empno,a.sal
from emp a
where 2>
(
select count(*)
from emp
where sal<a.sal
)

Oracle DBA Script : Monitor File I/O

This script takes a snapshot of v$filestats at the current time and saves it. It then waits 10 seconds and takes another snapshot and reports on the delta.

Code:
col name for a50
set linesize 132
set pages 666
-- drop temporary table
drop table jh$filestats;
create table jh$filestats as
select file#, PHYBLKRD, PHYBLKWRT
from v$filestat;
prompt Waiting......
exec dbms_lock.sleep(10);

prompt NOTE: Only the top 10 files...
select * from (
select df.name, fs.phyblkrd - t.phyblkrd "Reads",fs.PHYBLKWRT - t.PHYBLKWRT "Writes",(fs.PHYBLKRD+fs.PHYBLKWRT) - (t.PHYBLKRD+t.PHYBLKWRT) "Total IO"
from v$filestat fs, v$datafile df, jh$filestats t
where df.file# = fs.file# and t.file# = fs.file#
and (fs.PHYBLKRD+fs.PHYBLKWRT) - (t.PHYBLKRD+t.PHYBLKWRT) > 0
order by "Total IO" desc )
where rownum <= 10
/

Oracle DBA Script : Show View Source

Code: 


SET HEADING OFF
SET ECHO OFF
SET FEEDBACK OFF
SET PAGESIZE 0
set numwidth 10

SELECT uv.view_name SORT1, 0 SORT2, 0 SORT3,
0 SORT4,
'create or replace view '||uv.view_name ||' ('
from dba_views uv
WHERE uv.owner = upper('&2')
and uv.view_name = upper('&1')
union all
SELECT utc.view_name SORT1, utc.column_id
SORT2, 0 SORT3, 0 SORT4,utc.column_name
from dba_tab_columns
WHERE utc.owner = upper('&2')
and utc.table_name = upper('&1')
and utc.column_id = 1
union all
SELECT utc.view_name SORT1, utc.column_id
SORT2, 0 SORT3, 0 SORT4,
' , '||utc.column_name
from dba_tab_columns
WHERE utc.owner = upper('&2')
and utc.table_name = upper('&1')
and utc.column_id <> 1
SELECT uv.view_name SORT1,999 SORT2,0
SORT3,0 SORT4,' )'
from dba_views uv
WHERE uv.owner = upper('&2')
and uv.view_name = upper('&1')
ORDER BY 1, 2, 3, 4;
SELECT uv.text
from dba_views uv
WHERE uv.owner = upper('&2')
and uv.view_name = upper('&1');
SELECT uv.view_name SORT1,999 SORT2,0
SORT3,0 SORT4,' ;'
from dba_views uv
WHERE uv.owner = upper('&2')
and uv.view_name = upper('&1');

Oracle DBA Script : Show Package Source

This script Extract package and package body source from the database.

Code:
COL SORT1 NOPRINT
COL SORT2 NOPRINT
COL SORT3 NOPRINT
COL SORT4 NOPRINT
BREAK ON SORT1 SKIP 1
set linesize 120
SET HEADING OFF
SET ECHO OFF
SET FEEDBACK OFF
SET PAGESIZE 0
SPOOL bldpack.sql

select 'set echo on ' from dual;
select 'spool bldpack.lst' from dual;
select 'Remark Build package definitions' from dual;

SELECT NAME SORT1, LINE SORT2,
'Create or Replace ' || TEXT
FROM USER_SOURCE
WHERE TYPE = 'PACKAGE' AND LINE = 1
UNION
SELECT NAME SORT1, LINE SORT2,TEXT
FROM USER_SOURCE
WHERE TYPE = 'PACKAGE' AND LINE > 1
UNION
SELECT NAME SORT1, 999999 SORT2, '/'
FROM USER_SOURCE
WHERE TYPE = 'PACKAGE' AND LINE =1
ORDER BY 1,2;

Oracle DBA Script : Active Transactions in Rollback Segments

column rr heading 'RB Segment' format a18
column us heading 'Username' format a15
column os heading 'OS User' format a10
column te heading 'Terminal' format a10

SELECT r.name rr,
nvl(s.username,'no transaction') us,
s.osuser os,
s.terminal te
FROM
v$lock l,
v$session s,
v$rollname r
WHERE
l.sid = s.sid(+) AND
trunc(l.id1/65536) = r.usn AND
l.type = 'TX' AND
l.lmode = 6
ORDER BY r.name
/

Monday, May 7, 2012

CarePointz app for iPhone / iPad

Health5C  proud to announce our new app "CarePointz" for iPhone / iPad users.

Do you have a jet set lifestyle or are you a frequent traveler!? This application is for you. You never sure what you are searching in a new place? Carepointz, which can help you pinpoint your nearest medical/ health related facility based on your choice. Best thing of this app is that it discovers the current location of user and suggests the best nearby medical/health facility. Health5C is improving this app day by day and may be within two or three weeks you will get new features with new version.

The tool finds places either through your internet connection Wi-Fi (if present) or through your Mobile Service Provider. CarePointz provides 35 different criteria's for search. You can see your current location along with normal or satellite or hybrid map view. Search results are also available offline to ensure you do not miss your findings, in case, you experience any network issue.

Friday, May 4, 2012

How to : jQuery UI Autocomplete - Combobox ( dropdown )

Convert your <select> into beautiful jQuery UI Combobox. Its been fun with jQuery and UI is really cool. This is what i got when finished. ( final output )


You can customize the widget as you want. for this you need jQuery UI , I downloaded my own jQueryUI Theme using Theamroller. You can download default theme or customize it as per your project need, just download it from here.  To do this cool widget i follow following steps.

Step 1:Add Javascripts and CSS to your page
Here i have downloaded 1.8.20 version and using same for this tutorial. For this widget i added few scripts and css style in header section of HTML page.