20090604

http://blogs.msdn.com/ie/archive/2008/06/10/introducing-ie-emulateie7.aspx

Introducing IE=EmulateIE7

Bill Gates’ recent Tech Ed keynote and Tony Chor’s follow-up blog announced that IE8 Beta 2 will be available in August in many languages. We are encouraging sites to get ready for Beta 2 prior to release as it will present a big jump in IE8 browsing traffic.

What does “getting ready for IE8” mean for web sites? IE8 displays content in IE8 Standards mode – its most standards-compliant layout mode – by default. In previous blog posts, we’ve discussed how this aligns with our commitment to Web standards interoperability. However, browsing with this default setting may cause content written for previous versions of IE to display differently than intended. This creates a “get ready” call to action for site owners to ensure their content will continue to display seamlessly in IE8.

The preferred response to this call to action is to update the site to ensure that IE8 is provided with standards content fitting the DOCTYPE. However, we know it is very important to give site owners the chance to update site content on their schedule without affecting user experience. As such, we provide a meta-tag that tells IE8 to display an entire site or a specific page like it did in IE7.

In IE8 Beta 1, that option is the “IE=7” X-UA-Compatible tag, which instructs IE8 to display content in IE7 Standards mode. However, the scenario this doesn’t address is when IE=7 is applied as an HTTP header to a site that contains Quirks mode pages. The IE=7 HTTP header will force all pages – both Quirks and Standards – to display in IE7 Standards mode. Developers using this header while updating their sites would then have to add the “IE=5” tag to each page they want to keep in Quirks mode. This logic is fine for many websites. However, if a site has lots of Quirks mode pages, or for the case where pages with frames host a mix of Strict and Quirks mode content – as brought to light by IE8 Beta 1 user feedback – the compatibility opt-out adds a bit more work than we intended.

In response to the great IE8 Beta 1 feedback we’ve received so far, we are introducing the “IE=EmulateIE7” tag to address this problem. EmulateIE7 tells IE8 to display standards DOCTYPEs in IE7 Standards mode, and Quirks DOCTYPEs in Quirks mode. We believe this will be the preferred IE7 compatibility mode for most cases. Support for IE=EmulateIE7 is available now as part of the IE June Security Update for IE8 Beta 1. Installing this update will enable you to verify you’ve applied the EmulateIE7 tag to your site correctly.

In summary, IE7 compatibility support looks as follows:

Content Value

Details

IE=7

Display in IE7 Standards mode; Already supported in the IE8 Beta 1 release

IE=EmulateIE7

Display standards DOCTYPEs in IE7 Standards mode; Display quirks DOCTYPEs in Quirks mode; Available through the IE June Security Update for IE8 Beta 1

There are two ways to implement this tag:

  • On a per-site basis, add a custom HTTP header

X-UA-Compatible: IE=EmulateIE7

  • On a per-page basis, add a special HTML tag to each document, right after the tag

Implementing the HTTP header is beneficial if a site owner wants most of their site to render as it did in IE7 or if there are no plans to update site content. Inclusion of this header honors any Quirks mode pages that belong to the site.

Using the meta-tag on a per-page basis is beneficial when the publisher wants to opt-in specific pages to render as they did in IE7.

NOTE: The X-UA-Compatible tag and header override any existing DOCTYPE. Also, the mode specified by the page takes precedent over the HTTP header. For example, you could add the EmulateIE7 HTTP header to a site, and set specific pages to display in IE8 mode (by using the meta-tag with content=”IE8”).

Using the IE=EmulateIE7 compatibility tag is a simple way for users to continue their current experience when browsing your site until you can update with more standards-compliant content. Although adding this tag will prevent most display issues, you may also need to update your site to properly detect IE8. To learn more about IE8 document compatibility and browser detection, check out the IE Compatibility Center.

Jefferson Fletcher
Product Manager
Internet Explorer

P.S.: Here are some links to reference for adding custom HTTP headers on various versions of IIS and Apache servers: IIS7.0, IIS6.0, Apache 2.2, Apache 2.0, Apache 1.3

