No Free Time

Because my therapist says I need to let things out

Archive for July, 2008

How cool is Cuil?

Posted by andrewmyhre on July 29, 2008

So there’s buzz around this new search engine, but I want to know if it’s good, and whether it’s something I’d actually use. Off-hand I can think of three types of search I perform reguarly: technology, social networking and Wikipedia. Technology searching demonstrates up-to-date indexing, and the latter two demonstrate a level of index depth. So I performed a couple of tests, and here are my results with handy links if you want to compare for yourself.

Note: Cuil will probably improve a lot, and these are three very specific searches so we can only draw limited conclusions from them. So take all of this with a pinch of salt. If you know of a good comparison search let me know and I’ll add it here.

Search Results

Technology: Search term = ‘asp.net mvc preview 4′

Cuil: http://www.cuil.com/search?q=asp.net%20mvc%20preview%204&sl=long

The first page gives me eleven links to content, none of which is specifically to do with the latest build of the ASP.Net MVC Framework, let alone a link to a download page. Some of the pages are tutorials relevant to older versions of the framework but may still be applicable to the new version.

Google: http://www.google.co.uk/search?q=asp.net+mvc+preview+4&sourceid=navclient-ff&ie=UTF-8&rlz=1B3GGGL_enGB260GB260

The striking thing to notice in Google’s results page is that, of the ten results, nine of them actually have the words ‘preview 4′ in the title. From this I can immediately gather that their results are more relevant to me. Also, three of the pages contained links to the MVC project page or the installer on CodePlex, and one of the pages was a direct link to the CodePlex project page.

Social networking: Search term = ‘twitter andrew myhre’

Cuil: http://www.cuil.com/search?q=twitter%20andrew%20myhre&sl=long

Interestingly, Cuil’s first page provides a list of people I follow/who follow me, but none of the results is a link to me or my Twitter page. Most likely that’s because noone would deliberately link to my feed, but those links do exist on the pages in Cuil’s search result.

Google: http://www.google.co.uk/search?hl=en&rlz=1B3GGGL_enGB260GB260&q=twitter+andrew+myhre&btnG=Search&meta=

Google gives a somewhat better result. The first link is to a tweet within the feed of someone who follows me, and the second is a link to their profile. The third and fourth links are to my FriendFeed and the fifth is to a much-less-up-to-date mirror of this blog. The rest are barely or not at all related to me. Somewhat better than Cuil but I still expected better somehow.

Most interesting is when I search using my actual Twitter username ‘andrew_myhre’:

http://www.google.co.uk/search?hl=en&rlz=1B3GGGL_enGB260GB260&q=twitter+andrew_myhre&btnG=Search&meta=

Google finds me, first hit.

http://www.cuil.com/search?q=twitter%20andrew_myhre&sl=long

Cuil actually returns zero results. Disappointing.

Wikipedia: Search term = ‘wiki bicycle pump’

Google: http://www.google.co.uk/search?hl=en&q=wiki+bicycle+pump&btnG=Google+Search&meta=

As expected, the first result is the exact record I’m looking for – the Wikipedia entry on bicycle pumps.

Cuil: http://www.cuil.com/search?q=wiki%20bicycle%20pump&sl=long

Cuil earnestly presents a number of options but comes up short. No links to Wikipedia to be found.

Summary

Generally, Cuil doesn’t give me information that’s as relevant as what Google does. The problem seems to lie in the relationships between content nodes – why can’t Cuil knit my blog and social networking sites together to provide a seemingly complete ‘whole’ in the way that Google does?

On top of this, the value-adds that Google provides like postcode parsing, shopping information and natural language parsing of terms like time zones, weather and money (interesting that they don’t parse Zimbabwe dollars btw) I just get a lot more out of Google’s results.

Posted in tech | Tagged: | Leave a Comment »

Howto: “Object not set to an instance of an object” in Visual Studio 2008 when trying to add a Silverlight project to a solution

Posted by andrewmyhre on July 22, 2008

