My dragon #1

You can find a short film of my 3d dragon mentioned earlier in the “Things that Catch My Eye” category.  It takes a bit to download (the mov is 7mb) and the lighting isn’t good.  So, I’ll probably redo this later.  But this was a first attempt. 

The other side of this is that I the viewer code so that it could take the file name as a parameter in the link.  Now, that will seem like nothing to many of you.  It seems like nothing to me now too, except that 6 months ago I wanted to do the same thing and decided that it was impossibly out of my skill set at the moment.  So I made a seperate .htm file for each movie I wanted to play.  Even today I did that for a post on my wife’s site.  Then as I went to put this up, it just occured to that I was still doing stuff the hard way for no reason.  And that just wouldn’t do in The Code Cave. 😉

It’s kinda neat in that regard.  Anyway, here’s the new link:

http://www.thecodecave.com/playmov.php?mov=MyDragon.MOV

It’s just a neat world…

I’ve nothing very profound to say right now other than that it is really neat that I can sit here at my desk working on documentation (OK and blogging) while a little window shows a NASA control room live as the Mars Orbitor is inserted into the atmosphere of a nearby planet…

http://www.nasa.gov/mission_pages/MRO/main/index.html 

Mars-Bound Spacecraft Readies Itself for Orbit Insertion Today
 

After a seven-month journey, NASA’s Mars Reconnaissance Orbiter is going through maneuvers to place itself into orbit around Mars today. Coverage of the complex orbit insertion maneuver starts at 3:30 p.m. on NASA TV and the Web . Spacecraft milestones for the event can be followed on the right. The spacecraft is the most technologically advanced ever sent to Mars.
Expected time of events (in Eastern)

4:07 p.m.:  Turn to burn attitude 
4:24 p.m.:  Orbit insertion burn begins 
4:46 p.m.:  Behind Mars / expected loss of signal 
4:51 p.m.:  Orbit insertion burn ends 
5:16 p.m.:  Re-emerges from behind Mars 
5:16 p.m.:  Re-acquisition of signal 
5:30 p.m.: Health and status report 

The live link…
http://www.nasa.gov/multimedia/nasatv/index.html

 I find that kind of nifty…

Bill Amend “channeling” Bill Watterson: The FoxTrot/Calvin and Hobbes Conspiracy

or Speaking of Bill Amend

OK… While I don’t much believe in “channeling” and technically speaking Bill Watterson isn’t dead even if Chagrin Falls is fairly close to it… this is really starting to freak me out!

 I asked Bill about this back in last November and he denies (oops, typed Denise there) any conspiracy on the matter but something is going on…

I first noticed this back on November 28th:

Bill posted: Click images for a better view….

Jason plays guess the number

Meanwhile 11 years earlier – to the day – the other Bill had posted:

 Calvin plays guess the number

But this week I read on Sunday:

 Calvin needs Money

 

And  11 years and a day later Bill puts this up?

Jason Needs Money

Conspiracy? 

A desperate cartoonist’s cry for help? 

Subject matter for the next episode of Sci Fi’s “In Search of…”?

You decide….

3d Dragon illusion

I sent these links to Bill Amend of FoxTrot fame (who is a really nice guy btw):

http://www.grand-illusions.com/dragon.htm

He’s made one and I’ve made one too.  I’ll post some video sometime soon to show you how mine works.

Here’s the example from the main site:

http://www.grand-illusions.com/videos/dragon%20illusion.wmv

 

And here’s what Bill had to say… 

>Works great.

>My engineer brother-in-law had the same idea as you and says he’s going to
>print one out on his office’s giant color plotter and make a huge one.

>Bill Amend

>> From: Brian Layman
>> Date: Wed, 11 Jan 2006 12:36:52 -0500
>> To: Bill Amend

>> Subject: RE: HEY!!!!!
>>
>> Hey – how’d your cut and fold 3-d dragon turn out?
>>
>> Mine turned out fairly well, and the illusion works well too.  I had to
>> put an extra layer of paper behind some spots to prevent light from
>> shining through.  It worked better after that, but 4″ tall is too little
>> to get noticed. 
>>
>> I’m gonna redo it on an A3 page (11.7×16.5″) and see how it turns out…
>> A 1ft tall dragon should be MUCH more impressive…
>>
>> Cheers!

Books I’ve read in 2005 but have not yet reviewed

