Wednesday, August 22, 2007

Working in metadata removal from Office documents, one thing I do almost constantly is dig through files with a hex editor looking for any text that's readable.

I'd been contemplated writing a string filter utility for some time when I happened to see an offhand mention of something like that from SysInternals.

Now, if you've ever played with anything from the guys at Sysinternals (now a part of Microsoft), you know their stuff is gold, so I had to check it out.

The utility is called Strings. It does exactly that, pulls strings (both ANSI and UNICODE) from any file you throw at it and spits em out STDOUT. Pipe it to a file and it's MONEY, BABY!

Even better, put STRINGS.EXE and this little BAT file somewhere on your path, then setup a shortcut to the BAT file in your SEND TO folder, and you can Right click-Send To on any file and immediately have all the strings loaded up into whatever Text Editor is currently associated with TXT files. And that, as an old boss of mine would say, is "bells, whistles, hell, it's the whole damn midway!" 

ECHO OFF
REM Run the strings.exe program to extract all strings from a given file
REM Then load the file into an editor
REM 
REM Create a Shortcut to this BAT file in your SENDTO folder to make it even
REM better! Then, you can right click, select SEND TO and immediately get a full
REM list of strings embedded within the file loaded into your editor.


REM Extract the strings to a temp file
strings -q %1 >"%temp%\%~n1-Raw.txt"


REM Sort strings to make it a bit easier to find things
REM This may or may not be something you want to do consistently
REM Either do the sort or the copy
REM sort "%temp%\%~n1-raw.txt" /o "%temp%\%~n1.txt"
copy "%temp%\%~n1-Raw.txt" "%temp%\%~n1.txt"
del "%temp%\%~n1-Raw.txt"


REM -----------
REM Use this to load the file into whatever editor is associated with a TXT file
REM -----------
start "Strings" /I /B "%temp%\%~n1.txt"

REM OR

REM -----------
REM Use this to load the file into a specific named editor
REM -----------
REM o:\dev\protools\textpad\textpad "%temp%\%~n1.txt"
posted on Wednesday, August 22, 2007 10:19:41 PM (Central Standard Time, UTC-06:00)   •  # •  Comments [0] • 
Kick it •  Add to del.icio.us •  View blog reactions; 
 Tuesday, August 21, 2007

This is one of those often used functions in VB6 that could use a little improvement. The main problem with CreateObject is when it throws an error, it doesn't report what object it was attempting to create at the time, which would be quite a handy thing to know.

Fortunately, CreateObject is one of small number of intrinsic functions in VB that can be overridden quite easily.

In other words, you can define your own CreateObject function, and VB will call your version instead of it's built in version anywhere that you use it. This is quite handy because it means you can use the enhanced version without changing any calling code.

For instance, here's a CreateObject function I put together that expands on the default error message string if it encounters a problem creating the object asked for. It simply adds in the PROGID of the object you're trying to create.

Public Function CreateObject(ByVal Class$, Optional ByVal ServerName$) As Object
   '---- override the CreateObject
   '     function in order to register what
   '     object is being created in any error message
   '     that's generated
   Dim Source$, Descr$, ErrNum

   On Error Resume Next
   If Len(ServerName$) Then
      Set CreateObject = VBA.CreateObject(Class$, ServerName$)
   Else
      Set CreateObject = VBA.CreateObject(Class$)
   End If

   If VBA.Err Then
      Source$ = VBA.Err.Source
      Descr$ = VBA.Err.Description
      ErrNum = VBA.Err
      Descr$ = Descr$ & " (ProgID: " & Class$
      If Len(ServerName$) Then
         Descr$ = Descr$ & ". Instantiated on Server '" & ServerName$ & "'"
      End If
      Descr$ = Descr$ & ")"
      On Error GoTo 0
      VBA.Err.Raise ErrNum, Source$, Descr$
   End If
   On Error GoTo 0
End Function

Put this function in a normal BAS module, and anywhere that you use CreateObject already, you'll now be calling this function.

