Shell Schmell

I’m reading The Pragmatic Programmer, supposedly one of the Bibles for modern programmers. It came highly recommended by one of my favorite blogs, Coding Horror. (Well, it used to be highly recommended… I’d swear there were only two books on his recommended reading list before.) Anyway, it’s a good book so far. It’s easy to read and contains lots of good tips, although a lot of the advice is common sense practices you pick up through experience anyway. But it’s cool to have it all in one book. Great for someone starting out, I would think.

I’m finding a few things I don’t agree with, though.

For example, in the “Shell Games” section, the authors assert that you must be proficient in using the command shell to be a pragmatic programmer. In my opinion, this betrays a Unix environment bias. They list a few contrived situations where they tell you the shell is faster and easier. One of them is: Find “which Java files have not been changed in the last week.”

I very rarely need to know something like that, but it just so happens I had to do almost that exact same task recently when I needed to merge some changes from a branched project. Did I turn to the Windows command shell to find the files to merge? Hell, no. I opened up SourceSafe and did a recursive history. I certainly wouldn’t go to Windows Find Files, which the authors suggest is the only other alternative to the shell.

So no, I don’t see how the command shell is faster or easier for one-off situations like that. I don’t know about anyone else, but I started out programming on the Amiga where everything was shell-based, so frankly it’s kind of a pleasure to be able to use a GUI that doesn’t require me to memorize arcane shell commands. Sure it probably takes a few seconds longer than it would for a super-fast-typing shell user, but I’m old enough not to be too concerned about shaving a few seconds off of my productivity.

That being said, command shell knowledge is essential for scripting. Recently I’ve been writing a bunch of scripts at work to automate things that I would die of boredom from if I had to do them by hand. In that case I agree completely with Pragmatic Programmer: Scripting rules. Repetition blows.

I just don’t think its necessary to memorize shell commands anymore.

What Does Unofficial Mean?

Just out of curiousity, when one pastes a verbatim copy of a campaign press release into an unofficial campaign blog without any attribution, is it still appropriate to call it an “unofficial” blog? And when that same unofficial blog feed appears right on the official campaign web site without any disclaimers, with “Paid for by Jim Gilmore for Senate” at the bottom of the page, is it still appropriate to call it an “unofficial” blog? Seems like somebody should clarify that.

Ed Sells Out.. er.. Moves On

Captain’s Quarters: The Road Goes Ever On. How disappointing that the relatively moderate, thoughtful, and literate Captain Ed is being absorbed by the Michelle Malkin-branded corporate noise machine. (I can only assume this is a monetary decision… Malkin must be paying him more than he makes from his own blog.)

It’s not that I don’t think Ed deserves to do well — it’s that I don’t think Malkin deserves to attract good writers.

P.S. I looked at Hot Air’s feed to see if it was any less childish than it was the last time I looked at it. Unfortunately it’s impossible to tell since the feed only includes about one sentence per item (sometimes not even that). Maybe that’s the attention span they expect of their readership.

Sharing Files Between ASP.NET Projects

These rambling thoughts document my search for a way to share files between Visual Studio web projects.

I’ve got a web solution that really should be three entirely separate web solutions, but many of the pages are exactly the same between them. I could copy the shared files to the three projects, but for obvious reasons that’s not a desirable solution… I just want to maintain one copy of the shared files. How the heck do you do that in Visual Studio?

Turning to Google, I see there is this nifty feature for adding existing items as links. Cool! That will solve my problem nicely!

Um, except it doesn’t work for web projects:

“Visual Basic Web projects, Visual C# Web projects, and other similar projects do not support links to items.”

Back to the drawing board. Surely I’m not the first one to ever think of sharing a common page among multiple web projects?

Some Google hits referred to sharing the files in SourceSafe. This is a personal choice, but I don’t like doing that because it feels dirty. It still looks like multiple files in multiple directories. Plus, I worked on a project once where tons of files were shared like that and SourceSafe was really slow propagating changes. If possible, I just want one file in one directory, both in source control and on my hard drive.

Finally I found an MSDN KB article describing how to share an ASP.NET control between two or more projects. Basically Microsoft is saying that you should put the shared controls — I assume it would work for pages, too – into multiple virtual sub-directories all pointing to the same physical location. I’m not wild about this solution because in my situation I prefer not to rely on IIS tricks, but it’s definitely the best option so far.

