PDF file: set the bookmark

Strange enough, Adobe Acrobar Reader does not allow to put the user-defined bookmarks into the PDF file (and this is so simple and necessary thing!)

However, with the help of some “hack” the bookmarks still could be used.

Here is the trick:

Go to PDF Hacks site and download the zip file with the javascript.
Extract the file bookmark_page.js from [...]

AppleScript: rotate mov file in QuickTime Pro

Some 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"
    set m [...]

Office: check if PowerPoint is running

Dim objAPP, sMsg

On Error Resume Next

Set objAPP = GetObject(, "PowerPoint.Application")

If TypeName(objAPP) = "Empty" Then
    sMsg = "not started"
Else
    sMsg = "started"
End If

MsgBox "PowerPoint is " & sMsg, vbInformation, "PowerPoint"

if sMsg = "started" then objAPP.Visible [...]

MS Word: replace spaces to non-breaking

To insert it manually, use Ctrl+Shift+Space

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Normal")
Selection.Find.Replacement.ClearFormatting
With Selection.Find
   .Text = "   "
   .Replacement.Text = "^s"
   .Forward = True
   .Wrap = wdFindContinue
   .Format = True
End [...]

Check the default browser

The following section in registry should be checked:

HKEY_CLASSES_ROOT\http\shell\open\command
Key: (default)

Most (but not all) browsers check it to determine the current browser.

currentBrowser = RegistryGet("HKEY_CLASSES_ROOT","http\shell\open\command","")
MsgBox( currentBrowser )

Some browsers could create additional section HKEY_CLASSES_ROOT\http\shell\OpenWith\command, which helps to avoid the conflict with [...]

WHICH command for DOS

If You need the analog of Unix ‘which’ command and do not have Resource Kit, the following batch file will help.
The code was found on www.ss64.com
Published with the permission of the author, Clay Calvert.

@echo off
SETLOCAL
(set WF=)

:: Look for file in the current directory

for %%a in ("" %%) do (
if not defined WF if exist "%~1%%~a" set [...]

How to find the version of DirectX

Start the dxdiag tool.

Windows XP:
Start -> Run -> dxdiag

Windows Vista:
Start -> Search -> dxdiag

…and if You could not find dxdiag, probably You do not have DirectX on Your machine.
Are You still using old kind [...]

Read password in Unix shell

print -n "Enter Your password:"
 stty_orig=`stty -g`
 trap "stty ${stty_orig}; exit" 1 2 3 15
 stty -echo >&- 2>&-
 read PASS stty ${stty_orig} >&- 2>&-
 trap 1 2 3 15 print

trap :catches interruptions. I.e. if the user presses Ctrl+C, the normal stty mode is set before stopping the program
stty -echo :switches off the display echo
>&- 2>&- :helps to avoid “stty: Not [...]

Rev function and comma-separated output

Here is the shell command snippet to display comma-separated output:

ls -lrt | rev | sed ‘s/\\([0-9][0-9][0-9]\\)/\\1,/g’ | rev | sed ‘s/\\([\^0-9]\\),\\([0-9]\\)/\\1\\2/g;s/\^,\\([0-9]\\)/\\1/g’

Example:
-rw-r—– 1 sybase dba 1,572,872,192 Feb 2 07:09 master.dbf

Rev in awk

#!/bin/ksh
nawk ‘{ l=length($0) ; for(i=l;i>0;i–) { printf "%s", substr($0,i,1) } ; print "" }’

Rev function (absent on SunOS) :

(Warning! [...]

Find the files not in use in Unix

find . -name "*" -exec /usr/sbin/fuser {} 2>&1 \; | grep [...]