And to answer a few questions:

Q: Why do you use the VBA prefix for CreateObject and the ERR object in this piece of code?

A: In the case of CreateObject, you have to prefix it or this function would end up calling itself instead of the real VB CreateObject function.

In the case of the ERR object, see below.

Q: What other functions can be overridden?

I haven't done an exhaustive study of it, but I can say that a particularly handy object to override is the built in VB ERR object defined in the VBA library.

Overriding that object allows you to extend error handling functionality in all sorts of ways.

For instance, you could add a LOG method to the ERR class, or a MSGBOX method that automatically formats an error for display in a message box.

But that's a topic for another post. 

posted on Tuesday, August 21, 2007 8:33:17 PM (Central Standard Time, UTC-06:00)   •  # •  Comments [2] • 
Kick it •  Add to del.icio.us •  View blog reactions; 

John Dvorak wrote a very interesting article for PCMag on 8/14, Google Pulls Plug, Everyone Misses Point.

I've been saying web apps were overhyped ever since SalesForce first came out and was getting tons of hype back in the 90's, and that's not because I used to work at a competitor (gotta love the wayback machine).

On the surface, it's a great idea. No installation. No deployment headaches. No massive, multi machine upgrade pains. And with AJAX, and now SilverLight, you can get a user experience approaching a traditional fat client. Plus, with broadband nearing ubiquity, some of the bandwidth issues of the past are no more.

And for many installations, where users can connect to a centralized server within the company's domain, it often is a very smart architecture.

So what's the problem?

Dvorak points to the demise of the Google DTO/DTR program as exactly the problem. Imagine if it was YOUR BUSINESS that was running off the DTO program and Google pulled the plug. "Oh, you won't be able to access your customer records after Aug 8th, but here's a coupon for 2 bucks at Google Checkout you can use for the next 2 months."

I doubt SalesForce is going anywhere anytime soon, and they do have a compelling product. I'm not even picking on them, per se. But the whole idea of putting that kind of trust into an app that's running completely NOT under your control is just a little, eh, bothersome?

In fact, I tend to believe that the absolute BEST thing that could happen for everyone is for a few more biggies, like Google Apps, or SalesForce, or Microsoft MSN Mail, etc, to bite the dust and strand millions of people.

It'd hurt, but people would take a serious look at the implications of relying on ASPs to supply services like that.

There were some big reasons back in the early 80's that the personal computer and the fat client app, as opposed to the mainframe and the dumb terminal, because so popular. Some of them have been forgotten, and unfortunately, it might take a few tough lessons to remind people.

posted on Tuesday, August 21, 2007 4:10:05 PM (Central Standard Time, UTC-06:00)   •  # •  Comments [4] • 
Kick it •  Add to del.icio.us •  View blog reactions; 
 Monday, August 20, 2007

This project has been out a LONG time (looks like it was last messed with in 2001), but I hadn't seen it before and the specs are definitely worth a read.

Essentially, as a project, these guys built a pretty simplistic programming language that ends up looking very similar to a Shakespearian play.

Like I said, you gotta read the specs to fully appreciate it.

Variables are declared in the Dramatis Personæ section. They enter scope not by virtue of functions but by Enter, Exit and Exeunt declarations.

Here's a small sample:

Outputting Input Reversedly.

Othello, a stacky man.
Lady Macbeth, who pushes him around till he pops.


                    Act I: The one and only.

                    Scene I: In the beginning, there was nothing.

[Enter Othello and Lady Macbeth]

Othello:
 You are nothing!

                    Scene II: Pushing to the very end.

Lady Macbeth:
 Open your mind! Remember yourself.

Othello:
 You are as hard as the sum of yourself and a stone wall. Am I as
 horrid as a flirt-gill?

Lady Macbeth:
 If not, let us return to scene II. Recall your imminent death!

Othello:
 You are as small as the difference between yourself and a hair

