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 With
Selection.Find.Execute Replace:=wdReplaceAll

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 IE settings.

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 ("" %PATHEXT:;= %) do (
if not defined WF if exist "%~1%%~a" set WF=%CD%\%~1%%~a)

:: Look for file in the PATH

for %%a in ("" %PATHEXT:;= %) do (
if not defined WF for %%g in ("%~1%%~a") do (
if exist "%%~$PATH:g" set WF=%%~$PATH:g))

:: Store the Help Error message

if NOT "%~x1"=="" goto:END
for /f "delims=." %%a in ('help.exe *') do set HlpErr=%%a

:: If command missing from Help, goto end

help.exe "%~1" |find "%HlpErr%">nul && goto:END

:: Listed in help so find file in System32

for %%a in (exe com) do (
if /i "%WF%"=="%windir%\system32\%~1.%%a" goto:END)

:: File not in System32, so must be an internal command

set WF="%~1" is an internal command

:END
if defined WF (echo.%WF%) else (
echo The file: "%~1" was not found)

:: Credits:
:: Clay Calvert
:: alt.msdos.batch.nt

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 a typewriter” message for non-interactive scripts.

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! Avoid spaces before #define – SunOS cc compiler doesn’t like them)


#include <stdio.h>
#ident "@(#)rev 1.0 02/01/2006"
#define MAX_STRING_SIZE 2000char version[] = "rev v1.0 02/01/2006";

main(argc,argv)
int argc;
char *argv[];
{
char my_src[MAX_STRING_SIZE] ;
char my_dst[MAX_STRING_SIZE] ;
char *retCode ;

char *tmp_s ;
int i;

char *filename;
FILE *fSource ;

/* check command line arguments */
if (argc > 1) {
if( argv[1][0]=='-' || argv[1][0]=='/' ) {
fprintf(stderr, "Usage: %s [file] \n", argv[0]);
exit(1);
}
filename=argv[1] ;
fSource = fopen( filename, "r" ) ;
if ( fSource == NULL ) {
fprintf(stderr, "Can't open %s for reading\n", filename );
exit(1);
}
} else {
/* Using the standard input */
fSource=stdin ;
} /* if (argc > 1) */

while( (retCode = fgets( my_src, MAX_STRING_SIZE, fSource ) )!=NULL ) {

tmp_s=my_dst+MAX_STRING_SIZE-1;
*tmp_s=0;

for( i=0 ; i < MAX_STRING_SIZE && my_src[ i ] != 0 ; i++ ) {
if( my_src[ i ] == '\n' ) {
continue ;
}
tmp_s--;
*tmp_s=my_src[ i ];
}

fprintf( stdout, "%s\n", tmp_s);
}

fclose( fSource ) ;

fflush( stdout );

exit(0);
} /* main */