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.

Google Reader offline with Google Gears

I noticed a new item in the top right of my Google Reader window today:

Google Reader Offline (new!)

Interesting! I clicked the Offline link and was introduced to Google Gears (beta).

Google Reader Offline with Google Gears

After a short installation and a restart of Firefox, I was greeted with a little green arrow in Google Reader. Clicking on it started a background download of 2,000 recent RSS feed items, which became available to me even when I wasn’t “on the wire”.
Once again, Google shows the rest of the world how powerful tools can be made simple. Will GMail Offline be far behind?

Excel 2007’s unresponsive autorecovery feature

For the past 15 minutes, the newly-installed Excel 2007 has been unresponsive. Well, not totally unresponsive. It is doing something in the background: saving autorecover information. I know this because, every so often, I can get Excel to show me a little something like the following:

Excel autorecover... still waiting...

Task Manager periodically says Excel is “not responding” and other times says it is “running” (maybe so, but it’s still not responding to me).

In defense of Excel, this was a rather large document: over 15,000 rows and 26 columns — 12.9MB on disk. However, there’s no reason for any background process to make an application unresponsive — especially when the background process in question is something that supposed to protect you from the application becoming unresponsive.

I also can’t figure out why saving an autorecovery file takes about 20 minutes, when saving a new copy of the same file takes about five seconds.

Disclaimer: I happily use OpenOffice for personal use and Google Spreadsheets for shared documents. Office 2007 was installed on my work desktop so I can evaluate it. Let’s say the evaluation isn’t going so well right now.

Five simple rules for creating delimited text files

Here’s a few tips for those people who provide raw data in text files (think CSV files and the like).

  1. Surround all text fields in single quotes, even if a comma does not exist in a specific instance. By failing to do this, you lose field delimiter consistency on a row-by-row basis, forcing the contents of the field to be parsed separately (i.e. stripping the “optional” quotes).
  2. Use consistent line endings. Pick one and stick with it for all your files. Use either (CR/LF), (LF), or (CR) — and use the same in all your files.
  3. Put column headings in the first row only. This is more a convenience than a necessity. If you make your first row column headings, make sure it is only the first row.
  4. Every row past the first should have an identical schema. Don’t try to be fancy and have different row types in one file. Each file should have the same number and sequence of columns.
  5. Provide delimiters for all columns, even when a row does not have data for them. For example, in a comma-delimited file with five columns, if a row has data in only the first two columns, make sure the row ends with three commas. Failure to do so implies missing or incomplete data.

When text files following these guidelines, I can write a script to import them into a SQL table (using BCP and a simple batch file) in a few minutes. Each guideline that is broken requires additional cleanup steps and more complex data import steps, and adds significant development (and debugging) time that shouldn’t be necessary.

Lost in (Google) translation

For the past few days, I’ve been working on importing raw play-by-play data for Japanese baseball. Once the import scripts and queries were written, I needed a way to audit the results. To do that, I needed a source for up-to-date statistics on Japanese baseball players.
Yahoo! provides a rather robust web site for the Nippon Professional Baseball (NPB). Unfortunately, the web site is in Japanese, a language I don’t read or have support for on my computer, so the screen was, for the most part, filled with question marks, as seen below.

Yahoo! Sports NPB Baseball (before translation)
Yahoo! Sports NPB Baseball (before translation)

By using Google Translator, I was able to transform this into the following:

Yahoo! Sports NPB Baseball (with Google translation)
Yahoo! Sports NPB Baseball (with Google translation)

I wasn’t expecting a perfect translation (it would be silly to do so), but the results were certainly entertaining.

  • A “base on balls” is a “giving Annie Oakley”.
  • A “hit batter” is a “giving dead sphere” (the poor batter).
  • “On base percentage” is “coming out base ratio”.
  • “Slugging percentage” is “long batting average”.

If you look at a translated hitter’s page, you’ll see this unusual description of a player’s at-bat:

Two racketeers, empty three swing, medium flying it is cheap, the left ? flying, two racketeers

Who says there’s no racketeering in professional baseball today?