Published Tuesday, June 10, 2008 2:15 PM by ieblog Filed under: , ,
--
map{ map{tr|10|# |;print} split//,sprintf"%.8b\n",$_}
unpack'C*',unpack'u*',"5`#8<3'X`'#8^-@`<-CPP`#8V/C8`"

http://www.robvanderwoude.com/userinput.php

User Input

Sometimes we need some user interaction in our batch files.
We may need to know to which directory a file is to be copied, for example.
Or which drive needs to be formated.

There are many ways to achieve this user interaction.

The most basic form of user interaction, of course, is the PAUSE command, which halts the batch file until the user presses "any key" (apart from Ctrl, Alt, Shift, CapsLock, NumLock or ScrollLock).
Maybe not really sophisticated, but it works and is always available, in all DOS, Windows and OS/2 versions.
MS-DOS

In the MS-DOS 3 days, a simple Yes/No question could be answered by changing to a temporary directory where two temporary batch files were located, Y.BAT and N.BAT.
Guess what happend if a user typed a completely different answer . . .

Since MS-DOS 6 we have CHOICE.COM (CHOICE.EXE in later versions), a much more versatile and reliable way to solve one character answers like Yes/No.

Unfortunately, the CHOICE command was discontinued in Windows NT 4 and later.
You may want to try my Poor Man's Choice instead, or use DEBUG to create REPLY.COM, as published in Microsoft Knowledge Base article Q77457: Accepting Keyboard Input in Batch Files.

There is another way to receive user input: COPY CON

The command:

COPY CON filename

copies the user input on the command line to the file filename.
To stop entering user input, the user has to type Ctrl+Z (or F6), followed by the Enter key.

Many PC users and batch file authors (including myself), find this approach "less intuitive", to say the least. One would expect that pressing the enter key is enough, and once you find out it isn't, the previous line of input cannot be removed anymore.

The following trick uses ANSI to perform some key translation: the Enter key is translated to the F6 key followed by the Enter key. Thus only one line of input can be entered, and pressing the Enter key sends the input to the temporary file USERINP.TMP.

ECHO Enter some input, and press Enter when ready . . .
ECHO ←[13;0;64;13p
COPY CON USRINPUT.TMP
ECHO ←[13;13p
CLS
ECHO You typed:
TYPE USRINPUT.TMP

Note: The ← character is the Esc character, or ASCII character 27 (or 1B Hexadecimal).
It is a representation of the Esc key.
This Esc character is not to be confused with escape characters!

The previous example is only a bare minimum. The following example not only asks for user input, but stores it in an environment variable USRINPUT as well:

@ECHO OFF
REM * Ask for USeR INPUT and store it in variable USRINPUT
REM * Written by Rob van der Woude

SET USRINPUT=

REM * Turn on ANSI key translation (translate Enter
REM * key to F6+Enter sequence) and ask for input:
ECHO ←[13;0;64;13pEnter one word only . . .

REM * Copy entered text to temporary file:
COPY CON %TEMP%.\~USRINP.TMP

REM * Turn off ANSI key translation and clear irrelevant screen output:
ECHO ←[13;13p←[3A←[K←[1B←[K←[1B←[K←[2A

REM * Add empty line to temporary file. The empty line
REM * will be used to stop DATE asking for new date.
ECHO.>> %TEMP%.\~USRINP.TMP
ECHO.>> %TEMP%.\~USRINP.TMP

REM * Create a temporary batch file that will store the
REM * entered text into the environment variable USRINPUT:
TYPE %TEMP%.\~USRINP.TMP | DATE | FIND "):" > %TEMP%.\~USRINP.BAT

REM * Create more temporary batch files. Add
REM * more command line parameters if necessary,
REM * as in: ECHO SET USRINPUT=%%3 %%4 %%5 %%6 %%7 %%8 %%9>CURRENT.BAT
ECHO SET USRINPUT=%%3>CURRENT.BAT

REM * VOER.BAT and TYP.BAT are replacements for CURRENT.BAT for Dutch
REM * DOS versions; add your own language versions if necessary:
ECHO SET USRINPUT=%%6>VOER.BAT
ECHO SET USRINPUT=%%4>TYP.BAT

REM * This temporary batch file now sets the variable USRINPUT:
CALL %TEMP%.\~USRINP.BAT

REM * Display the result:
ECHO You typed: ←[1m%USRINPUT%←[0m
ECHO.
PAUSE

REM * Finally, clean up the mess of temporary files:
FOR %%A IN (%TEMP%.\~USRINP.BAT %TEMP%.\~USRINP.TMP VOER.BAT TYP.BAT CURRENT.BAT) DO DEL %%A

Click to view source Click to download the ZIPped sources

The previous batch file should work in every DOS version, assuming ANSI.SYS (or one of its replacements, like ANSI.COM) is loaded.
With a few minor adjustments (replace .BAT with .CMD everywhere) it can be used in OS/2 as well. Use READLINE instead, however, in OS/2's DOS sessions.

The following batch file checks if ANSI.SYS is loaded. If so, it will tell the user to press the Enter key only. If not, it will tell the user to press F6 first, followed by the Enter key.
However, to check if ANSI.SYS is loaded, this batch file needs MS-DOS 6 or later.

@ECHO OFF
REM * Asks for USeR INPut and store it in variable USRINPUT
REM * Uses ANSI if available, but works without ANSI too
REM * Assumes MS-DOS 6 or later
REM * Written by Rob van der Woude
REM * http://www.robvanderwoude.com

SET USRINPUT=

REM * Check if ANSI sequences can be used (needs at
REM * least MS-DOS 6 to get an errorlevel from FIND):
SET ANSI=1
MEM /C | FIND "ANSI" > NUL
IF ERRORLEVEL 1 SET ANSI=0

REM * Turn on ANSI key translation (translate Enter
REM * key to F6 + Enter sequence) if possible:
IF "%ANSI%"=="1" ECHO ←[13;0;64;13p

REM * Ask for input:
IF "%ANSI%"=="0" ECHO Enter one word only, and press F6 followed by Enter . . .
IF "%ANSI%"=="1" ECHO Enter one word only, and press Enter . . .

REM * Copy entered text to temporary file:
COPY CON %TEMP%.\~USRINP.TMP

REM * Turn off ANSI key translation and clear irrelevant screen output:
IF "%ANSI%"=="0" CLS
IF "%ANSI%"=="1" ECHO ←[13;13p←[3A←[K←[1B←[K←[1B←[K←[2A

REM * Add empty line to temporary file. The empty line
REM * will be used to stop DATE asking for new date.
ECHO.>> %TEMP%.\~USRINP.TMP
ECHO.>> %TEMP%.\~USRINP.TMP

REM * Create a temporary batch file that will store the
REM * entered text into the environment variable USRINPUT:
TYPE %TEMP%.\~USRINP.TMP | DATE | FIND "):" > %TEMP%.\~USRINP.BAT

REM * Create more temporary batch files. Add
REM * more command line parameters if necessary,
REM * as in: ECHO SET USRINPUT=%%3 %%4 %%5 %%6 %%7 %%8 %%9>CURRENT.BAT
ECHO SET USRINPUT=%%3>CURRENT.BAT

REM * VOER.BAT and TYP.BAT are replacements for CURRENT.BAT for Dutch
REM * DOS versions; add your own language versions if necessary:
ECHO SET USRINPUT=%%6>VOER.BAT
ECHO SET USRINPUT=%%4>TYP.BAT

REM * This temporary batch file now sets the variable USRINPUT:
CALL %TEMP%.\~USRINP.BAT

REM * Display the result:
IF "%ANSI%"=="0" ECHO You typed: %USRINPUT%
IF "%ANSI%"=="1" ECHO You typed: ←[1m%USRINPUT%←[0m
ECHO.
PAUSE

REM * Finally, clean up the mess of temporary files:
FOR %%A IN (%TEMP%.\~USRINP.BAT %TEMP%.\~USRINP.TMP VOER.BAT TYP.BAT CURRENT.BAT) DO DEL %%A
SET ANSI=


Click to view source Click to download the ZIPped sources


In NT we don't need temporary files and we can skip a few lines by using TYPE CON and FOR /F:

@ECHO OFF
:: UserInNT.bat
:: How to use the TYPE CON command to receive user input
:: Written by Rob van der Woude
:: http://www.robvanderwoude.com

ECHO.
ECHO Demonstration of receiving user input through the TYPE CON command.
ECHO Type in any string and close by pressing Enter, F6 (or Ctrl+Z), Enter.
ECHO Only the last non-empty line will be remembered, leading spaces are ignored.
ECHO.

:: Only one single command line is needed to receive user input
FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET INPUT=%%A
:: Use quotes if you want to display redirection characters as well
ECHO You typed: "%INPUT%"

It is still just as un-intuitive as the first COPY CON example, though.

Click to view source Click to download the ZIPped sources

Latest news: Replace TYPE CON by MORE in the above NT batch file and you can save yourself pressing Enter once -- you'll need to press F6, Enter only instead of Enter, F6, Enter, though the latter will still work.
[Tip posted by "Frank" on alt.msdos.batch.nt]

Tom Lavedas' New and Improved Data Input Routine! shows a way to use a graphical box to ask for user input in Windows 95

Duke Communications International, Inc.'s tip # 0323: How can I get a batch file to prompt me for parameters? shows a way to get a graphical box asking for user input in Windows NT

Walter Zackery posted two interesting solutions to obtain user input in NT, on the alt.msdos.batch.nt news group.

One solution uses the FORMAT command, which will fail since it tries to format a diskette in drive A: at 160KB.
If you have a 5¼" drive as your A: drive don't use this one.

The second solution uses the LABEL command.
It will actually change drive C:'s volume label and then restore it again to its old value.
The volume label in NT is restricted to 32 characters, and so is the input string when using this LABEL trick for user input.
Besides that the batch file limits the string to 2 words (1 space) only.

I adapted the original postings so that the batch files no longer need to use temporary files. You can view the original postings at my Solutions found at alt.msdos.batch page.

Click to view source Using FORMAT
Click to view source Using LABEL
Click to download the ZIPped sources


Clay Calvert posted another interesting solution to obtain Yes or No input in most DOS versions by using DEL's /P switch (prompt for confirmation).

Another great solution by Eric Phelps uses a temporary HTA file to obscure a password while it is being typed.
Windows 2000/XP

In Windows 2000, user input can be obtained quite easily by using SET /P

SET /P variable=[promptString]

This command will display an optional promptString where the user can type in a string and press Enter. The typed string will then be stored in the specified environment variable variable.
KiXtart

A non-batch solution for Windows 95/98/NT/2000 users is the GETS function in KiXtart:

@ECHO OFF
:: UsrInKix.bat, Version 1.00 for Win32
:: Batch file using Kix to retrieve user input
:: Written by Rob van der Woude
:: http://www.robvanderwoude.com

:: Create a temporary Kix script that will
:: in turn create a temporary batch file:
> %TEMP%.\UserIn.kix ECHO REDIRECTOUTPUT( "NUL" )
>>%TEMP%.\UserIn.kix ECHO GETS $UserIn
>>%TEMP%.\UserIn.kix ECHO IF OPEN( 1, "@SCRIPTDIR\UserIn.bat", 5 ) = 0
>>%TEMP%.\UserIn.kix ECHO WRITELINE( 1, "SET UserIn=" + $UserIn )
>>%TEMP%.\UserIn.kix ECHO ELSE
>>%TEMP%.\UserIn.kix ECHO ? "Error opening temporary file, errorcode = " + @ERROR
>>%TEMP%.\UserIn.kix ECHO ENDIF
:: Prompt for user input:
ECHO Type anything you like and press Enter when finished:
:: retrieve user input using the Kix script, and
:: then store the result in a temporary batch file:
KIX32.EXE %TEMP%.\UserIn.kix
:: Call the temporary batch file to store
:: the result in an environment variable:
CALL %TEMP%.\UserIn.bat
:: Clean up the temporary files:
IF EXIST %TEMP%.\UserIn.* DEL %TEMP%.\UserIn.*
:: Finaly, display the result:
ECHO You typed: %UserIn%


Click to view source Click to download the ZIPped sources

VBScript

More advanced dialog boxes, output and input, including (masked) password prompts, can be created using VBScript and Internet Explorer, but I would not recommend creating them on the fly.
Sample change password dialog created using VBScript and Internet Explorer

See the VBScript Scripting Techniques section for some of these advanced user message windows.
OS/2

OS/2 users may want to take a look at UserInPM, a utility written in VX-Rexx, displaying a small PM window asking for user input.
It creates a temporary batch file to set an environment variable to the typed input.
An example batch file, with the resulting PM window:

SET USRINPUT=
USRINPUT.EXE Type whatever you like:
CALL USRINPUT.CMD
ECHO User input: %USRINPUT%

USRINPUT dialogue window

You will need the VX-Rexx runtime library VROBJ.DLL to run UserInPM.

http://www.robvanderwoude.com/pmadmin.php#PMChoice

The Poor Man's Administrator Tools

This page is dedicated to administrators tools and tips based on "native" and freeware utilities only.
Knowing these tools may prove extremely valuable when you're faced with problems "in the middle of nowhere", without your own set of utilities nearby.
NT

* Do you need a tool to remotely execute commands on any PC?
You could of course use RCMD from the Microsoft Windows NT Server Resource Kit. Or, if "third party tools" are allowed, PSEXEC is an excellent RCMD replacement, available at SysInternals.com for free.
Or you can use the AT command to schedule the command 2 minutes from now:

NET TIME \\remotePC /SET
AT \\remotePC 10:02 "your command goes here"

If you prefer not to change your system time, download either PMSoon.bat or AtFuture.bat.
PMSoon.bat will only work if the time difference between the two systems is 1 minute or less. It will display a warning message if the difference is greater.
AtFuture.bat (a coproduction with Rob Fuller), intended for local use only, does not have this limitation.
* Do you need to prevent login scripts from running on servers?
Use NTRole (update: this utility is no longer available for download) to determine if the current "workstation" is actually a server or not.
Some company policies do not allow third party tools, however.
Of course, I wouldn't have mentioned NTRole here if I didn't have a "poor man's version" available: NTRole.bat.
Download the ZIPped version.
* Did you ever try to redirect or pipe CACLS' output in NT 4?
If you ever installed an NT Service Pack, what you probably saw were the permissions without the user IDs or groups that those permissions belonged to.
Instead of using XCACLS from the Microsoft Windows NT Server Resource Kit, extract CACLS from your original NT 4 CD-ROM and use that version whenever you need to redirect its output.
XCACLS' /Y switch can be emulated by piping a Y to CACLS' standard input:

ECHO Y| CACLS .....
Warning: Do not use the old CACLS version to set or change permissions if you have any NT 4 Service Pack applied.
A safe way to prevent yourself from accidentally using the old version is to rename the old CACLS.EXE to OLDCACLS.EXE.
* Disappointed because the CHOICE command wasn't implemented in NT? I know I was.
You could buy yourself a copy of the Microsoft Windows NT Server or Workstation Resource Kit.
Or you could download both PMChoice.bat and PMChoice.kix. The only missing part of this combination is that PMCHOICE does not accept redirected input, only keyboard input.
* SHORTCUT.EXE from the Microsoft Windows NT Server or Workstation Resource Kit is a great tool to set or read a shortcut's properties.
Many times, however, it is used just to read the path of a program file. In that case you may want to download Shortcut.bat, a batch file that uses internal commands only to read both the UNC and the fully qualified path from one or more shortcut files.

If you do need to create shortcuts, learn how to create shortcuts using INF files from this posting by Walter Zackery to the alt.msdos.batch.nt news group, and from this article by Daniel U. Thibault.
* If you ever need to create a fixed time delay in a batch file, but you do not have a copy of SLEEP.EXE from the NT Resource Kit available, just download PMSleep.bat (for Windows NT/2000) or PMSlpW9x.bat (for Windows 95/98).
These batch files use PING's -W switch to create a delay.
The following example will create a 1 minute delay in Windows NT and 2000:

CALL PMSLEEP.BAT 60

Due to limitations in the MS-DOS 7 batch language, we need to add 1 to the number of seconds specified in Windows 95 and 98:

CALL PMSLPW9X.BAT 61

This Windows 9x example will wait for 60 seconds, not 61.

You may also choose to download the latest KiXtart version from www.kixtart.org and use its SLEEP function within your batch file.
The following example will create a 1 minute delay:

ECHO $RC = SLEEP 60 > "%TEMP%.\SLEEP.KIX"
KIX32.EXE "%TEMP%.\SLEEP.KIX"
DEL "%TEMP%.\SLEEP.KIX"

This KiXtart script will work in all 32-bit Windows versions, as long as KiXtart is installed.

http://academic.evergreen.edu/projects/biophysics/technotes/program/ansi_esc.htm#notes





Programming













ANSI.SYS Escape Sequences
















































































































































































































































































































































Cursor Commands

Cursor Up {ESC}[<row>A
Moves the cursor up the specified number of rows without changing the column.

<row> is a number from 1 through 24 that specifies how many rows the cursor is to be moved up.
If you omit <row>, DOS moves the cursor up one row.
    examples {ESC}[13A Move the cursor up 13 rows

{ESC}[A Move the cursor up 1 row

Cursor Down {ESC}[<row>B
Moves the cursor down the specified number of rows without changing the column.

<row> is a number from 1 through 24 that specifies how many rows the cursor is to be moved down.
If you omit <row>, DOS moves the cursor down one row.
    examples {ESC}[8B Move the cursor down eight rows.

{ESC}[B Move the cursor down one row.

Cursor Right {ESC}[<col>C
Moves the cursor right the specified number of columns without changing the row.

<col> is a number from 1 through 79 that specifies how many columns that cursor is to be moved right.
If you omit <col>, DOS moves the cursor right one column.
    examples {ESC}[40C Move the cursor right 40 columns.

{ESC}[C Move the cursor right one column.

Cursor Left {ESC}[<col>D
Moves the cursor left the specified number of columns without changing the row.

<col> is a number from 1 through 79 that specifies how many columns the cursor is to be moved left.
If you omit <col>, DOS moves the cursor left one column.
    examples {ESC}10[D Move the cursor left ten columns.

{ESC}[D Move the cursor left one column.

Move Cursor {ESC}[<row>;<col>H or {ESC}<row>;<col>f
Moves the cursor to the specified row and column.

<row> is a number from 1 through 25 that specifies the row to which the cursor is to be moved. If you omit <row>, DOS moves the cursor to row 1. To omit <row> but specify <col>, enter the semicolon to show the <row> is omitted.
<col> is a number from 1 through 80 that specifies the column to which the cursor is to be moved. If you omit <col>, DOS moves the cursor to column 1.
If you omit both <row> and <col>, DOS moves the cursor to the home position (row 1, column 1--the upper left corner of the screen).
    examples {ESC}[;10H Move the cursor to column 10, row 1.

{ESC}[H Move the cursor to row 1, column 1.

Save Cursor Position {ESC}[s
Stores the current row and column position of the cursor.

You can move the cursor to this location with a Restore Cursor Position command.
    examples {ESC}[s Save the current cursor position.

Report Cursor Position {ESC}[6n
Returns the current row and column position of the cursor in the form {ESC}[<row>;<col>R.

<row> is a number from 1 through 25 that specifies the row where the cursor is located.
<col> is a number from 1 through 80 that specifies the column where the cursor is located.
    examples {ESC}[6n Report the current cursor position.

Restore Cursor Position {ESC}[u
Moves the cursor to the row and column position most recently saved with a Save Cursor Position command.
    examples {ESC}[u Move the cursor the row and column last saved with a Save Cursor Position command.

Erase Commands

Erase Display {ESC}[2J
Erases the entire display (equivalent to the DOS Clear Screen or cls command).
    examples {ESC}[2J Erase the screen.

Erase to End of Line {ESC}[K
Erases from the current cursor position through the end of the line that contains the cursor.
    examples {ESC}[K Erase from the cursor to the end of the line.

Display Attribute and Mode Commands

Set Attribute {ESC}[<attr>m
Turns on a characteristic or attribute of the display, such as high intensity, blink, or foreground and background color.

<attr> specifies the display attribute to be turned on. More than one attribute can be specified by using a semicolon to separate the attribute numbers. <attr> can be any of the following:


































Text AttributeValue
None0
High Intensity
(bold)
1
Underline
(monochrome display only)
4
Blink5
Reverse7
Invisible8

 

































Color
Attribute
Foreground
Value
Background
Value
Black3040
Red3141
Green3242
Yellow3343
Blue3444
Magenta3545
Cyan3646
White3747


If you omit <attr>, all attributes are turned off (equivalent to specifying <attr> as 0).
    examples {ESC}[1m High intensity.

{ESC}[1;5m High intensity and blink.

{ESC}[30;46m Black foreground, cyan background.

{ESC}[m Turn off all attributes.

{ESC}[0m Turn off all attributes.

{ESC}[0;1;36m Turn off all attributes, then turn on high-intensity cyan foreground.

Set Display Mode {ESC}[=<mode>h
Sets the width and color capability of the display (generally equivalent to the DOS MODE command). This command can also be used to cause lines longer than 80 characters to be broken at the 80th character and continued on the next line, rather than truncated at the 80th column; this is called line wrap. It can be turned off with the Turn Off Line Wrap command. Note the equal sign (=) that precedes <mode>.

<mode> specifies the display mode. It can be one of the following:






































Display ModeValue
40 columns by 25 rows, black and white0
40 columns by 25 rows, color on1
80 columns by 25 rows, black and white2
80 columns by 25 rows, color on3
320 by 200 graphics, color on4
320 by 200 graphics, black and white5
640 by 200 graphics, black and white6
Turn on line wrap7


    examples {ESC}[=1h Set the display to 40 by 25 color on.

{ESC}[=7h Continued lines longer than 80 characters, don't truncate them.

Turn Off Line Wrap {ESC}[=7l
Causes lines longer than 80 characters to be truncated at the 80th character, rather than continued to the next line.
    examples {ESC}[=7l Truncate lines longer than 80 characters.

Keyboard Commands

Define Key {ESC}[<key code>;<result>p
Assigns one or more characters to be produced when you press a key.

<key code> specifies the key to be defined. If the key is one of the standard ASCII characters, <key code> is a number from 1 through 127. If the key is a function key, keypad key, or a combination of the <Shift>, <Ctrl>, or <Alt> key and another key, <key code> is two numbers separated by a semicolon and can be found in the ANSI.SYS key code table.
<result> is the character or characters to be produced when a key is pressed. It can be specified as an ASCII code, an ANSI.SYS key code, a string enclosed in quotation marks, or any combination of codes and strings separated by semicolons.
To restore a key to its original meaning, enter a Define Key command that sets <result> equal to <key code>.
    examples {ESC}[126;92p Redefine the tilde <~> key as a backslash <\>.

{ESC}[126;126p Restore the tilde <~> key to its original meaning.

{ESC}[0;112;"dir|sort";13p Redefine <Alt><F9> as a Directory command piped to a Sort command, followed by a Carriage Return.

{ESC}[0;112;0;112p Restore <Alt><F9> to its original meaning.





Notes



Entering the {ESC} Character

  • In DOS:  Press and hold the <Alt> key, then type 27 on the keypad.
  • In Windows:  Press and hold the <Alt> key, then type 0027 on the keypad.
  • Exceptions:  Sometimes the above keystrokes do not work. Try one of the following methods:


    • In MS-DOS EDITOR and QBASIC, type any one of these:

      • <Ctrl>P, <Alt>027
      • <Ctrl>P, <Ctrl>[
      • <Ctrl>P, <Esc>


    • In Microsoft WORD, use a macro:

      • Sub AsciiEscChar()
           ' Insert ASCII Esc character.
           Selection.TypeText Chr(027)
        End Sub

      • Save the file as "Text Only" or "MS-DOS Text".


    • In Microsoft NOTEPAD and WORDPAD:

      • Copy the {ESC} character from another text file and paste it into the document.




Enabling ANSI.SYS


Before using escape seqences, ANSI.SYS must be named as a device driver in the CONFIG system file.



For Windows 95, Windows 98 and DOS:


  • Create or edit the CONFIG.SYS file.   (Found in the root directory.)
  • Add the following line to the file:
    DEVICE=<path>\ANSI.SYS
    where <path> is the full path of the ANSI.SYS file.   (Usually found in the WINDOWS directory.)

  • Save CONFIG.SYS with the new line.
  • Check that a copy of ANSI.SYS exists in the specified path location.
  • Restart the computer to complete the change.




For Windows NT, Windows 2000 and Windows XP:

  • Create or edit the CONFIG.NT file.   (Usually found in the WINNT\SYSTEM32 directory.)
  • Add the following line to the file:

    DEVICE=%systemroot%\system32\ANSI.SYS

  • Save CONFIG.NT with the new line.
  • Check that a copy of ANSI.SYS exists in the specified path location.
  • Restart the computer to complete the change.




Restrictions:

  • Windows NT does not support ANSI.SYS escape sequences in Win32 Console applications.
  • The Windows 2000/NT Command Interpreter, CMD.EXE, does not support ANSI.SYS. Use COMMAND.COM instead.



Using ANSI.SYS Escape Sequences


Because ANSI.SYS commands control the console device, they must be typed at the keyboard or sent to the display.




  • Put the ANSI.SYS commands in a file and display the file with the TYPE or COPY command.
  • Use the PROMPT command with the command prompt code, $e.
    Example:

    prompt $e[1;37;44m   (Set the text color to bright white and the screen color to blue.)

  • Use the ECHO command in a batch file.
    Example:
    echo {ESC}[8;26H   (Move the cursor to row 8, column 26.)
    To execute a batch file containing ANSI commands in Windows 2000/NT, use one of the following methods:


    • Open a DOS command prompt window and type the <batch path>.
    • Type %SystemRoot%\system32\COMMAND.COM /c <batch path> at the Run command line.
    • Create a program information file (PIF) by making a shortcut of COMMAND.COM, then set the Cmd Line property to the <batch path> and the Advanced Program properties to %SystemRoot%\system32\AUTOEXEC.NT and %SystemRoot%\system32\CONFIG.NT.



  • Use the WRITE, PRINT or a similiar command in FORTRAN, C, BASIC, etc.
    Example:
    WRITE(*,*)'{ESC}[2J'   (Clear the screen.)



File Syntax and Parameters






ANSI.SYS Examples



Batch File


SCREEN.BAT demonstrates some Display Attribute and Cursor commands.




Command Prompt


Type the line below in a COMMAND.COM window to change the DOS command prompt.



  • prompt=$_$d$_$t$h$h$h$_$e[1;37;43mMy Computer$e[44m $p$g
  • View a screen shot.




Other Resources






[  Index  |  Technical Notes  ]





DISCLAIMER



Page author: Dawn Rorvik (rorvikd@evergreen.edu)

Last modified: 07/17/2003



20090603

http://sial.org/howto/rsync/ loop[back

http://sial.org/howto/rsync/&nbsp;
Hey There,<br><br>The problem may be because<br><br>
<div class="smallfont" style="font-size: 11px; margin-bottom: 2px; ">Quote:</div><table cellpadding="3" cellspacing="0" border="0" width="100%"><tbody><tr><td class="bbcodeblock" style="background-color: rgb(207, 217, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: inset; border-right-style: inset; border-bottom-style: inset; border-left-style: inset; border-color: initial; ">/home/ubuntu/dos/cd.squashfs</td></tr></tbody></table>from the /etc/fstab gets translated into&nbsp;<br><br><div class="smallfont" style="font-size: 11px; margin-bottom: 2px; ">Quote:</div><table cellpadding="3" cellspacing="0" border="0" width="100%"><tbody><tr><td class="bbcodeblock" style="background-color: rgb(207, 217, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: inset; border-right-style: inset; border-bottom-style: inset; border-left-style: inset; border-color: initial; ">/dev/loop0</td></tr></tbody></table>once it's mounted.<br><br>Have you tried using this line in /etc/fstab instead?:<br><br><div class="smallfont" style="font-size: 11px; margin-bottom: 2px; ">Quote:</div><table cellpadding="3" cellspacing="0" border="0" width="100%"><tbody><tr><td class="bbcodeblock" style="background-color: rgb(207, 217, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: inset; border-right-style: inset; border-bottom-style: inset; border-left-style: inset; border-color: initial; ">/dev/loop0 /home/ubuntu/dos/cd squashfs user,loop,ro 0 0</td></tr></tbody></table>It may or may not work, but it's worth a shot&nbsp;<img src="http://http.cdnlayer.com/lq/images/questions/images/smilies/smile.gif" border="0" alt="" title="Smilie" class="inlineimg" style="vertical-align: middle; "><br><br>Best wishes,<br>

macfuse

<a name="Compiling_Other_FUSE_File_Systems_Written_for_Linux"></a>
<a name="Compiling_Other_FUSE_File_Systems_Written_for_Linux">When running the configure script for a file system, you&nbsp;<strong>need</strong>&nbsp;to have&nbsp;<tt>-D__FreeBSD__=10</tt>&nbsp;in&nbsp;<tt>CFLAGS</tt>. This is critical!
Often, using the&nbsp;<tt>macfuse_buildtool.sh</tt>&nbsp;script to configure the software for compilation will work. As in the case of&nbsp;<tt>sshfs</tt>&nbsp;above, go to the top-level compilation source directory (the one that contains a&nbsp;<tt>configure</tt>&nbsp;script) of the software in question and run&nbsp;<tt>macfuse_buildtool.sh</tt>.
</a>

ipod notes maximum size

Your iPod will only hold 1000 Notes. Also, each Note can have a maximum size of 4000 characters. TouchCopy ensures that any Notes you create conform to these restrictions. Note that these are restrictions defined by your iPod, not TouchCopy.<br class="khtml-block-placeholder">

bash trick start as root when user != root

&nbsp;&nbsp;3 main () {
&nbsp;&nbsp;4 if [[ "$(whoami)" != 'root' || "$(id -u)" != 0 ]]; then
&nbsp;&nbsp;5 &nbsp; &nbsp;echo -e "Please give your user passwd, prog needs to run as root" ARH
&nbsp;&nbsp;6 &nbsp; &nbsp;/usr/bin/sudo $0 &nbsp;7 else

20090602

make iso osx

hdiutil makehybrid -o ~/image.iso ~/foo -iso -joliet<br class="khtml-block-placeholder">

20090529

http://www.terrencemiao.com/Webmail/msg00947.html

<pre style="word-wrap: break-word; white-space: pre-wrap; ">http://www.terrencemiao.com/Webmail/msg00947.html<br></pre>

20090527

Posted by Tom Cunningham on February 5 2004 5:42am

Tom's fulltext tips: To get MySQL searching well for me I did:

1. Have a normalized versions of the important columns: where you've stripped punctuation and converted numerals to words ('1' to 'one'). Likewise normalise the search string.

2. Have a combined fulltext index on your searchable columns to use in your 'WHERE' clause, but then have separate fulltext indexes on each column to use in the 'ORDER BY' clause, so they can have different weights.

3. For the scoring algorithm, include the independent importance of that record, and include a match of the inclusive index against stemmed versions of the search words (as: "wedding" => "wed", "weddings").

4. If there's exactly one result, go straight to that record.

5. If you get no results, try matching against the start of the most important column (WHERE column LIKE 'term%'), and put a 5-character index on that column. This helps if someone is searching on a very short word or a stopword.

6. Reduce minimum word length to 3, and make a new stopwords list just using "a an and the is in which we you to on this by of with". Use "REPAIR TABLE xxx QUICK" to rebuild the index and make a note of the index-file (xxx.MYI) size before and after you make changes. Then use ft_dump to tune.

http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html

11.8. Full-Text Search Functions

MATCH (col1,col2,...) AGAINST (expr [search_modifier])

search_modifier:
{
IN BOOLEAN MODE
| IN NATURAL LANGUAGE MODE
| IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION
| WITH QUERY EXPANSION
}

MySQL has support for full-text indexing and searching:

  • A full-text index in MySQL is an index of type FULLTEXT.

  • Full-text indexes can be used only with MyISAM tables, and can be created only for CHAR, VARCHAR, or TEXT columns.

  • A FULLTEXT index definition can be given in the CREATE TABLE statement when a table is created, or added later using ALTER TABLE or CREATE INDEX.

  • For large data sets, it is much faster to load your data into a table that has no FULLTEXT index and then create the index after that, than to load data into a table that has an existing FULLTEXT index.

Full-text searching is performed using MATCH() ... AGAINST syntax. MATCH() takes a comma-separated list that names the columns to be searched. AGAINST takes a string to search for, and an optional modifier that indicates what type of search to perform. The search string must be a literal string, not a variable or a column name. There are three types of full-text searches:

  • A boolean search interprets the search string using the rules of a special query language. The string contains the words to search for. It can also contain operators that specify requirements such that a word must be present or absent in matching rows, or that it should be weighted higher or lower than usual. Common words such as “some” or “then” are stopwords and do not match if present in the search string. The IN BOOLEAN MODE modifier specifies a boolean search. For more information, see Section 11.8.2, “Boolean Full-Text Searches”.

  • A natural language search interprets the search string as a phrase in natural human language (a phrase in free text). There are no special operators. The stopword list applies. In addition, words that are present in 50% or more of the rows are considered common and do not match. Full-text searches are natural language searches if the IN NATURAL LANGUAGE MODE modifier is given or if no modifier is given.

  • A query expansion search is a modification of a natural language search. The search string is used to perform a natural language search. Then words from the most relevant rows returned by the search are added to the search string and the search is done again. The query returns the rows from the second search. The IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION or WITH QUERY EXPANSION modifier specifies a query expansion search. For more information, see Section 11.8.3, “Full-Text Searches with Query Expansion”.

The IN NATURAL LANGUAGE MODE and IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION modifiers were added in MySQL 5.1.7.

Constraints on full-text searching are listed in Section 11.8.5, “Full-Text Restrictions”.

http://www.fastechws.com/tricks/sql/full-text-search-boolean.php

Full Text Searching with MySQL

When you want to let visitors search through a web-site's data by typing a search string, possibly containing multiple words, what's the best way to do that?

This is a question that web developers have been asking for a long time. There's many views on this subject, and many opinions. I generally want the best searching ability I can get without spending aeons of time (and cost) developing it.

Simple Searches

You may be thinking this is no big deal - your data is in a SQL database, so why not just do word-matching with "LIKE":

SELECT * FROM t1
WHERE description LIKE '%word%';

That is fine when you only have one word to search for, and one field to search in. But what if you have three fields (name, title, description) and the user types five keywords, such as "where is the Saharan Desert"? By eye, you can see that the really useful search keywords are "Saharan" and "Desert" - but how can your code possibly know that? If you require all 5 words to match, you won't return any matches at all.

Even if you knew that there are only 2 valid keywords, you can't just do a single match like this:

SELECT * FROM t1
WHERE description LIKE '%saharan%desert%';

That won't match everything that should match, because maybe some of the descriptions have the words in the other order. For two keywords, you really have to do two matches:

SELECT * FROM t1
WHERE description LIKE '%saharan%desert%'
OR description LIKE '%desert%saharan%';

You can imagine how this degrades - every combination of 3 keywords requires 6 different LIKE's; 4 keywords requires 24 combinations - that's factorial growth; it starts to get really big, and really slow!

Database Solution - Full Text Search

A really good solution to this and other problems related to search are solved by Full Text Search. Let the Database automatically maintain a special index of some sort that helps it find your matches quickly! You just provide the keywords to search for and which table fields should be searched. Simple.

The basic form is called "Natural Language Search", and has a number of cool features, including the ability to have a "stop list" - a list of words that are so popular, we ignore them because it would return too many records (too many mis-matches). Words like "is", "the", and "and" are way too popular. MySQL's built-in stop list is a text file that the administrator (root user) can change if needed.

In fact, with MySQL, when it builds the FT index for the specified fields in a table, it figures out other stop words - any word used in 50% or more of the records is automatically excluded from matching - which is good, you generally don't want half your table's records coming back as positive matches.

FTS queries look like this in MySQL:

SELECT * FROM articles
WHERE MATCH (title,body) AGAINST ('what is the saharan desert');

Setting up Full Text Search

For that query to work, your table must already have a FTS index created, which must have the exact fields that you're matching against (title and body, in the above example).

To create that index you would do the following, one time only:

ALTER TABLE articles
ADD FULLTEXT (title,body);

If you ever need to match against a different set of fields - say, just title, or just body, you'll need to create a whole other FULLTEXT index just for that. You can have many indexes on any table; it just takes more space (disk space, and sometimes memory).

Fancier Method - Boolean Matching

You know those advanced features of search engines like Google, where you can specify negative keywords with "-" sign, as in:

chili -bar -"new york"

because you want info on chili the food, not the bar and grill or the city in New York.

That, and a lot more, is built in to MySQL FTS - using Boolean Expressions. Boolean expressions include ways to vary the priority value based on certain keywords being there, or not being there. You can do partial-word matches (like "*" globbing in Unix, sort of). It honors double-quotes around "multiple words" when you want to find those words next to each other in the order shown. It can even let you group pieces of the boolean expression (with parentheses). Read the MySQL docs (see References below) to learn the syntax.

Notes and Limits with Full Text Search

Make sure your test data has at least 3 records. Think about it: 2 records won't work because ALL the words are found on 50% of the records, so everything's stoplisted!

If you want really advanced features such as configurable weight values per field, you will have to write more code yourself. You could put separate FT indexes on each field of the table, then build a query that has multiplier values (weights) for each field's results. This would probably result in more work for the database engine, but give you tighter results.

Another thing to remember is that (at least with MySQL), the Natural Language matching does not necessarily tell "how well" the match occurred; you only know that it matched or it didn't match. To get a nicer priority value back, use Boolean matching. You get a floating point value between 0 and 1, I believe.

References - MySQL Manual Online

MySQL Natural Language Matching

MySQL Boolean Expression Matching

Those links are for MySQL 5.0, but you can click on the other versions to see the related pages there.

Books

MySQL Cookbook from O'Reilly and Associates
Chapter 5 has a lot of info on Full Text Searches.

Conclusion

FTS has been around for a while - it should work with MySQL versions 4, 5, and the upcoming version 6. FTS exists in many other databases too, not just MySQL. However the syntax may vary with other database systems.

Overall, Full Text Search is very powerful and useful, and very easy to configure and use. It certainly saves a lot of time from having to do individual keyword matches yourself and try to determine which matches are "better" than which others.

<br><br><span style="font-weight: bold; ">INFORMATION</span>&nbsp;<br>Updates: Changed the version variable to '*' so it should now customize all U3 Drives without a problem.&nbsp;<br>New: Packaged the zip file with a command-line ISO maker.&nbsp;<br><br>I scanned the files with Norton AntiVirus 2006.&nbsp;<br><br>This computer application is not able to make a classic(normal) flash drive U3 compliant.&nbsp;<br><br>The pre-packaged 'U3CUSTOM.ISO' file is the loader for the U3 SwitchBlade/Hacksaw.&nbsp;<br><br>You might have to run this software 2 or more times before it works properly (you might get an error message) and manually put your files back on the flash drive and re-install your U3 software titles.&nbsp;<br><br>To make your own 'U3CUSTOM.ISO' file follow these directions. (XP/NT/2003 Only)&nbsp;<br><br>
<ul>1. Navigate to the directory where you extracted Universal_Customizer.zip to and open the 'U3CUSTOM' folder.&nbsp;<br>2. Copy your custom files* to that folder.&nbsp;<br>3. Go to the parent directory.&nbsp;<br>4. Execute 'ISOCreate.cmd' (It will create an ISO with the CD name of 'U3CDROM')&nbsp;<br>5. Launch 'Universal_Customizer' and your done.</ul><br>*Use the files in the folder where you backed up your U3 CD-ROM if you want to restore your U3 LaunchPad.&nbsp;<br><br><span style="font-weight: bold; ">U3 FIRMWARE ISO's</span>&nbsp;<br><a href="http://www.sendspace.com/file/5vr8rd" target="_blank" class="postlink" style="color: rgb(0, 102, 153); text-decoration: none; ">Memorex LaunchPad</a>&nbsp;<br><a href="http://www.sendspace.com/file/clwcdg" target="_blank" class="postlink" style="color: rgb(0, 102, 153); text-decoration: none; ">SanDisk LaunchPad</a>&nbsp;<br>
<h2 style="color: black; background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; font-weight: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0.6em; margin-left: 0px; padding-top: 0.5em; padding-bottom: 0.17em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); font-size: 19px; background-position: initial initial; "><span class="mw-headline">Briefcase Reconciler</span></h2>When&nbsp;<a href="http://en.wikipedia.org/wiki/Microsoft_Office_Access" title="Microsoft Office Access" class="mw-redirect" style="text-decoration: none; color: rgb(0, 43, 184); background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; background-position: initial initial; ">Microsoft Office Access</a>&nbsp;is installed, the Windows Briefcase can be used as a replication tool by dragging an Access database (<tt>.MDB</tt>) file to the Briefcase so that the database is automatically converted into replicable form.&nbsp;<sup id="cite_ref-2" class="reference" style="line-height: 1em; font-weight: normal; font-style: normal; "><a href="http://en.wikipedia.org/wiki/Briefcase_(Microsoft_Windows)#cite_note-2" title="" style="text-decoration: none; color: rgb(0, 43, 184); background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; white-space: nowrap; background-position: initial initial; "><span>[</span>3<span>]</span></a></sup>&nbsp;The Design Master can be left at the source and replica put into the Briefcase or vice versa. When synchronizing, the replicas are merged by the Briefcase reconciler.

http://www.wayne-robinson.com/journal/2006/11/11/multiple-values-from-scriptaculous-autocomplete.html

Multiple Values from Scriptaculous' Autocomplete
Saturday, November 11, 2006 at 04:48PM
Wayne Robinson in javascript, programming, ruby on rails

Ever wanted to extract multiple values from a Script.aculo.us Google Suggest-like autocomplete text field? I recently did and here's how.

If you aren't aware of how to use autocomplete text fields, please read over the simple and customised demos available at Script.aculo.us. Also, a warning, this demo utilises Ruby on Rails however, with a little bit of modification, this should work using the Script.aculo.us library without Ruby on Rails.

This example will auto-populate a state and postcode based on the user's selected suburb (yes, I'm Australian).

The first step is to create a view for the page containing the autocomplete field and for the autocomplete field itself.

Controller:

def new

# This is the main controller that will
# contain the autocomplete field
@contact = Contact.new
end

def auto_complete_for_suburb
suburb = params[:suburb]
@surburbs = Suburb.find_by_name(suburb,
:order => "name", :limit => 20)
render :partial => "auto_complete_suburb"
end

View for the new action (assume an application.rhtml template has been created, this template must include the Prototype and Script.aculo.us javascript libraries):

<%= form_tag({:action => :create}, {:method => :post}) %>


















Name: <%= text_field(:contact, :name) %>
Suburb: <%= text_field_with_autcomplete(:contact, :suburb,
:select => "value",
:after_update_element =>
"function (ele, value) {
$("contact_state").value =
Ajax.Autocompleter.extract_value(value,
'STATE');
$("contact_postcode").value =
Ajax.Autocompleter.extract_value(value,
'POSTCODE'); }
") %>
State: <%= text_field(:contact, :state, :size => 10) %>
Postcode: <%= text_field(:contact, :postcode,
:size => 10) %>

<%= end_form_tag %>

Before we continue any further, it is worth-while defining the _auto_complete_suburb.rhtml partial.


    <% unless @suburbs.nil? -%>
    <% @suburbs.each do | suburb | -%>

  • <%= h("#{suburb[:name]}, #{suburb[:state]}" +
    "#{suburb[:postcode]}") %>




  • <% end -%>
    <% end -%>

The autocompleter view has three (3) hidden

tags which contain the extra data used by the base Autocompleter Javascript methods as well as the new one (extract_value) that will be defined below.

You may also want to cast your eye over the suburb field definition in the new contact view as this is where most of the action is. There are two options to note:

  • the :value option which specifies the class name of the element which contains the value to place in attribute (the default would be whatever is within the rendered
  • field which, as we will find out below, will contain more than just the selected suburb)
  • the :after_update_element option which specifies a piece of Javascript to execute when the item is selected. You will see that this Javascript executes the Ajax.Autocompleter.extract_value function twice. This function does not exist in Script.aculo.us but is provides an easy way to extract extra values from an autocomplete list.

The Script.aculo.us Autocompleter methods conviently pass the complete contents of the

  • field to the method specified in the :after_update_element option. This allows us to extract any additional values from this data. I have created a simple addition to the Ajax.Autocompleter class below that speeds this extraction:

    Additional method for Ajax.Autocompleter class. This can be declared anywhere after the inital Script.aculo.us script inclusion. For my purposes I put this at the top of my application.js file.

    Ajax.Autocompleter.extract_value =
    
    function (value, className) {
    var result;

    var elements =
    document.getElementsByClassName(className, value);
    if (elements && elements.length == 1) {
    result = elements[0].innerHTML.unescapeHTML();
    }

    return result;
    };

    So that's all there is to it. If anyone would like me to create a demo of the above code, ask me and, if I get enough requests, I'll put something together.

  • Article originally appeared on Wayne Robinson's Blog (http://www.wayne-robinson.com/).
    See website for complete article licensing information.

    http://www.edgeblog.net/2006/defending-against-u3-switchblade/

    October 12, 2006
    Defending against U3 & Switchblade
    Filed under: Security — bill @ 10:22 pm

    U3U3 is a fun new technology for USB flash devices. U3 flash drives contain a partition that emulates a CD-ROM drive, where U3 enabled applications are installed. The CD emulation means that these devices will auto-play on most XP, 2000 and 2003 computers, when the drive is inserted. The talented folks over at hak5.org have created several projects, including Switchblade and its younger cousin Hacksaw, which exploit this technology for hacking/pen testing.

    U3 reinforces the old security axiom, “if I can touch it, I own it.” Using auto-play with exploit code is nothing new. CDs can be used in this manner. What is new is the ability to run this on a writeable device. As the hak5 guys have proven, this is a deadly combo. Plug your USB drive in, wait for it to suck off password hashes or key files, install a back-door, and be gone. This works even if the screen is locked. One more reason why at some companies, the janitor is the richest guy in the place.

    As pen testers, U3 is just one more tool to make our lives easier. As security managers, developing a defense in depth against U3 is difficult. Here are a few suggestions to make it easier. Most of these are just good general security practices, but U3 increases their importance:

    1. Assign the least amount of privileges possible to your users. Programs run with U3 execute with the privileges of the logged-on user. Unless, of course, the hacker includes a privilege escalation exploit on the drive.
    2. Keep systems patched. This reduces the # of possible exploits.
    3. Never leave systems logged in with admin access. Locking the screen does not protect against auto-play. Admins should always log out when done.
    4. Disable auto-play. (Instructions below)
    5. Restrict USB devices. Several vendors offer solutions to disable USB ports, or restrict them to authorized devices.
    * GFI EndPoint Security
    * ControlGuard Endpoint Access Manager
    * SafeEnd Protector
    * Device Lock
    * SecureWave Sanctuary
    * DeviceWall
    * TriGeo USB-Defender

    There are mulitple ways to disable auto-run. The best way is to use group policy. Go to computer config>admin templates>system and find the “turn autoplay off option. This option makes a registry entry in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer. You can also create this key manually. For stand-alone PCs, the TweakUI PowerToy from Microsoft can also be used. TweakUI offers a disable autoplay option under the “My Computer section.

    The last tool in your arsenal is training. Teach your users not bring in USB devices from home, or plug-in flash drives the find or are sent in the mail. This seems like common sense, but several security testers have shown that users will pickup drives on the ground and plug them in to their PCs to see what is on them. The most famous example of this is the test Steve Stasiukonis wrote about in the Dark Reading blog. 20 Flash drives on the ground outside a bank yielded 15 compromised systems. Flash drives work better for this type of test than CDs, because users perceive them as valuable since they are re-writable. A good security education program would prevent this.

    If you have other ideas for protecting against flash drives and U3, we’d love to hear about them.

    -Bill
    Permalink
    Thanks for stopping by.
    If you found this article useful, please leave a tip.

    3 Comments »

    1.
    Bill said,

    October 23, 2006 @ 11:50 am

    Nice piece!
    2.
    edgeblog » 10 New Immutable Laws of IT Security said,

    October 23, 2006 @ 4:25 pm

    [...] An unsupervised janitor is the richest guy in your company - See rule 4. As I’ve discussed before, a USB key with U3 and a PC with AutoPlay is all it takes to get passwords, install software, and generally 0wn a PC. Couple that with your administrator’s terminals and you have a recipe for disaster. Would you really trust your janitor to do the right thing if I offered him $1,000 to plug a USB drive into a PC for 10 minutes and then bring it back to me? Physical security extends beyond the data center to include every system that has privileged access. How secure are your admin’s home PCs? Your CIO’s? [...]
    3.
    dante said,

    March 4, 2007 @ 6:56 am

    hello bill, i had a question about your switchblade article, i am not sure switchblade can run if the screen is password protected. i have tried on two laptops, and it only works when the screen is not locked. if i have missed something, please let me know… thanks for your time.

    RSS feed for comments on this post · TrackBack URI
    Leave a Comment

    Name (required)

    E-mail (required)

    URI

    *
    Categories
    o Home
    o Books
    o Compliance
    o Data Center Design
    o General
    o Networks
    o Politics
    o Popular
    o Scripting
    o Security
    o Software
    o Systems
    *
    Pages
    o About
    o Donate
    *
    Archives
    o May 2009
    o January 2009
    o November 2008
    o October 2008
    o September 2008
    o August 2008
    o January 2008
    o October 2007
    o June 2007
    o May 2007
    o March 2007
    o February 2007
    o January 2007
    o December 2006
    o November 2006
    o October 2006
    o September 2006
    *
    e-Tip Us!

    *
    Book Recommendations
    o 19 Deadly Sins of Software Security
    o Cheat at Windows SysAdmin
    o Experts’ Guide to OS/400 & i5/OS Security
    o Google Hacking
    o Google Maps Applications
    o Gray Hat Hacking
    o Grid Networks: Advanced Tech
    o Hacking iSeries
    o How to Break Software Security
    o How to Break Web Software
    o How to Cheat at Infosec
    o Internetworking Technologies Handbook
    o Metasploit Toolkit
    o Metasploit Toolkit for Penetration Testing
    o Protect Your Windows Network
    o RFID Security
    o Security Warrior
    o SELinux By Example
    o Silence on the Wire
    o Stealing the Network: How to Own a Continent
    o Stealing the Network: How to Own a Shadow
    o Stealing the Network: How to Own an Identity
    o Stealing the Network: How to Own the Box
    o The Security Development Lifecycle
    o Ubuntu Hacks
    o Windows Powershell in Action
    o WordPress 2 Quickstart
    o Writing Secure Code, 2nd ed.
    o Zen of CSS Design
    *
    Friends
    o EdgeBack
    o edgeproxy
    o Gadget Workshop
    o iQuotient
    o IronScale
    o R3publicans
    o Raging Wire
    o Secure Insanity
    o The Digerati Life
    *
    Security Links
    o CERT/CC
    o CVE
    o Foundstone
    o Full Disclosure
    o Infosec Institute Blog
    o OSSTMM
    o Switchblade
    *
    CERT⁄CC
    o Microsoft Releases Service Pack 2 for Windows Vista and Windows Server 2008
    o Novell Releases Updates for GroupWise
    o NSD DNS Buffer Overflow Vulnerability
    o Cisco Releases Security Advisory for CiscoWorks TFTP Vulnerability
    o Mac OS X Includes Known Vulnerable Version of Java
    *
    Northern Cal Jobs (Dice)
    o SW Engr 2
    o SW Engr 2
    o Technical Support
    o Entrepreneurial Leader
    o Oracle DBA
    o Installation Technician
    o Oracle DBA
    o Software Engineer
    o Systems Engineer Intern/Graduate - College
    o CIO


    Xobni outlook add-in for your inbox
    Digg!

    ©2006 William L. Dougherty • Design based on Corporate Pro by Mystical Twilight ·



    --
    map{ map{tr|10|# |;print} split//,sprintf"%.8b\n",$_}
    unpack'C*',unpack'u*',"5`#8<3'X`'#8^-@`<-CPP`#8V/C8`"

    Scriptaculous Autocomplete Page Jump Using Arrow Keys

    Scriptaculous Autocomplete Page Jump Using Arrow Keys
    Tags: CSS, JavaScript, Scriptaculous

    When you use overflow:auto in your css in conjunction with Scriptaculous’ Autocomplete, there is a bug that makes the entire page jump around when you use the arrow keys on your keyboard to navigate up and down through the suggestion list. This bug normally appears only when the page itself is long enough to require a scroll bar.

    I managed to come up with a very clean working solution by hacking the controls.js file that comes with scriptaculous. The solutions requires replacing the markPrevious and markNext functions and adding a small line of code to the updateChoices function.

    Currently, markPrevious and markNext are telling the page to jump around like that, and I’m not sure why! As far as I can tell (please let me know otherwise) this solution could be included in the scriptaculous without breaking a thing (hint, hint to the scriptaculous team).

    To implement the solution, replace:

    markPrevious: function() {
    if(this.index > 0) this.index--;
    else this.index = this.entryCount-1;
    this.getEntry(this.index).scrollIntoView(true);
    },

    markNext: function() {
    if(this.index < this.entryCount-1) this.index++;
    else this.index = 0;
    this.getEntry(this.index).scrollIntoView(false);
    },

    With:

    markPrevious: function() {
    if(this.index > 0) {this.index--;}
    else {
    this.index = this.entryCount-1;
    this.update.scrollTop = this.update.scrollHeight;
    }
    selection = this.getEntry(this.index);
    selection_top = selection.offsetTop;
    if(selection_top < this.update.scrollTop){
    this.update.scrollTop = this.update.scrollTop-selection.offsetHeight;
    }
    },

    markNext: function() {
    if(this.index < this.entryCount-1) {this.index++;}
    else {
    this.index = 0;
    this.update.scrollTop = 0;
    }
    selection = this.getEntry(this.index);
    selection_bottom = selection.offsetTop+selection.offsetHeight;
    if(selection_bottom > this.update.scrollTop+this.update.offsetHeight){
    this.update.scrollTop = this.update.scrollTop+selection.offsetHeight;
    }
    },

    Now find the updateChoices function and just after the code this.stopIndicator(); add this.update.scrollTop = 0; so that it looks like this:

    this.stopIndicator();
    this.update.scrollTop = 0;
    this.index = 0;

    I’ve tested in FF 2.0.0.4, FF 3.0.5, Chrome 1.0.154.43, Safari 3.2.1, Opera 9.5.1, IE 7.0.5730.13 and IE 6.0.2600 without problems.
    Bookmark and Share

    --
    map{ map{tr|10|# |;print} split//,sprintf"%.8b\n",$_}
    unpack'C*',unpack'u*',"5`#8<3'X`'#8^-@`<-CPP`#8V/C8`"

    20090507

    ടി ലികെസ്‌ ടോ കോഡ് ;)

    t likes to code ;)


    if (is_numeric($kkey) && $kkey != ($fid = getFieldId($kkey)) ) {

    --
    map{ map{tr|10|# |;print} split//,sprintf"%.8b\n",$_}
    unpack'C*',unpack'u*',"5`#8<3'X`'#8^-@`<-CPP`#8V/C8`"

    20090504

    osx dns

    NAME
    &nbsp;&nbsp; &nbsp; scutil -- Manage system configuration parameters

    SYNOPSIS
    &nbsp;&nbsp; &nbsp; scutil
    &nbsp;&nbsp; &nbsp; scutil --prefs [preference-file]
    &nbsp;&nbsp; &nbsp; scutil -r { nodename | address | local-address remote-address }
    &nbsp;&nbsp; &nbsp; scutil -w dynamic-store-key [-t timeout]
    &nbsp;&nbsp; &nbsp; scutil --get pref
    &nbsp;&nbsp; &nbsp; scutil --set pref [newval]
    &nbsp;&nbsp; &nbsp; scutil --dns
    &nbsp;&nbsp; &nbsp; scutil --proxy

    setuid root

    You could have sudo not ever require a password for a certain command with an entry in /etc/sudoers:<br><br>
    <div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px; "><div class="smallfont" style="font: normal normal normal 11px/normal verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; margin-bottom: 2px; ">Code:</div><pre class="alt2" dir="ltr" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(230, 230, 230); color: rgb(0, 0, 0); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 6px; padding-right: 6px; padding-bottom: 6px; padding-left: 6px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: inset; border-right-style: inset; border-bottom-style: inset; border-left-style: inset; border-color: initial; width: 480px; height: 34px; text-align: left; overflow-x: auto; overflow-y: auto; background-position: initial initial; ">mikuro ALL= NOPASSWD: /path/to/command
    </pre></div><span>Or for the setuid route, it looks like in Leopard setting the setuid bit isn't enough any more --&nbsp;<span class="IL_LINK_STYLE" style="position: static !important; text-decoration: underline; background-image: none !important; background-repeat: repeat !important; background-attachment: scroll !important; -webkit-background-clip: initial !important; -webkit-background-origin: initial !important; background-color: transparent !important; cursor: pointer !important; display: inline !important; color: rgb(0, 0, 255); padding-bottom: 1px !important; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(0, 0, 255); font-size: 13px; font-weight: normal; font-style: normal; font-family: verdana; background-position: 0% 50%; ">the code</span>&nbsp;also has to call setuid(), which is the way it should be, I believe. So for example:</span><br><br><div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px; "><div class="smallfont" style="font: normal normal normal 11px/normal verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; margin-bottom: 2px; ">Code:</div><pre class="alt2" dir="ltr" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(230, 230, 230); color: rgb(0, 0, 0); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 6px; padding-right: 6px; padding-bottom: 6px; padding-left: 6px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: inset; border-right-style: inset; border-bottom-style: inset; border-left-style: inset; border-color: initial; width: 480px; height: 162px; text-align: left; overflow-x: auto; overflow-y: auto; background-position: initial initial; ">#include <stdio.h>
    int main(void)
    {
    if (setuid(0) &lt; 0)
    fprintf(stderr, "setuid() failed\n");
    else
    system("/usr/bin/whoami");
    return(0);
    }
    </stdio.h></pre></div>Try that with the setuid bit set and it should do what you want.<br><br>I'll spare you the usual security warnings and all that...&nbsp;<img src="http://macosx.com/forums/images/smilies/apple.gif" border="0" alt="" title="Apple Smile" class="inlineimg" style="vertical-align: middle; ">__________________<br><a href="http://cyberfeen.wordpress.com/" target="_blank" style="color: rgb(0, 51, 102); text-decoration: underline; ">Tech Blog</a>

    20090430

    Using a Linux L2TP/IPsec VPN server with Mac OS X and iPhone

    Using a Linux L2TP/IPsec VPN server with Mac OS X and iPhone

    --
    map{ map{tr|10|# |;print} split//,sprintf"%.8b\n",$_}
    unpack'C*',unpack'u*',"5`#8<3'X`'#8^-@`<-CPP`#8V/C8`"