... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2007-12-19

Ecmascript RegExp

Here are a couple of fine points about Ecmascript regular expressions worth noting.

The '.' atom does not match the four line terminator characters LF, CR, LS, and PS.  This is true irrespective of the presence of the multiline flag in the expression.

You indicate that a quantifier should be non-greedy by suffixing the pattern with '?'.  For example, '.*?', '.+?', '.??' etc.

These points are true for most other regular expression implementations as well.


2007-12-17

WScript vs. ERRORLEVEL

If you invoke a Windows script directly from a command prompt, it will be launched using WScript and its exit status (set using WScript.Quit) will be gobbled.  If you launch it using CScript, the exit status will be returned properly.  Interestingly, if you invoke a script file from within a batch file, CScript is used automatically, despite the default file association to WScript.


2007-12-13

BAT Files vs. Variable Expansion

You might think that the following BAT script would print out the word right:

set answer=wrong
if "a" == "a" (
    set answer=right
    echo %answer%
)

... but it actually prints out wrong.  The reason is that the BAT processor expands the variable answer when it is read, not when it is executed.  To work around this problem, you must use an extension, thus:

setlocal enabledelayedexpansion
set answer=wrong
if "a" == "a" (
    set answer=right
    echo !answer!
)

Note the use of exclamation marks instead of percent signs to delimit the delayed expansion of the variable answer.


2007-12-10

TCPMon

TCPMon has been moved out of the Axis project and into a subproject of its own in the Apache Web Services commons.


Blank JMeter Response Data

I was testing a web application using JMeter, and the Response data tab of an HTTP Request sampler was always empty.  It turns out that JMeter does this if the content type of the response is not in a blessed list of "text" responses.  In my case, the content type was application/xml which is not on the list by default.  To fix it, edit the jmeter.properties file to include a line like this:

content-type_text=application/xml

This directive specifies additional types to supplement the built-in types (text/*, etc). The shipped jmeter.properties file comes with a template line for this property.

2007-12-03

SQL Server OBJECT_ID

In SQL Server 2005, the function OBJECT_ID takes a second argument which specifies the type of the object (e.g. 'U' for user table).  It turns out that SQL Server 2000 will also accept this parameter (at least, SP3 will).  This is not documented behaviour and does not work if you attempt to compile a procedure that calls OBJECT_ID with the second parameter (you get the message 'Invalid parameter 2 specified for object_id).


Blog Archive