Rob Eberhardt

cleverness ensues

skip navigation

 Tuesday, April 19, 2005

"A modern computer is a magic box filled with ceremonial components that traps in a little evil spirit who is forced to work for you."

Nothing like a little Fenestredigitation, Open Sourcery, and Voodoo Debugging to start the day.

4/19/2005 10:02 AM Eastern Daylight Time  #    Disclaimer  |  Comments [0]  | 

 Saturday, April 09, 2005

 Wednesday, April 06, 2005

I thought I'd share some Small Business Server 2003 security silliness.  Following is a series of Internet Explorer dialogs when you setup VPN via the Remote Web Workplace:

---------------------------
Microsoft Internet Explorer
---------------------------
After you install Connection Manager, ensure that all users of this computer have strong passwords to protect the security of your Windows Small Business Server network.
---------------------------
OK   
---------------------------

---------------------------
File Download - Security Warning
---------------------------
Do you want to run or save this file?
    Name: sbspackage.exe
    Type: Application, 503 KB
    From: ---
---------------------------
Run   Save   Cancel
---------------------------
While files from the Internet can be useful, this file type can potentially harm your computer. If you do not trust the source, do not run or save this software. What's the risk?

---------------------------
Internet Explorer
---------------------------
The publisher could not be verified.  Are you sure you want to run this software?
         Name: sbspackage.exe
    Publisher: Unknown Publisher
---------------------------
Run   Don't Run
---------------------------
This file does not have a valid digital signature that verifies its publisher. You should only run software from publishers you trust. How can I decide what software to run?

---------------------------
Connect to Small Business Server
---------------------------
Do you wish to install the connection to Small Business Server?
---------------------------
Yes   No   
---------------------------

Notice the Big Red Flag??  Microsoft's SBS team never signed the VPN installer (sbspackage.exe), so IE on XPSP2 (and presumably 2003SP1 now) does its scary "don't take candy from strangers" warning.  (How long has Microsoft been touting executable signing now?!?) 

*sigh*

 

4/6/2005 4:43 PM Eastern Daylight Time  #    Disclaimer  |  Comments [0]  | 

 Friday, April 01, 2005

I just asked a guru of advanced Object-Oriented Javascript, Douglas Crockford the following question.  For posterity, and for other possible takers, I'm posting it here too.

Also, for the record, this has nothing to do with IE's proprietary -- but wonderful -- setExpression method or CSS expression capabilities.  Those dynamic properties only apply to DOM objects, not custom Javascript objects.


Do you know of a way to define dynamic object properties in Javascript?

For example, VBScript lets us define classes such as this:

CLASS myClass
    PUBLIC phrase
    PUBLIC PROPERTY GET firstword    'get first word from phrase
        firstword = left(phrase, instr(phrase, " "))
    END PROPERTY
    PUBLIC PROPERTY LET firstword(v) 'set phrase's new first word
        phrase = v & " " & phrase
    END PROPERTY
END CLASS

This demonstrates two important features:
1. the firstword property can return dynamic results (depending on the current value of the phrase property). 
2. setting the firstword property can run other code (which dynamically prepends to the phrase property).

We can fully accomplish #1 (Property Get) in Javascript, by reassigning the toString method/property to a function like so:

function myConstructor(){
    var self = this;    //preserve object's context
    this.phrase = '';
    this.firstword = function(v){
        if(v){self.phrase = v + ' ' + self.phrase};    //LET
        return self.phrase.substring(0, self.phrase.indexOf(' ')); //GET
    }
    this.firstword.toString = this.firstword;
}

...But I've found no way to achieve #2 (Property Let or Set) in Javascript.  I can set firstword as a method, but setting the property value overwrites the method definition (and all subsequent GETs return that static value).

I've extensively searched, but found no answer (at least not before Javascript 2.0, which doesn't yet exist).  Any ideas from the experts?

Update: Douglas Crockford responded that he doesn't care for getter/setter properties, since "it allows simple assignment to have side effects, which I think works against reliability."  (I take that as a "No, it's not possible.")
    My current need is that I'm patterning my custom object after part of the DOM, whose objects certainly do have getter/setters.  I agree with Douglas that getter/setter side effects can be dangerous (esp. in the hands of a poor coder, as with any powerful code construct), but I think the use of methods -vs- getter/setter properties should be in the realm of "best practice" rather than a language limitation. 

4/1/2005 3:25 AM Eastern Daylight Time  #    Disclaimer  |  Comments [7]  | 

 Thursday, March 31, 2005

 Wednesday, March 30, 2005

I've run into this often: the need to have a VBScript constant containing a line-break character.  Today I finally got a definitive answer on whether it's possible (for the impatient, the answer is NO).

If you're interested in history...

Of course this is right out:

CONST blah = "hello 
there"
...It's just bad syntax.  The closing string quote has to be on the same line as the opening one.

The normal approach I've tried was this:

CONST blah = "hello " & vbCRLF & " there"
..But the ampersand (concatenation operator) automatically makes it an expression to the VBScript compiler, and therefore it assumes "not constant." This is of course despite the fact that both parts are known at the time of compilation (which is the main criterion for a constant -- value is known at compile time).  Anyway, the ampersand is right out.

Now in JScript/Javascript/ECMAScript, you can do this:

var blah = "hello \r\n there"
...The \r\n switches define the line-break character, they go inside the string, and they are only interpreted when it's read. 

Unfortunately, there's no similar switch in VBScript.  While HTML does honor ASCII codes like 
 or 
, and web browsers honor hexadecimal codes in URLs, VBScript does neither.  So these also don't work:

CONST blah ="hello 

 there"
CONST blah = "hello %0A%0D there"
CONST blah = "hello 0x0A0x0D there"

So I was reading a blog entry by Eric Lippert (who I believe wrote most of VBScript) today, and he mentioned Constant Folding, and proceeded to outline the mechanics behind this VBScript constant problem.  It rung a bell, I asked about line-breaks in VBScript constants in his comments, and Eric responded:
"Sorry, you are correct -- there's no way to do that. Sub-optimal, I know. "
...Straight from the dev's mouth.

SO, if you need a line-break in a VBScript constant, just use a variable instead:

DIM blah
blah = "hello " & vbCRLF & " there"
...Yes, there may be some slight performance penalty compared to a constant, but it is script after all -- racing performance ain't the point.

3/30/2005 7:37 PM Eastern Daylight Time  #    Disclaimer  |  Comments [1]  |