I didn’t plan on doing anything like this.  So I didn’t track everything  I read.  Luckily I was on a series binge in 2005.  So I could look up the most of them easily.  I’ll try to get reviews of each of these on here later. 

Here’s what I remember:

The Burglar in the Rye by Block, Lawrence.
The Burglar Who Studied Spinoza by Block, Lawrence.
The Burglar Who Traded Ted Williams by Block, Lawrence.
The Burglar Who Painted Like Mondrian by Block, Lawrence.
Burglars Can’t Be Choosers by Block, Lawrence.
The Burglar in the Closet by Block, Lawrence.
The Burglar Who Liked to Quote Kipling by Block, Lawrence.
The Burglar Who Thought He Was Bogart by Block, Lawrence.
Marker Cook, Robin.
Seizure by Cook, Robin.
Shock by Cook, Robin.
Saga of Seven Suns Book 1: Horizon Storms by Anderson, Kevin J.
Saga of Seven Suns Book 2: A Forest of Stars by Anderson, Kevin J.
Saga of Seven Suns Book 3: Hidden Empire by Anderson, Kevin J.
The Dark Tower I: The Gunslinger by King, Stephen.
The Dark Tower II: The Drawing of the Three by King, Stephen.
The Dark Tower III: The Waste Lands by King, Stephen.
The Dark Tower IV: Wizard and Glass by King, Stephen.
The Dark Tower V: Wolves of the Calla (title originally announced as The Crawling Shadow) by King, Stephen.
The Dark Tower VI: Song of Susannah by King, Stephen.
The Dark Tower VII: The Dark Tower by King, Stephen.
Anne of Green Gables by Montgomery, L. M.
Anne of Avonlea by Montgomery, L. M.
Anne of the Island by Montgomery, L. M.
Anne’s House of Dreams by Montgomery, L. M.
Vulcan’s Soul. Book I, Exodus Star Trek; by Sherman, Josepha.; Shwartz, Susan
Captains Corageous by Rudyard Kipling
Dagon’s Kin – Todd MaCaffery
Faith of the Fallen by Terry Goodkind
Left Behind: A Novel of the Earth’s Last Days by Tim F. LaHaye,Jerry B. Jenkins
Tribulation Force: The Continuing Drama of Those Left Behind by Tim F. LaHaye,Jerry B. Jenkins
Nicolae: The Rise of Antichrist by Tim F. LaHaye,Jerry B. Jenkins
Soul Harvest: The World Takes Sides by Tim F. LaHaye,Jerry B. Jenkins
Apollyon: The Destroyer Is Unleashed by Tim F. LaHaye,Jerry B. Jenkins
Assassins: Assignment: Jerusalem, Target: Antichrist by Tim F. LaHaye,Jerry B. Jenkins
The Indwelling: The Beast Takes Possession by Tim F. LaHaye,Jerry B. Jenkins
The Mark: The Beast Rules the World by Tim F. LaHaye,Jerry B. Jenkins
Desecration: Antichrist Takes the Throne by Tim F. LaHaye,Jerry B. Jenkins
The Remnant: On the Brink of Armageddon by Tim F. LaHaye,Jerry B. Jenkins
Armageddon The Cosmic Battle of the Ages by Tim F. LaHaye,Jerry B. Jenkins
Glorious Appearing: The End of Days by Tim F. LaHaye,Jerry B. Jenkins

Books I’ve read in 2006 but haven’t reviewed yet

Read in 2006
Saga of Seven Suns Book 4: Scattered Suns by Anderson, Kevin J.
The Da Vinci Code by Dan Brown
The Time Machine by Wells, H. G.
Califia’s Daughters by Richards, Leigh
Those Who Walk in Darkness by Ridley, John.
S is for Silence by Sue Grafton – Not yet completed

Angels and Demons by Dan Brown – Not yet completed

WordPress 2.0 themes are now available.

The first of the WordPress 2.0 themes are up! I’m trying out the new BinaryBlue theme.  But it has a BIG surprise waiting for non-localized blogs that try it.  It will crash your blog and your admin pages.

It is a localized theme. That means that you HAVE to have a special setting in your WP-Config .

You know that section in wp-config.php that most of us have ignored? the one that says:
[PHP]
// Change this to localize WordPress.  A corresponding MO file for the
// chosen language must be installed to wp-includes/languages.
// For example, install de.mo to wp-includes/languages and set WPLANG to ‘de’
// to enable German language support.
define (‘WPLANG’, ”);

