Friday, May 09, 2008

The trending feature in DasBlog is pretty much non-existant, and the reporting is pretty lack luster, so I've decided to switch over to FeedBurner so I can get a handle on whats going on with this blog and its readers.  So, if you wouldn't mind, please kindly update your feed reader to pull from my feed burner feed. http://feeds.feedburner.com/akcoder

Update! - I upgraded to DasBlogCE 2.0 which has an option to set your feedburner information. So you shouldn't have to do anything if to quote Scott Hanselman "Aggregrators worth their salt know to update their local records when a feed issues a 301. DasBlog will automatically get everyone over to your new feed."

posted on Friday, May 09, 2008 9:35:27 AM (Alaskan Standard Time, UTC-09:00)  #    Comments [0]

The Problem

For the last few days I've been trying to figure out how to do this SQL in linq:

   1: select from customers where substring(customers.Name, 1, 1) IN ('a', 'b', 'c', 'd');
The problem is the list (a, b, c, d) is variable, on one page I need all the results where foo.Name starts with a or b, on another it could be b, c, d, e and f.  This is trivial to do in SQL, you just break out a little dynamic sql and your done.  But being a noob to LINQ, I'm not so sure how to go about doing this.

I had a lot of failed queries, and failed code, before giving up and just looping through the letters for that particular page and manually building up what I wanted.

But that's kind of a hack. OK, its not kind of a hack, its a big hack.

The Solution

This LINQ goodness (using the Customers db in LINQPad) will pull back all the customers who's names begin with a t, d, or j (note the .ToList() on line 4, I'll discuss it next).

   1: string[] letters = { "t", "d", "j" }; 
   2:  
   3: var customers = (from c in Customers
   4:     select c).ToList(); 
   5:  
   6: var results = from c in customers
   7:     join letter in letters on c.Name.First().ToString().ToUpper() equals letter.ToUpper()
   8:     select c; 
   9:  
  10: customers.Dump("Customers");
  11: results.Dump("Filtered by first letter");

And LINQPad renders this for us:

image

Limitations

LINQ to SQL doesn't support querying a SQL database with if one of your sources is an in-memory store, except if you use the Contains operator.  So, to work around that, you have to pull back ALL the results from the db, and then convert it to a List before you use it in the above query.

I'm my opinion, this is kind of a painful limitation, but for my particular purpose, I'm willing to live with it because my particular database will only ever have around 100 or so rows, so pulling everything back in memory isn't such a big deal...

P.S. if you are reading this in a feed reader, let me know how it renders, I've updated my code snippet plugin to try and fix the previous rendering problems.

posted on Friday, May 09, 2008 12:13:08 AM (Alaskan Standard Time, UTC-09:00)  #    Comments [0]
 Saturday, May 03, 2008

So in my last post, I ranted (well, tried to, but my rant got wiped out when Vista crashed) about what I didn't like about Vista.  Now I'll rant about what I do like about Vista.

Task Manager and Resource Monitor

Both the Task Manager and the Resource Monitor (formally performance monitor) on Vista received a much needed revamp.  The fact that task man now allows you to go to one place and see all your running programs and services, and even allows you to start/stop services from within the task man is a huge improvement.  And with perfmon, being about to see at a glance what is going on with your CPU, disk, network and memory is awesome!  While the old perfmon was OK, the fact that you had to 1) add all those things separately and then try to discern one from another because they were all overlayed on one graph was kind of a pain.

Animations / Eye Candy

In ALL previous version of Microsoft Windows, the first thing I would do is turn off ALL the animations, I always found them to be annoying, distracting, and a waste of my time.  But I've found the animations and eye candy with Vista to actually enhance the experience of using the OS.

Start Menu

The start menu in all previous versions of Microsoft Windows was always a jumbled mess of applications, and God forbid you had more than a dozen or so applications installed, your start menu would become just unwieldy.  I used to organize all my programs by type, Internet, Utilities, Audio & Video, and Development to try and tame the mess that was the start menu.  Now, it really doesn't matter how big a mess it becomes, the fact that I can press the Win key and start typing makes the whole thing more manageable, and a heck of a lot easier to use.

Programs and Features

The abomination that was formally Add/Remove Programs has finally been fixed!  As a developer, with all the software I had to have installed, it would take several minutes for the Add/Remove Programs dialog to come up and populate. Now, it pops up right away, and starts populating.  I haven't had it take more than 10-15 seconds for it to fully populate with all my programs!  And, it even tells me down at the bottom that I have 101 programs installed, for a total of 9.57 GB of space.  Pretty handy. That fact that I can sort all my installed programs by size is really nice as well.

Overall

Overall, when I can get Windows Vista to not lockup, I'm happy with it.  If things continue the way they have been today, I think I'll stick with Windows Vista.  I can say though, that game performance is pretty crappy.  I'm getting a solid 10-15 frames per second less in Half Life 2 :(

posted on Saturday, May 03, 2008 5:44:27 PM (Alaskan Standard Time, UTC-09:00)  #    Comments [0]