Supporting free software II: The saga continues

Last month, I posted about how I will start donating $5 per month to a free and/or open source project that I feel is worthy of my $5. (The first recipient was OpenOffice.) Over the past few days, the focus on .Net OSS projects has grown, partially thanks to Jeff Atwood. Ayende talks about putting OSS funds to good use on his projects (notably Castle/MonoRail/ActiveRecord), and a month ago Phil Haack talked about the growing .Net OSS attention.

Speaking of Phil Haack, he wrote today about his push for June 26th being “Contribute to Open Source Day“. To those professionals who use OSS projects regularly, I think $5 a month is hardly a lot of money.

(It’s not July yet, so I won’t announce who will get my next $5, but I assure you they will deserve it.)

Will you join the initiative to give $5 a month to a worthy open source project?

Capturing function keys in web browsers

I have a web application that allows the user to press the F2 key to bring up a modal box search window (the modal box script is provided by ModalBox). Today, one of the users came to me and said that every time they press the ‘Q’ key in the search box, the modal box refreshes.

It turned out that pressing the ‘Q’ key did in fact refresh the modal box — but only in Firefox, not in Internet Explorer. Knowing that Mozilla and IE have slightly different JavaScript event capture techniques, I looked at the code I was using to capture the F2 keypress.

Event.observe(window, 'load', function() {
	Event.observe(
		document, 'keypress', function(event)
		{
			if (event.keyCode) 
				keycode=event.keyCode;
			else
				keycode=event.which;
			if (keycode==113)
				Modalbox.show('Search', '/search/quicksearch.rails', {width:360, height:90});
		}
	);
});

A little research and I found the problem: keyCode 113 is the ASCII code for the lower-case ‘q’. I needed to find a way to capture the event when the function key 113 was pressed, not the ‘q’ key 113.