[/PHP]
Well, if you don’t have a value in there when you choose the new Binary blue theme, you only get this :

Cannot instantiate non-existent class: cachedfilereader […]

on every page of what you had previously thought of as your blog…

Luckily, the fix is simple… change the define line in the config file to this:
[PHP]

define (‘WPLANG’, ‘en_US’);

[/PHP]

and your site will work again (after it does some initial chugging to apply the localization – give it half a  minute…)

Beyond that, the theme is wonderfully well organized.  The options page is a treat and the developer, and you can see from his comments , that he is helpful and seems to know his stuff.  I’d like my WP3.0 theme to be as well organized.  This theme, though still 1.0, sets the standard that many should follow.

I do wish there was a readme file that explained that step or that localization was turned off by default.

I also tried turning on the ie7 “fixes” feature that the author gets tripple Kudos for turning into a configurable option rather than just building it in, and it caused some of my posts to wrap the sidebars down to the end of the page.  So that option is off again.

I’ll try do a full review of it over the weekend.

Hey, Kevin should create a blog entry for theme reviews that we can all point our tracebacks to…   Good idea?

WordPress 2.0 Theme competion SLAMMED with entries

Justin innocently thought he would have a little competion to allow bloggers to compete with their WordPress 2.0 themes

Now in the last day his email box was flooded with entries.  A total of 188 themes were submitted!  Now the poor guy is left with no, if he ever had one, life for the next 6 months as he reviews these themes!

Ya gotta giggle: http://kcyap.com/competition/?p=24

Actually it makes me want to start a WordPress 3.0 them competition site right now. Then we’ll have a chance at having something organized by the time WordPress 3 is released in a few years!

Hiding an EXE or Virus inside a TXT file or JPG.

AKA: Alternate Data Streams – An introduction…

One of the members of a technical forum to which I belong had a virus detected in a dll that he could not find anywhere on his computer.  In the end, it was discovered that the file was embedded as Alternate Data Stream (ADS) attached to his System32 directory.  The full path to the file was something simlar to c:\windows\system32:dhht.dll.

I was not familiar with using streams in this manner; so I looked it up.  In short, any file or directory on an NTFS drive can any number of files piggy-backed onto it without affecting its reported file size.  These files remain intact through normal file copying and renaming actions as long as the file remains on an NTFS drive (or compatible archiver).

I’d never come across this before and thought I would share.
Summary/Demo….    (adjust paths as necessary)

  1. Create a directory off the root called test
    From the command prompt in your test directory type:
       [DOS]Echo a>test.txt[/DOS]
       That will create a nice 3 byte text file.
  2. Now type:
       [DOS]type c:\Windows\system32\notepad.exe>test.txt:notepad.exe[/DOS]
  3. Get another directory listing and notice that the size of test.txt remains 3 bytes though an additional ~70kb has been added to it.  The time has changed but that could be set back.
  4. Now, from the command prompt in your test directory, execute the hidden stream:
       [DOS]start \test\test.txt:Notepad.exe[/DOS]
       (You must use include the path to test.txt)

You are now running an exe that was hidden in 3 byte text file!
As far as Windows is concerned, that file takes up only enough space for three characters.  Yet it’s got this hidden back end on it.  That txt file could be taking up any amount of space.  Perhaps it is storing 5 gigs of pictures in it.  Who knows?
Windows supplies no tools to display this.  The zip file referenced in this article, includes an exe that does. 
The Task Manager shows the running proces in different ways depending upon your Windows version.  In SP2, the executable is listed as test.txt:Notepad.exe. However, in earlier versions of windows, only the host file is listed.  So, if you’d embeded Notepad.exe in calc.exe, calc.exe would be in the task list even though you’d be running Notepad.  Nifty huh?
Of course, you’ll have to find a transport/archiver that supports these streams, if you want to distribute them.  Outlook and WinZip do not seem to do so.
Apparently ADS are there for backwards compatibility with a Macintosh file system (HFS), but I’m not sure why we’d want/need that…  Some Windows apps use it for other things.  For example when you download an exe file through IE, MS helpfully edits the file for you and attaches an ADS that stores the Zone under which the file was downloaded.  As a result you are NEVER getting the same file that was on the internet.  Developers should be aware of this when they deploy software via a website. 

In short, while Alternative Data Streams do add some flexibility to the operating system, the incomplete implementation of the feature makes ADS more of an avenue for abuse than a feature.

