Using the clipboard in WSH
Friday, July 25th, 2008How to get the text from the clipboard
set objIE = CreateObject(”InternetExplorer.Application”)
objIE.Navigate(”about:blank”)
textFromClipboard = objIE.document.parentwindow.clipboardData.GetData(”text”)
objIE.Quit
WScript.Echo textFromClipboard
How to put the text into clipboard
textIntoClipboard = “Some text” & VbCrLf & “Some more text”
Set objIE = WScript.CreateObject(”InternetExplorer.Application”)
objIE.Navigate “about:blank”
Do Until objIE.ReadyState = 4
WScript.Sleep 100
Loop
objIE.document.ParentWindow.ClipboardData.SetData “text”, textIntoClipboard
objIE.Quit
The detailed explanation could be found here.
Oracle: check the existance of logon/logoff triggers
Friday, July 25th, 2008SELECT DECODE((COUNT(trigger_name)),0,’LOGON trigger missing’, ‘Number of logon triggers: ‘ || COUNT(trigger_name) ) “INFO”
FROM sys.dba_triggers
WHERE TRIGGERING_EVENT LIKE ‘LOGON%’ AND status=’ENABLED’ AND owner=’SYS’
UNION
SELECT DECODE((COUNT(trigger_name)),0,’LOGOFF trigger missing’,”, ‘Number of logoff triggers:’ || COUNT(trigger_name)) “INFO”
FROM sys.dba_triggers
WHERE TRIGGERING_EVENT LIKE ‘LOGOFF%’ AND status=’ENABLED’ AND owner=’SYS’
The field TRIGGERING_EVENT could have the spaces at the end! Very clever…
Unix shell: workaround for loop problem
Friday, July 11th, 2008It’s not possible to get the value of the loop variables in some versions of ksh.
Example:
#!/bin/ksh
num=0
cat $0 | while read line ; do
let num=num+1
done
echo “Number=$num”
This script will return “Number=0″ as the result.
Here is the workaround for the problem: You should change the redirection method for the input file.
#!/bin/ksh
l=0
while read line ; do
let l=l+1
done < $0
echo [...]
JavaScript: edit web page in browser
Friday, July 11th, 2008Here is small bookmarklet, which allows to edit the web page for any site (ok, You could save the results on Your local machine only).
javascript:document.body.contentEditable=’true’; document.designMode=’on’; void 0
Oracle: redo log switches by date
Thursday, May 8th, 2008The following script help to find, how often the redo logs were switched.
It calculates the number by date and by hour.
JavaScript: Soundex implementation
Thursday, April 10th, 2008There is a special algorithm for comparision strings, which sound similar (Soundex).
Here is JavaScript Soundex implementation:
function soundex ( s_src )
{
var s_rez = “0000″ ;
var new_code, prev, idx
a_codes = { “bfpv”: 1, “cgjkqsxz”:2, “dt”: 3, “l”: 4, “mn”: 5, “r”: 6 };
s_src = s_src.toLowerCase().replace(/ /g,”")
if ( s_src.length < 1) {
return(s_rez);
}
s_rez = s_src.substr(0,1);
prev = [...]
Oracle: usage of the tablespaces (permanent and temporary)
Friday, March 28th, 2008SET pagesize 10000
SET COLSEP ‘|’
SET VERIFY off
SET serveroutput ON SIZE 1000000
BREAK ON report
COLUMN tablespace_name format a30 heading ‘TABLESPACE’
COLUMN sizegb format 9999999999D9 heading ‘SIZE-Gb’
COLUMN usedproc format 999D99 heading ‘USED-%’
COLUMN status format a10 heading ‘STATUS’
COMPUTE SUM LABEL ‘Total size:’ OF sizegb ON report
SELECT b.tablespace_name ,
b.bytes/1024/1024/1024 AS sizegb ,
NVL(100-((a.bytes/b.bytes)*100), 100) usedproc,
[...]
AppleScript: rotate mov file in QuickTime Pro
Friday, March 28th, 2008Some kind of life hack: it’s very easy to make mov file with digital camera, rotating it 90 degrees. However, it’s not so easy to convert the result file to the ‘visible’ form.
QuickTime Pro could do this, and I found the AppleScript script, which could make it even more easy.
tell application “QuickTime Player”
[...]
Oracle: plan of the running query
Friday, March 28th, 2008col object_name FOR a40
SELECT operation,
options,
object_name,
partition_id
FROM v$sql_plan
WHERE address IN
( SELECT sql_address FROM v$session WHERE sid = &sid.)
ORDER BY id;
Oracle: using DBMS_METADATA for getting table structure
Monday, March 17th, 2008SET LONG 5000
SELECT dbms_metadata.get_ddl(’TABLE’,'EMP’,'SCOTT’);