Of course, there is always the option of building the projects outside of Visual Studio with a tool like NAnt, where you can build projects from any files scattered all over creation. If it were just me I might consider that route but, again, in my situation it’s generally better to keep things simple. (That is my coy way of saying that nobody else would know what the heck NAnt is or how to build anything with it.) Even worse, I’d still have to make copies of the shared files to do any debugging inside Visual Studio.

Hrm, that gives me an idea. Maybe a combination of those last two methods would work:  Use the virtual directories for local debugging, but create a NAnt project to build the deployable production site. It’s so crazy it just might work!

P.S. It was too crazy and didn’t work. :) Actually I can’t say that for sure because I gave up and left the three sub-apps in a single web solution. The difficulty in separating them outweighed the advantage of separating them.


Ralph joins the race! Down with the corporations! I like this story mainly because it challenges the idea that God handed down a two-party system to America carved on stone tablets, and we citizens should learn to not just accept it but embrace it unquestioningly. We watched Meet the Press today and Russert’s obviously biased questions were pretty annoying. I paraphrase slightly: “Mr. Nader, aren’t you the least bit ashamed that you might cause the first black president in America to lose?? Will you be able to live with that??”

Time for a Double-Take

Thanks to the alertness of Daily Whackjob, I just learned that Ben Tribbet spoke in Manasass on a panel about ethical blogging. I think we all remember where we were when we first read Ben’s finest example of ethical blogging: “GILL’S LOGO IS AN ISLAMIC SYMBOL” and his thoughtful analysis, “WOW!!!!!!” (That fifth exclamation point really sold me on the story… I wouldn’t have believed him if he’d only used, say, three or four exclamation points.)

(Charles from Two Conservatives was also on the panel, and wrote a bit about the experience.)

Fidel Who?

I’m a little embarrassed to admit that I don’t know why we’re supposed to hate Cuba and Fidel Castro so much. Whatever caused this lingering animosity happened way before I was born, and all that’s left now is a vague sense that today we’re supposed to celebrate the news of the official end to Castro’s regime. I realize they’re godless Communists and all, but I was born too late to really appreciate the Cold War thing. My formative years were the 1980s when Russia was already declining, and the biggest Communist threat we faced was Dolph Lundgren in Rocky IV. I guess I need to read some history to get a better sense of this.

My FTP Broke

I installed Vista Service Pack 1 this weekend. Now, I can’t seem to FTP into my web site with FileZilla anymore. I think it’s just a coincidence and that my web host’s FTP server is down for completely unrelated reasons, but they aren’t usually down this long and I’m starting to wonder…

WPF: Finicky About JPEGs

Gah! I’ve found that WPF’s BitmapImage is quite finicky about the kind of JPEG files it will load.

For example: I have a huge directory of genealogy pictures originally scanned in high-resolution TIFF format. I also have a mirror of the pictures saved in smaller-sized JPEG format, which was created with a utility I wrote utilizing the Independent JPEG Group’s library. Sadly, WPF wouldn’t load any of those JPEGs:

System.IO.FileFormatException: The image decoder cannot decode the image. The image might be corrupted. —> System.Runtime.InteropServices.COMException (0x88982F60): Exception from HRESULT: 0x88982F60

Naturally they worked just fine in the Vista Explorer and, well, basically everywhere except my new WPF test app.

At first I thought it was because my JPEGs were saved as progressive scan JPEGs, but that wasn’t it.

I turned to Google, and found exactly one hit related to my problem:  This Microsoft forum post. It turns out the problem is in the Windows Imaging Component (WIC), which I think is new in Vista.  I should say it’s actually a problem that WIC thinks is in my JPEGs. I got WIC Explorer from the Windows Imaging Component Code Samples and Tools to investigate further. WIC Explorer also threw an error, but it was still able to load and display my JPEG image despite the error.

That led me to try catching the offending FileFormatException and proceed anyway, but the BitmapImage was not complete and could not be used.

So I looked at that forum post again and discovered the original poster had solved his problem with the BitmapCreateOptions.IgnoreColorProfile flag. I added that and voila, problem solved.

BitmapImage bitmap = new BitmapImage();


bitmap.StreamSource = stream;

bitmap.CacheOption = BitmapCacheOption.OnLoad;

// IgnoreColorProfile solves FileFormatExceptions with JPEGs created by IJG.

bitmap.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;

bitmap.DecodePixelWidth = 600;


Turned Off Daily Links

I turned off the daily link posts. It’s just too much noise, and it was mostly just an experiment to see if my blog platform was compatible.