I installed Visual Studio 2008 SP1 Beta, .Net 3.5 SP1 Beta and the new Silverlight Tools Beta 2, and when I tried to add a new Silverlight project to my solution I got a dialog in Visual Studio with the message “Object not set to an instance of an object”, after which nothing happens and my project was not added.

If you’re having the same problem try these steps:

  1. Open Visual Studio Command Prompt
  2. devenv /resetskippkgs [return]
  3. Close VS
  4. devenv /setup [return]
  5. devenv [return]

Hopefully now you’ll be able to add a Silverlight project to your solution.

Source of this solution here.

Posted in silverlight | Tagged: , | Leave a Comment »

Performing a case-sensitive search and replace in SQL 2000/2005

Posted by andrewmyhre on July 22, 2008

If you need to perform a case sensitive search and/or replace in an SQL 2000 or SQL 2005 database you need to use the correct collation method. In the situation I had today I needed to change some copy throughout a website, all of which is in a string resource table, but I had to be careful to maintian case used, i.e: ‘Shipping’ had to change to ‘Delivery’, but ’shipping’ had to change to ‘delivery’.

Your database may have been set up to use a case-sensitive collation method, or it may not have, or you may not have been involved in setup. I don’t know which collation method is the smartest in the world to use – I’m not a DBA – but here’s how to find out which collation you’re working with.

Execute this query in a query analyser:

select charindex('If the result is 0 you are in a case-sensitive collation mode', 'RESULT')

A 0 return result means you’re working with a case-sensitive collation mode. This means you can write your search/replace query (I’ll give an example below) without specifying the collation method you want to use and your query will consider ‘RESULT’ different to ‘result’.

If you DO have to specify a collation method you just have to declare it after the column name you’re interested in. Here’s an example:

update StringResource
set ConfigValue = replace(ConfigValue COLLATE Latin1_General_BIN, 'Shipping', 'Delivery')
from StringResource
where charindex('Shipping', configvalue COLLATE Latin1_General_BIN) > 0

update StringResource
set ConfigValue = replace(ConfigValue COLLATE Latin1_General_BIN, 'shipping', 'delivery')
from StringResource
where charindex('shipping', configvalue COLLATE Latin1_General_BIN) > 0

This query replaces the word ‘Shipping’ with ‘Delivery’ in the ConfigValue column in the StringResource table. There are two seperate statements, one for each case I’m replacing, because I need to specify the casing I’m concerned with explicitly. The important part of the collation type is the _BIN part, which specifies that I want to compare strings as binary data. More information about aspects of collation sorting here. This method may not be the smartest in the world so I would appreciate any comments.

Posted in sql | Tagged: | 2 Comments »

Howto: Only include part of a project workspace in a TFS 2008 Team Build

Posted by andrewmyhre on July 17, 2008

I’m working on a website with a large design aspect, so we have a lot of .psd files (about 200mb) kicking about the place. We want them source controlled, so they live in the TFS 2008 team project folder in source control. But then our Team Build includes them when downloading the source files, so that quickly fills up our build server’s drive and makes a single build take up to 11 minutes, which is far too long for a basic eCommerce website.

So I trimmed these files from our build process. Here’s what I did:

  1. Copy the .psd files and any other files that aren’t required for a build into a seperate folder in the root of the team project. (All our website/source files are in another folder called ‘Current’, as in the ‘current version’, as opposed to ‘Phase 1′, ‘Phase 2′)
  2. In Team Explorer, right click the build you want to edit and selected Edit Build Definition…
  3. In the Workspace tab, enter the path within source control where you want to start downloading files from. In our case I chose the $/[project]/Current folder, so the /PSDs folder will be ignored and not downloaded.

Now, thanks to the above steps my build history folders are 1/10th the size they were to begin with, and the build process takes less than half the time!

Posted in .net, CI, tfs | Tagged: , , | 2 Comments »

Neat video

Posted by andrewmyhre on July 16, 2008

Posted in Uncategorized | Tagged: | Leave a Comment »

Enabling WCF in IIS 7 on Vista

Posted by andrewmyhre on July 13, 2008

