Windows Live Writer – Test

This is a test of using Windows Live Writer to post to the blog.  At first glance, I am impressed.  The interface is clean (but, once again, seems to have been written with some custom set of UI widgets that Microsoft hasn’t made available to the rest of us in standard Windows Forms :-( ).

“Save as Draft” didn’t work as expected…I had hoped that it would literally save the draft in WordPress, just as if I’d clicked “Save as Draft” while editing in the normal web-based WordPress editor, but it doesn’t appear to have done so.  There is a “Post Draft to Weblog” option in the Publish menu which might do what I expected “Safe as Draft” to do, but there must be a configuration error, because I’m getting a network error when I try it.

On the plus side, inserting a picture is much easier with this tool than with the standard WordPress editor:

 (Update: When I tried to actually post this, I kept getting a network error until I removed the image I had added right here.  So my WordPress installation doesn’t like whatever Live Writer is doing to send the image up to the server.  Will have to figure that out…)

The default editing view, Web Layout, is excellent.  WLW inspected my blog automatically when I first set it up to find what the background of the site looks like, and shows that as the background while I type, so the results are much more WYSIWYG.  (It got the formatting for that link correct, too).  “Normal” view seems to be included just for completeness (though I suppose some people might like it).  “HTML” view might sometimes come in handy, but what’s really nice is “Web Preview” view, which shows what the post will look like integrated with the rest of the content of the site’s front page.

So far, it looks like WLW is an excellent example of the kind of rich-client application that is much harder or impossible to do quite as well in HTML, even with AJAX.  I don’t see anything in this UI that would be completely impossible with AJAX, but the application’s is just large enough that developing it in JavaScript could quickly turn nightmarish.

Transparent PuTTY Question

Got this question today:

I just downloaded your transparent putty program. It is great and it is just what I was looking for. I have a tranparent version of “aterm”, but was experiencing refresh issues with it. Anyway my reason for writing to you is that whenever I run the transparent putty program with “Desktop” selected in the Background option and Opacity set to 0, my putty cursor disappears. I think that the cursor transparency also depends on the opacity value you set. Would you know of a way that I might be missing to make the cursor independent of the opacity value? Thanks

His analysis is correct: the cursor transparency uses the opacity. That was a consequence of the way PuTTY draws the cursor. I never really experienced that as a problem b/c I always use an opacity of about 50 or 75. I am mostly posting this as a way to remind myself to try check out whether this will be easy to fix, the next time I’m able to work on my PuTTY transparency patch. (Which probably will be at least a few months still…being employee #2 at a new company and, more importantly, having a 3-month-old son, tends to eat up all of one’s time).

XP Firewall Script

My friend Matt come up with this little CMD script for when you need to open a whole bunch of ports in the Windows XP Firewall at one time. Might be useful.

FOR /L %I IN (7001,1,7201) DO netsh firewall add portopening TCP %I “FTP_Passive_Data_”%I

Now, whether actually running 200 passive FTP connections between two computers at the same time makes any sense is an open question…if you could theoretically fill the bandwidth with just 1 transfer, then 200 just adds TCP/IP and context switching overhead. If FTP pauses between files while it sends commands on its command port, then maybe having at least two or three going makes sense. But 200? Matt — any input on the performance you saw?

DataTable.Load & ReadOnly Columns

Whew. I spent several hours over the past couple of days trying to find a nasty bug in some ADO.Net code. Updates would fail, and I discovered the problem was that, before I ever got to the point of trying to save the current row, it had already somehow gotten an error in it. The RowError had this text:

ReadOnly Data is Modified

If you’re reading this sometime shortly after 2006-06-30, try that phrase in Google, with quotes. Nadda. Apparently, no one had ever encountered that particular error and lived to tell about it.

Read on for more.
Continue reading

Scoop: Conversation in a Media Conglomerate’s Board Room

Voice1: The promise of cable TV is that we can air a number of different niche channels, thus better targetting individual consumers and providing a better value for our advertisers. And after all, that is our primary goal as an advertising service provider. That was the vision of the founders of this company, and we must stay true to it.

Voice2: You’re absolutely correct. Now, on to new business. Let’s look at this week’s numbers.

(A pause)

Voice3: As you can see, for the 456th week in a row, the Bland Miscellaneous Network has better numbers than any other. The question is, how can we make every other network exactly like BMN.

Voice1: Um…

Voice2: You’re speaking out of turn. Please let Wilson continue.

Voice3 (Wilson): To continue: the formula at BMN is to recycle old shows that got high ratings. Original content is too expensive, so we need to go find stuff that was popular with the kiddies in the 80s. They’re in their 20s and 30s now, and they’re not giving us enough of their money. So what I want each of you to do is to go out and find three unoriginal shows that we can start showing on our other niche networks. The criteira: nostolgic and cheap. It doesn’t actually have to fit the theme of the network…when they see the show people will be too surprised to notice.

Voice2: But doesn’t that…

Voice3: Jenkins, you’re fired.

Smallville Climax

One thing that I really like about Smallville is the fact that every episode of the show has an anticlimax. Many shows go for a climax at the very end of the episode…the climactic moment occurs sometime in the last five minutes or so. But Smallville generally hits the climax somewhere around minute 50, before the last commercial break, and then spends 10 or so minutes wrapping up plotlines and forshadowing future events. I think it shows a bit more respect toward the viewers, to spend some time wrapping up one-or-two-episode plotlines and answering questions right then, rather than assuming that nobody is really paying attention to anything but the action scene where Clark (or whoever) saves the day.

I have begun to lose interest in the show a little in the past several months, especially as the whole Lana/Clark thing just dragged on and on and on. The plot seems to have started picking back up and moving again near the end of April, though…but I’m about 5 episodes behind (Tivo’d) right now…so nobody spoil it for me if I was wrong and Lana & Clark have already gotten back together again :-)

Anonymous Delegates: Are you sure you’ve captured what you think you have?

I ran across this issue a while back, and as I came across a need to exercise the knowledge gained again today, I thought I’d post a quick note for others.

What’s wrong with this code?


foreach (Form form in forms)
{
ToolStripItem item = new ToolStripMenuItem(
form.Text, CreateImage(form.Icon), delegate { Open(form); }
);
strip.Items.Add(item);
}

Hint for old Lisp hands: the delegate { } construct creates a closure.

The problem is that every item ends up opening the last form in the list when clicked.

Here’s why: the loop variable, form takes on a number of different values during the lifetime of the loop. When the compiler creates the closure for the anonymous delegate, it doesn’t capture the value of variables — it captures references to the variables themselves. In C# terms, it’s as if you had declared form as a ref parameter to the delegate.

To correct this problem, you have to do something like the following instead.


foreach (Form lf in forms)
{
Form form = lf; // Create a local var for the closure below.
ToolStripItem item = new ToolStripMenuItem(
form.Text, CreateImage(form.Icon), delegate { Open(form); }
);
strip.Items.Add(item);
}

Here, we created a new variable that is local to the scope within which the anonymous delegate is created, and we reference it instead of the loop variable. Unlike the loop variable, this new variable only ever has one value (per time that its scope is entered, which is what is important). I.e., even though the loop body may execute many times, the compiler is essentially creating a new variable (== a new storage location) for each loop execution. (In reality, the compiler is actually creating a new instance of an anonymous class to hold that variable each time the loop body executes).

If the above discussion sounds worrying from a performance standpoint, don’t get too worked up about it. You only pay the price of features like anonymous delegates if you actually use them; if that method had been written without the delegate { } construct, the compiler would have emitted code that uses the same memory location for each loop iteration, no hidden anonymous classes or other shenanigans involved. And even in cases where you do use anonymous delegates, the alternative is generally to manually do what the compiler would do for you: create a class to hold state and pass it around. Just being aware of what the code that you write actually means will help you avoid major performance snafus. In the case above, the cost of the anonymous delegate is negligible, b/c the maximum execution count for that loop is still very small — commonly between 5 and 10, and always less than about 20. For numbers that small, worrying about performance is just wasted time.

Never speak too soon…

Arrgghh. Almost immediately started having temp problems again in my desktop PC (see the post last weekend). Turns out the dust wasn’t the only problem — the processor fan was also going bad…in fact it looks like it was about to quit entirely. Here’s the before-and-after (pictured across a hibernate during which the fan was replaced).

<lesson>
Inspect all available evidence. Don’t assume that the most obvoius solution is the correct or only cause of a problem, even if fixing it appears at first to solve the problem.
</lesson>

Time Machine

In an attempt to make some space in my garage and my life, I’m going through my old books and several years of saved magazines. The books are only vaguely interesting — what I’m getting rid of is mostly stuff that I read between late elementary and high school, stuff that I remember reading but have little desire to ever read again. What’s considerably more interesting to me are the magazines.
Continue reading

The Spam is Not Mine

Somebody is sending spam with my email address in the From field. It’s not from me. I didn’t send it. If you came here trying to find out who’s sending you spam, you’re on the wrong track. Go contact your legislators and tell them to pass some effective anti-spam legislation if you want it to stop.

Maintenance…

I hibernated my desktop to clean the accumulated dust out. Happened to leave the temperature gauge up, so when I logged back in, I got a very startling visual indication of just how bad it had gotten.

Temperature Gauge

Of course, that was the “just on” temp, but after several minutes it evened out at about 54/32 (processor/motherboard).

<voice style=”tone: educational; era: 1950s”>
So the lesson boys and girls: be sure wash behind your ears, in your navel, and inside your case.
</voice>

DLinq in C# 2.0

Out of curiosity, I decided to see what it would take to get DLinq working in C# 2.0. DLinq is really designed for C# 3.0, but it seems that none of the changes between 2.0 and 3.0 require new framework support — they’re all compiler-level. So, if you reference a DLL compiled with C# 3.0 (like System.Query, for instance) when compiling using the C# 2.0 compiler, things will work, minus the syntax enhancements to support it all.

It was a little harder than I’d thought. The only way I could figure out to get an initial Query object was to use reflection. Creating an initial Query (to which additional standard query operators may then be applied) is essentially equivalent to applying the from operator in C# 3.0. There is likely a better way, but even the better way may still rely on reflection: the LINQ docs describe how all of the new standard query operators are mapped to method calls except for from, for which I couldn’t find any information…

One gotcha: you have to use the exact same ParameterExpression object both to specify parameters to a lambda and to refer to that parameter within the lambda’s expression. Different objects that have the same name cause an “item not in dictionary” exception. (Example in code below is the widgetParm).

(Click “more” to see the code):
Continue reading

Dogs are Funny

My wife and I got a Black Lab puppy (if you call a 40-pound monster a puppy) a few months ago. So I’ve been learning how to keep and train a dog — and how not to kill her when she does something like systematically tear the screen out of every window in the back of the house looking for an open one…

Tonight I was standing in a doorway talking with my wife, though, and after a few moments, noticed that the dog kept circling in and out of the room. We figured out that she was trying to follow me, but b/c I had stopped in the doorway, she didn’t know which way I was going…so she just kept going in and out, in and out. I thought it was hilarious. You’ll never see a cat do something like that…

C# 2.0 Rocks

I’ve been playing with C# 2.0 for more than a year now, but now that I’m really using it in anger, I keep being surprised by just how helpful closures (anonymous delegates) are. The following used to require no fewer than six methods and about 4 times the number of lines of code.

private void OnClickZoomBn(object sender, EventArgs args)
{
            ContextMenuStrip menu = new ContextMenuStrip();
            menu.Items.Add("20%", null, delegate { m_printPreviewCtl.Zoom = 0.20; });
            menu.Items.Add("50%", null, delegate { m_printPreviewCtl.Zoom = 0.50; });
            menu.Items.Add("100%", null, delegate { m_printPreviewCtl.Zoom = 1.00; });
            menu.Items.Add("200%", null, delegate { m_printPreviewCtl.Zoom = 2.00; });
            menu.Items.Add("Auto", null, delegate { m_printPreviewCtl.AutoZoom = true; });
            menu.Show(m_zoomBn, new Point(2, 2));
}

Visual Studio 2005 Integration

With Microsoft loosening the restrictions on writing extensions for Visual Studio in the past two years, I was really hoping to see some progress on the extension and integration model for VS 2005. Unfortunately, it’s still mostly the same old COM-orfic mess it has been in the past. You know something is wrong when the A# guys, who ported a compiler for a non-trivial language like Ada to .NET and added support for it to two other IDEs, say this about Visual Studio:

I’ve looked into incorporating A# into Visual Studio .NET, but right now it looks like too much work for me to take on.

Darth Oedipus

I happened by the Episode III DVD at Wal-Mart a few days ago and picked it up. I put the commentary track on while I was working today, on which Lucas makes several comments about the story, including a few about the inspiration for certain elements of it. I could write quite a lot about the apparent political commentary (especially with Lucas’ own comments for fuel), but it’s been done before, and Lucas’ insistence that the only comparisons that make any sense are to the Nixon white house are relatively believable (since the story was fleshed out, at least in general, at that time). (So if there are parallels, the logical conclusion is that there are significant similarities between the Nixon-era political situation and the current one, but that’s all I’ll say about that…)

No, what I really want to mention today is my surprise that Lucas never mentioned the word Oedipus in the commentary, since Episode III in particular seems to be inspired so closely by Greek tragedy, Oedipus in particular. I don’t mean any of that desire-to-possess-your-mother-sexually stuff — Google around and you’ll find people who have identified that thread in the movie, but I’m not a psychiatrist, and if I was I wouldn’t be a Freudian 😉 What I mean is the idea that Anakin’s dreams (= the Oracle’s prophesy) gave him a glimpse of the future, and trying to prevent that future was exactly the thing that brought it about. Yet, Anakin isn’t off the hook just because he was destined to do what he did — he is still responsible for his choice. I’ve always been fascinated with the idea and logical consequences of fate (or predeterminism — the idea that you’re not absolved of responsibility for your decisions just because God knows what your decision will be), so those elements in Episode III jumped right out at me.

Vaguely related story: a few months ago, I saw Episode III in the theater with my wife and parents. At the end of the movie, my Dad leaned over to me and said, “I’ve got it figured out — this happened before the first movie, and the kids are Luke and the girl from the first movie.” — “Yes, Dad…” Which I guess goes to show that Lucas did a good job of linking the movies together even for people who don’t know these movies are prequels.

Intergalactic Medicine Show

For OSC fans, the first issue of a new online science fiction and fantasy magazine has just been released: Orson Scott Card’s InterGalactic Medicine Show. It’s $2.50 per issue (via PayPal), and is remarkable as much for its business model as for the fact that each issue is supposed to contain a new Ender story (along with lots of stuff not written by OSC — it does not appear to be primarily a platform for self-publishing his own works). The magazine claims exclusive copyright on works that it publishes for only a year, after which they switch only to nonexclusive digital rights — meaning that you are pretty-much free to sell it to anthologies or do what you want with it, but they get to keep that issue of the magazine online indefinitely. It’s about as author-friendly as you can get.

Here’s the best part, though: once you’ve paid for an issue, it loads in a normal HTML page, no DRM, no Adobe, nada. Best of all, there’s no timeout — once you’ve paid for an issue, it’s always yours. If IGMS goes out of business (as all companies, inevitably, someday will), you of course might not be able to retrieve back issues directly from them, but the fact that their content is non-encumbered means that you won’t be forced to buy something again if you buy a new computer, forget a password, or whatever. It seems they trust their readers enough not to treat them like criminals. If you enjoy science fiction and fantasy, and OSC, give it a look-see.

1 2 3 4 5 6