Recently in Future Reference Category

Can't Pull the Rug Out From Under Yourself

I found another big gotcha in .NET today. When iterating over a Hashtable, you might want to change something within that Hashtable, like say change or clear out a value. Ain't gonna happen, buddy. Nice big runtime exception: Collection was modified; enumeration operation may not execute.

I got it the first time and I slapped my forehead—figuratively, of course, as I'm not in the habit of self-flagellation. So I did what I always do. *sigh* I got clever. I thought that I could obviate the problem by enumerating through the Hashtable.Keys collection and make my changes that-a-way.

Again, no dice. I'm not entirely sure how changing the value of a Hashtable key while looping over a collection of keys is affecting the underlying Hashtable. But I think it has something to do with the CLR iterating over the Keys collection by reference rather than by value.

The answer, after some Googling, is to split the operation into two phases: storing the keys to be changed in another collection and then looping over that second store to actually modify the values or do what-have-you. It's decidedly not as elegant as say creating an isolating enumeration class, but I've got work to do.

Does Type Implement an Interface?

I've wasted far too much time on this issue, so I'll make an entry for future frustrated Google searchers. You're welcome.

If you need to see if a particular Type object implements a particular interface, it's clear that the method IsAssignableFrom is the proper choice. But the damn thing wouldn't work. is certainly what I was looking for. Then I found Scott Hanselman's entry on the subject and it became obvious that I was reversing the members.

Assembly library = Assembly.LoadFrom(pathToLibrary);
Type[] allTypes = library.GetTypes();
foreach (Type type in allTypes)
{
if (typeof(IInterfaceToImplement).IsAssignableFrom(type))
{
doYourThing(type);
}
}

Previously, I was doing if (type.IsAssignableFrom(typeof(IInterfaceToImplement)) and it just wasn't doing it's thing.

The Command Prompt

This is going to seem like yesterday's news to my fellow Mac OS X and Unix readers, but I just got something working today that is pretty impressive in the Windows command prompt.

I love this Windows version of "grep"—I install it on every server and desktop I interact with. It's super fast, very similar to the Unix version, and I've never had a single problem with it.

I was trying to use its output as input for another command. This is called "command redirection" in the Windows world and "piping" everywhere else. Sadly, the documentation on the Web about this feature of Windows is sparse. I can see why: Windows executes both commands simultaneously and if the receiving command wasn't designed to wait for standard input then it'll just error out. Like the "del" command, for example. Non-Windows users are welcome to snigger quietly now.

Then I found this article. This isn't piping per se, but the idea is the same. Take the output of one command and use it in another. Once I had that, it was a simple for /f "tokens=*" %a in ('grep -l stuffIwantDeleted *.FOO') do del %a. Worked like a dream!

What's New in 2

List of .NET 2.0 and C# 2.0 New Features: nice to have it all in one handy place.

Remastering on the Cheap


Using iTunes as an Audio Processor: I've got a lot of records and tapes that I want to convert to a digital format but it's such a chore to edit out noise, cracks, and hiss from the waveform. By "such a chore" I mean that I would rather eat spackle. I did it when I recorded all of Sandi's childhood albums onto CD, but I did that for love. Ease of listening and portability aren't love, let me tell you.


Lesser of Two Evils 2004


For my future reference, C-SPAN's 2004 presidential coverage sans spin.


Favicons


Favicon from Picture: for my future reference. {via}


Big Ass Scanner


For my future reference, the Mustek ScanExpress A3 USB Scanner can scan up to 11.7" x 22". For when you just need to scan in something really big.


Copyright Is Alright By Me

Photoshop Tips and Tutorials

Taking a Good Picture


For my future reference (perhaps more immediate than that implies), digital photography composition tips or "How to Take Better Pictures."

[UPDATE (6/24/04): More good references: Photography Composition Article Library, Photographing on Federal Lands, and The Photographer's Right (PDF {via}).]

[UPDATE (7/19/04): Here's a very promising blog that seeks to help digital photographers move past the automatic settings.]


Maximum RegEx


For my future reference, here's a good resource on regular expressions and ASP.NET, including a useful library of prebuilts. {via}

[UPDATE (6/15/04): The Tao of Regular Expressions: another interesting resource.]


String.Format

For my future reference, here's an excellent explanation of the String.Format possibilities in C#.

GarageBand Updated


For my future reference (when I ever get a chance to use GarageBand), the new update has an undocumented feature that allows you to use instruments available on the net in an open format.


Presenting Better


Jeffrey Veen has a great entry about making better presentations with a bunch of great comments left by visitors. I would second his suggestions and add that people should read Weissman's Presenting to Win as well. I especially like his suggestion about using PowerPoint unconventionally. People definitely would notice that.


Geetard


For my future reference, learn to play guitar online. I've got an interesting story to relate about my guitar lessons thus far, but it'll have to wait for an update right now.


Photo Tips


For future reference: photo tips.


Multiple IEs on Windows


For future reference: setting up multiple Internet Explorers on one Windows box. This is the reason why I never installed IE6 on my boxes and I'm glad to see that it's no longer valid.


NUnit Templates


For my future reference: NUnit templates for VisualStudio .NET makes adding NUnit classes a breeze. Will definitely need this later.


GooseQuill


For my future reference, GooseQuill and GooseQuill WriterWare. These are fascinating ideas, but I'm not so sure about their implementations. I wish they'd put up some screenshots to give me an idea of how this is such a sight better than a conventional word processor.


About this Archive

This page is an archive of recent entries in the Future Reference category.

Feedback is the previous category.

Getting Things Done is the next category.

Find recent content on the main index or look in the archives to find all content.

Feedback to

Monthly Archives