I created a Silverlight-enabled WCF service which worked perfectly when running my Silverlight app from Visual Studio, but as soon as I deployed to IIS 7 on my machine and opened it outside of VS I received the following error:

Unhandled Error in Silverlight 2 Application Exception has been thrown by the target of an invocation. at System.RuntimeMethodHandle._InvokeMethodFast
…… (there was more

I couldn’t be sure whether this was a Silverlight or a WCF issue so I opened the SVC url in my browser and received a (405) Method Not Allowed response. I checked IIS and discovered there was no HTTP Handler set up for WCF services.

I then managed to find this very helpful post about setting up WCF HTTP Handlers in IIS 7, and the solution described worked perfectly for me. Here are the steps:

  1. Open a command prompt as administrator
  2. CD to c:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation
  3. Type ServiceModelReg -i and press return
  4. A whole load of lines like “Installing: HTTP Handlers” will print out to the console. When it’s finished go into IIS 7 and open the HTTP Handlers list for your website. You should see a couple of new ones for the *.svc extension

Also, another issue I came across while trying to track down how to set these up was where people were deploying their WCF/Silverlight project to IIS 7 without updating their web.config to change the server binding reference. When you add a service reference to your Silverlight project the url is stored in the ServiceReferences.ClientConfig file, but if the WCF project is defined in the same solution then the URL will point to the local Cassini server, which means the service call will fail when you deploy the app to IIS.

One solution to the issue is to override the service URL in code, so that you don’t have to keep updating the .config file when you deploy to a web server.

Posted in .net, iis7, silverlight | Tagged: , , , | 1 Comment »

How to create a default instance of a type T

Posted by andrewmyhre on July 11, 2008

A problem I’ve come across in the past when writing ORM solutions is when I need to create a new instance of generic type T but set to a NULL or 0 value. Value types I need to set to null but reference types I need to set to 0. How do I do the right thing? Here’s a bad way:

if (typeof(container) == typeof(int))
container = 0;
else if (typeof(container) == typeof(Customer))
container = null;

Using this method means lots of if … else if …else by checking type. How ugly! There has to be a better way, I thought. So I gave up and got on with something else.

Months later, it turns out there IS a better way: the default keyword:

t container = default(containerType);

This keyword gives you a NULL or 0 value based on the type you pass it. I don’t know whether it’s faster or more efficient, but hey, it’s a lot less code for you to write, and you can be pretty sure they’ve covered all the edge cases.

More information about the default keyword.

Posted in .net, c++ | Tagged: , | Leave a Comment »

How to delete a team project in Team Foundation Server 2005/2008

Posted by andrewmyhre on July 9, 2008

TFS 2005/2008 both ship with the TfsDeleteProject.exe utility.

Open a command line on your team foundation server and cd to

%program files%\Microsoft Visual Studio 9.0\Common7\IDE (2008)
%program files%\Microsoft Visual Studio 8\Common7\IDE (2005)

Then:

tfsdeleteproject /q /force /server:<tfs server> "<project name>"

Posted in tfs | Tagged: | Leave a Comment »

ASP.Net MVC: Giving MasterPages access to ViewData

Posted by andrewmyhre on July 3, 2008

If you want to include ViewData in the MasterPage UI, you can.

ASP.Net MVC MasterPages are System.Web.Mvc.ViewMasterPage – this is a generic type just like System.Web.Mvc.ViewPage. So you can type it with a ViewData object, like this:

public partial class MyTemplate : ViewMasterPage<SomeViewData>

As soon as you do this you’re saying that the SomeViewData class is the only ViewData object that can be used on any page using this template. Not a problem though, just create a base ViewData class.

public class SiteWideViewData
{
}

public class PageViewData : SiteWideViewData
{
}

This of course means no more default ViewData objects and no more return View(); I found the easiest way to deal with that is to create a static property on the base ViewData:

public class SiteWideViewData
{
public static SiteWideViewData Default { get { return new SiteWideViewData(); } }
}

Now I can do this:

public ActionResult MySimpleControllerMethod()
{
return View(SiteWideViewData.Default);
}

And that seems to work okay.

Posted in .net, mvc | Tagged: , | 3 Comments »