Anyway, pretty clever, funny stuff, that is, as long as you'd find this pretty clever and funny (and if you haven't been to http://xkcd.com, it's worth the trip).

posted on Monday, August 20, 2007 4:19:16 PM (Central Standard Time, UTC-06:00)   •  # •  Comments [0] • 
Kick it •  Add to del.icio.us •  View blog reactions; 
 Sunday, August 19, 2007

If you're running Vista, you might want to check into KB938979.

It's call the "Performance and Reliability Update for Vista". There's actually 2 different packs, one for 32bit and one for 64bit.

In my case, Vista Explorer was just crashing, almost constantly, when I was copying files around (I got into a house cleaning mode this morning and started shuffling files into a little better folder structures).

It's a 10mb download, so it's not utterly trivial, but it's not 300mb service pack either.

I just have to wonder what actually got changed when MS rolls out patches like this. Just once, wouldn't be interesting for MS to roll out a patch that included a DIFF report. You know, not ALL the code, per se, just what the old line was and what it was changed to, what was deleted and what was added.

Wouldn't THAT make for some interesting reading?

posted on Sunday, August 19, 2007 3:45:21 PM (Central Standard Time, UTC-06:00)   •  # •  Comments [2] • 
Kick it •  Add to del.icio.us •  View blog reactions; 

image

I just kind of stumbled on this while playing with Joel Faber's Flipped Disc technique. He and his brother do some amazing stuff in Apophysis.

I had no idea you can get two almost completely different fractal styles in a single image.  Definitely warrants more play.

posted on Sunday, August 19, 2007 10:13:54 AM (Central Standard Time, UTC-06:00)   •  # •  Comments [0] • 
Kick it •  Add to del.icio.us •  View blog reactions; 
 Thursday, August 16, 2007

The web as we know it is in its death throws.

Um, right.

I just read the Guest Opinion in the latest Visual Studio Magazine. It's by Rockford Lhotka, who I have a lot of respect for. But this piece was a little off.

He basically claims that "the web as we know it is finally coming to an end". Why, you may ask?

  • Is it the impending rollout of IPV6?
  • Maybe some new 3d "navigator" (as in the-chess-set-on-the-millenium-falcon 3d, not yet-another-2d-window-into-a-virtual-3d-space 3d)?
  • Or maybe there's a new "brain driven" interface I hadn't heard of?

No.

It's Silverlight. and Atlas.

Sigh.

According to Rockford, AJAX is the "last gasp of a dying technology". He argues that at some point, "either the browser transforms into a full blown programming platform or we find another answer", and that answer, apparently is SilverLight.

Now, don't get me wrong. SilverLight is pretty slick, as long as you don't try to find any examples of actual web apps written in it. You know, the kind that people would use as opposed to just play with for 5 seconds. There's tons of nice animated displays synched to music and pretty graphics of pages flipping, but where's the data driven samples, or the reporting grids, or the company dashboards, etc?

Not only that, but hasn't the web already got a "launch point to load something that is a programming platform". I thought it was called Flash? And flash has certainly not brought the end of the Web nigh. Hell, it's harder and harder to find sites that even bother with it anymore.

And SilverLight is from Microsoft, so you can bet that, even if they initially support a plethora of browsers and systems, eventually, it'll get whittled down to Windows Voyeur (or whatever they'll be calling the new version in 5 years).

Rockford makes a good point about technologies lasting upwards of around 10 years before being replaced by newer, better concepts. Things like COM, Win32, and CORBA. Things like ISA, the serial and parallel port, and ATA IDE. Things like hard drives, mice, qwerty keyboards, text files and relational DBMSs.... Oh wait.

I'd lay money that the next "big thing," the thing that "kills the web as we know it" and ushers in a new era similar to the internet age of the 90's, will not come from a big house like Microsoft, or IBM, or even Xerox. It'll come from some dedicated hacker like Marc Andreeson or Bram Cohen. It'll start off small. Hardly anyone will use it, kinda like Google back in, oh, 1999. And it'll probably have a goofy name, nothing as cleanly futuristic as "SilverLight".