The solution was to use the event.charCode exposed in Firefox. This is undefined in IE, but in Firefox it equals zero when a function key is pressed. A little revision to the JavaScript code resulted in the following (note the difference in the line that contains (keycode==113).

Event.observe(window, 'load', function() {
	Event.observe(
		document, 'keypress', function(event)
		{
			if (event.keyCode) 
				keycode=event.keyCode;
			else
				keycode=event.which;
			if (keycode==113 && (event.charCode ? event.charCode : 0) == 0)
				Modalbox.show('Search', '/search/quicksearch.rails', {width:360, height:90});
		}
	);
});

Problem solved.

First community patch applied to WilsonORWrapper

Hot on the heals of yesterday’s update, I just received and applied the first community patch to WilsonORWrapper.

The patch, from Wayde Gilliam, adds the following:

  • Added MemberPrefix option to mappings generator, allowing member prefix (private field) customization
  • Added SetProperties method allowing dictionary-based changes
  • Added IncludeList option to mappings generator, allowing selective table inclusion (combines functionality with IgnoreList)

Hats off to Wayde for a well-written patch!

Release 43 (download source code) has the aforementioned changes, as well as an update to the readme file which gives kudos to Wayde and to Gunter Spranz, an early-adopter of this project whose insight and input was invaluable in the development of the product as we see it today.

Thanks to both — and don’t forget to go ahead and send in your own patch!

Query added to WilsonORWrapper

I just updated WilsonORWrapper to include a Query<T> class that simplifies using OPathQuery<T> objects. To illustrate, I’ll take the content from the newly-written Services page on the project wiki (which also gives an overview of the Data<T> service).


The Query service provides a simple interface to generating OPath queries. It helps simplify code by avoiding the need to explicitly use the Wilson.ORMapper namespace to generate OPathQuery objects.

Using the Query service is best illustrated by comparing how you would generate an OPathQuery using the Wilson.ORMapper namespace, and how you would generate a query using the Query object (which hides the underlying OPathQuery object from your code).

Querying using OPathQuery<T>

using Wilson.ORMapper; 
using WilsonORWrapper.Services; 
... 
OPathQuery&lt;User&gt; query = new OPathQuery&lt;User&gt;("Name = ?");  
User user = Data&lt;User&gt;.Retrieve(query, "Brian"); 

Querying using Query<T>

  
using WilsonORWrapper.Services;  
...  
Query&lt;User&gt; query = new Query&lt;User&gt;("Name = ?");  
User user = Data&lt;User&gt;.Retrieve(query, "Brian"); 

Note the similarities of the code. The usage of Query<T> is the same as OPathQuery<T>, but you are saved the hassle of dealing with a separate namespace.


I hope you find this helpful, and as always, please give me your feedback on the project.

Download the source code for this release (r41). (Compiled distributions are not currently available.)

Excel crashes, and flooding Microsoft with error reports

Excel 2007 crashed on me while I was scrolling vertically using the mouse wheel. Impressively, Excel was able to recover, apparently right back where I left off scrolling.excel_error_reporting

I continued trying to scroll (again with the mouse wheel), and once again, after about 100 or so rows scroll by, Excel crashes again. This time, I choose to send the error report.

Recovery again works like a charm (at least one thing is working right). I try scrolling with the scroll bar; no crash. I try page-down and arrow keys; no crash. I go to a different part of the document and scroll with the mouse wheel; crash after about 100 rows pass by.

“Send error report” clicked again.

This is getting fun, so I’m going to do it about 20 more times.

Supporting free software: My drive to donate

I’ve been a fan of free things for a long time, whether it be software or web sites. “If it’s for free, it’s for me.” Scanning through my list of installed programs and bookmarked web sites, I find the following.

Note: The list below includes free software that is not a free version of commercial software. As an example, Grisoft‘s free software is excluded, as those are feature-limited versions of commercial software.

There’s many more than those listed above, as well — those are just the ones I was able to identify quickly.

Most of those projects are voluntary efforts spearheaded by a few good men (and women) with no financial reward. Being a provider of free software myself, I realize how important it is to get the occasional donation — not just to help defray costs (my baseball game, CSFBL, costs over $250 a month just for the Internet connection and server, and the latter is woefully inadequate), but to also give you the incentive to keep plugging forward. Each donation becomes a validation that what you do is worthwhile and meaningful to someone other than yourself, and in many ways, getting that donation helps give you the incentive to keep plugging away.

That all being said, I decided that, starting June 2007, I will donate a small amount of money ($5.00) each month to one free project that I feel is worth the cause. Sure, $5.00 is not a lot — it amounts to $60 a year, an amount that does not reflect the economic value that these products bring to me — but my goal here is to start a trend.

We all use free stuff, and we all reap the rewards of it. Think how much more free stuff there would be — and how much better it would be — if each of us gave $5 a month to a single worthy product or service?

Sure, you can think, “It’s not free if we give money.” That may be true, but that’s not the point. Free software means that someone is giving you something with no expectation in return. By giving something to those people, we are saying “Thank you” and giving them the incentive to keep doing what they’re doing.

My first pledge goes to OpenOffice. They accept donations via PayPal, which makes it very easy. For $5.00 (rather 5 euros, so they get a little more than $5.00 thanks to favorable exchange rates), I have saved hundreds of dollars buying a commercial productivity suite. It’s money well-spent.

So, what do you say? Will you join the movement to pledge $5 a month to a free product or service that you feel is deserving? Make your pledge and let me know you’re on-board!

WilsonORWrapper: better, stronger, (maybe) faster

About a month ago, I wrote about a major update coming to WilsonORWrapper, the code library/code generation templates I put together for Paul Wilson’s O/R Mapper. Finally, it’s available!

The source code, releases, API documentation, and some (but far from enough) how-to sections are available on the WilsonORWrapper project site.

For those who used the previous version of the wrapper, there are some major breaking changes in here, but it’s not incredibly time-consuming or difficult to make the transition. The namespace hierarchy is changed somewhat, the configuration settings are changed, and some core classes have different method names, but overall it shouldn’t take long to convert. (I converted a project with about 30 entity classes in about 60 minutes.)

Every few days, I’m going to add to the “how-to” documentation, focusing on a different part of the library each time. Until then, there’s still plenty of stuff to check out.

If you find an error, please create a ticket on the project site. If you have comments or suggestions, post them here or on the WilsonORWrapper project page on this blog.

Testing Windows Live Writer with WordPress

I buckled down and installed Windows Live Writer today. Sure, I’m happy enough with the default WordPress post editors (I like simple editors that don’t do too much and give me total HTML control), but decided it was time to try it out, since others seem to be using it successfully.

So, here it goes — a quick test of inserting a picture with a drop-shadow:

windows-live-writer-test-pic

(Saving draft to blog, be right back…)

I’m actually impressed! It worked rather well. The fact that Live Writer uses my stylesheets in the post editor is quite nice. Two little quirks:

  • The image successfully uploaded (to wp-content/uploads), which is very nice. I would prefer if it uploaded to a subdirectory (wp-content/uploads/images), but that can be configured by customizing the FTP configuration. Still, an option to upload images to a custom subdirectory would be nice.
  • Though I saved this post as a draft, it is being seen as a post, and my drafts are empty. Another minor detail.

One thing that’s important to me is source formatting using SyntaxHighlighter from dreamprojections. Here’s a test of that…

public static void Main()
{
// just a test
}

Well, the initial try didn’t work, thanks to HTML tags being inserted into the code. Can’t blame WLW for that. I could just edit the code in HTML view, which is fine for now. I may try a WLW plug-in for source editing, or maybe roll my own.

In the end, after a quick test, I have to say that I would use Windows Live Writer again. Hats off to Microsoft for coming up with this useful tool.