Common mistake: Don’t rely on exception handling.

Steve Trefethen, Senior R&D Engineer Delphi/C#Builder for the Borland Software Corporation had an EXCELLENT post on his BLog. It emphasizes the cost of a mistake that I always see in example code on the web and in WordPress plug-ins as far as that goes.

Here’s the law that is always broken: “If you know an error is likely to occur in your code, check for that condition first.  DO NOT rely on exception handling detect it.”

This applies whether you are waiting for file access to fail  or an SQL insert statement to come back with an error.  Check to see if the condtion (or record) exists and then have your program handle it correctly.

Generic exception handling should only be used when you cannot predict or test for the condition. 

Newer versions (5+) of MySQL have a clause for inserts called ON DUPLICATE KEY.  Many MySQL programmers are starting to rely on it, but it too has a cost.  Even a single call that runs two insert queries with exception handling thrown in there is almost always going to be slower than checking for the record first and chosing what to do based upon the result of the read only select.  The ONLY reason I see for that call to exist is if it locks the database as it is running and therefore you KNOW the has not changed after your Select query is run. So it does have its application.

 Maybe this article will help others come around: 

BDS 2006, slow compile times and the cost of exceptions

While browsing the newsgroups I ran into a thread where a user had commented that BDS 2006 compiled his application incredibly slowly. A while ago I’d had a discussion with Mark Edington our resident performance maverick about this issue and it turns out that it’s a good reminder of the cost of raising an exception or in this case lots of them.

Since Mark debugged this issue he kindly provided me with a short write up of the specifc problem, it’s solution and a workaround.

Mark write:
In BDS 2006 in Delphi a performance issue arises when compiling projects in the IDE when the source files in the project are marked as read-only on disk. The more files in the project the more significant the delay. The problem only affects projects that have read-only source files. The root of the problem, is a callback procedure which is called by the compiler when compiling in the IDE. The callback is designed to open the file and return an IStream interface:

 


function OpenOSFile(const Name: string): IStream;
begin
  { try opening existing file so that read/write operations are
    possible }
  Result := nil;
  if FileExists(Name) then
  begin
    try
      Result := TOSFileStream.Create(Name, fmOpenReadWrite or 
        fmShareDenyNone);
    except
      on EFOpenError do
        Result := TOSFileStream.Create(Name, fmOpenRead or 
          fmShareDenyWrite);
    end;
  end;
end;

Notice the try/except block, since there is no parameter to the function that specifies what access rights to use when opening the file, the procedure tries to be accommodating and provide read/write access first and if that fails it resorts to to opening the file as read-only. Unfortunately, as written, it introduces a serious performance penalty for anything other than small projects. Interestingly enough, the performance issue isn’t from the fact that it takes 2 attempts to get a read-only file opened, it is actually caused by the exception that is raised when the first (read/write) TOSFileStream.Create call fails.

In the test case that was submitted for diagnosing this problem the RaiseException procedure (which is a Windows API call), was accounting for nearly 40% of the total compile time. Under a profiler it took nearly 50 seconds to execute that procedure about 1100 times. That works out to around 45 milliseconds per call which may not sound like that much, but when executed 1100+ times it adds up.

The solution was very straightforward: Rewrite the routine and remove the exception based fallback algorithm. The new version looks like this:


function OpenOSFile(const Name: string): IStream;
var
  Code: Integer;
begin
  Result := nil;
  Code := GetFileAttributes(PChar(Name));
  if (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code = 0) then
  begin
    if (FILE_ATTRIBUTE_READONLY and Code = 0) then
      Result := TOSFileStream.Create(Name, fmOpenReadWrite or
fmShareDenyNone)
    else
      Result := TOSFileStream.Create(Name, fmOpenRead or
fmShareDenyWrite);
  end;
end;

This version first checks to make sure the file is not marked as read-only before attempting to open it as read/write. The FileExists call that was replaced in the original version of the procedure is actually implemented using GetFileAttributes anyway, so there was no extra overhead introduced to make the check.

The moral of the story is avoid writing code that raises exceptions as part of the normal course of program execution. Exceptions are horrifically expensive to raise and handle and should be reserved for the truly “exceptional” events. If you have a medium to large Delphi project that has files marked as read-only the workaround for this issue is to mark them as read/write until this fix is made publicly available.

posted on Monday, February 27, 2006 3:51 PM