Until then, I'd say the odds are long on HTML, Javascript, Ajax, etc, going poof.

posted on Thursday, August 16, 2007 10:14:23 PM (Central Standard Time, UTC-06:00)   •  # •  Comments [1] • 
Kick it •  Add to del.icio.us •  View blog reactions; 

The VS 2008 VB will support nullable types.

Simply put, a nullable type is a standard type, like, say, integer or string that can ALSO contain a null.

This can become very important in database work, because a null value in a field means that no value has been assigned to that field vs a common case where you might use 0 in a numeric field to indicate no value, or you might use a null string (ie a string with no length) in a string field.

Obviously, using 0 to indicate no value works much of the time, but, there often comes a point when you actually do need to use a 0 value for that field.  There's a number of other, more arcane reasons that using one of the values from the range of possible values of a type to indicate null is usually not a good idea.

Hence, nullable types. With a nullable type, I can have an integer variable that can be a 31bit positive or negative number, or 0, and STILL have yet another "state" of that variable that indicates it's null.

This will likely be incredibly handy for many many uses when working with database data.

But the syntax?

Dim a As Integer?

or

Dim a? As Integer

No, I'm not making that up.

What the hell? A question mark?

Why not just:

Dim a As Nullable Integer

I find this to be an unbelievably hypocritical decision given the almost overwhelming philosophical rants delivered by Microsoft about not using the traditional VB type specifier characters in .NET anymore (you know, $ for strings, % for integers, those bad boys). Heck, check page 42 of "Framework Design Guidelines" by Krzysztof Cwalina and Brad Abrams of Microsoft:

DO NOT use Hungarian notation (their bold, not mine)

Now, to be fair, the authors in this particular instance are discussing publicly available interfaces, but I've seen the same directive applied to internal coding as well. So, we're not suppose to use hungarian, and we're not supposed to use type characters, so we're left to simply scan the code to information about how a variable is used or what it likely contains. Jeez. How convenient.

posted on Thursday, August 16, 2007 4:33:15 PM (Central Standard Time, UTC-06:00)   •  # •  Comments [3] • 
Kick it •  Add to del.icio.us •  View blog reactions; 
 Wednesday, August 15, 2007

Not sure if it's working entirely yet, but it appears to at least be serving pages.

Let me know if you notice anything amiss.

posted on Wednesday, August 15, 2007 10:23:38 PM (Central Standard Time, UTC-06:00)   •  # •  Comments [3] • 
Kick it •  Add to del.icio.us •  View blog reactions; 
 Sunday, August 12, 2007

I haven't been coding too much in ASP.NET, and it seems like every time I sit down to do something in it, things have gone fubar in some random, unexplained way.

The latest example. I went to start a web app that I'd debugged plenty of times before and ended up with

Unable to start debugging on the web server. An authentication error occurred while communicating with the Server

Ok, start googling. 

I tried everything I could find to no avail.

Then I happened on Mike Volodarsky's Server Side and this article.

I'd run smack into a full-on bug in VS2005, and not a small one. Mike's post details why all of the alternatives have their drawbacks and then he presents his "Debug Assistant" that works around the bug and allows you to start in F5 debug mode anyway.

And even better, he updated the post with details about KB article 937523 that describes a hotfix to resolve this problem.

Unfortunately, the hotfix is one of those that MS insists you call them to obtain, but Mike makes the link available. It's here.

Anyway, downloaded the hotfix, applied it, and I didn't even have to reboot. Debugging works great (ie like it should have in the first place) now.

A big thanks to Mike, for posting about this bit of VS nastiness.

Now, it's ~3hours later. What was it I sat down to take a look at in my ASP app again?

posted on Sunday, August 12, 2007 9:10:53 PM (Central Standard Time, UTC-06:00)   •  # •  Comments [0] • 
Kick it •  Add to del.icio.us •  View blog reactions;