I Write Like …

July 14, 2010 Leave a comment

Using this new tool, you can enter a few paragraphs of text and it will decide which famous author you write like. In my case:

I Write Like by Mémoires, Mac journal software. Analyze your writing!

Categories: Uncategorized

Scott Pilgrim vs. The World Trailer

May 31, 2010 Leave a comment

This movie looks great. The live-action adaptation of Brian Lee O’Malley’s Scott Pilgrim comic book series.

The film, which stars Michael Cera, Mary Elizabeth Winstead, Kieran Culkin, Johnny Simmons, Ellen Wong, Allison Pill and Mark Webber, and Anna Kendrick, opens wide August 13.

Categories: Uncategorized

WCF Data Services Tip

March 31, 2010 1 comment

At work, I’ve been deep diving into OData / ADO.NET Data Services / WCF Data Services or whatever it’s named this week. We had a desire to expose an existing database table internally for Zip Code lookup. Previously, they used operations within an ASMX service, but I wanted to make a more RESTFUL service available.

Within this project, we already were using LINQ-to-SQL for our data access and I decided to use the DataContext exposed by that instead of wiring up an EDM just for that table. Data Services is pretty slick and can handle the LINQ data context. I followed the normal steps and quickly had a service up and running with the following code:

using System;
using System.Collections.Generic;
using System.Data.Services;
using System.Linq;
using System.ServiceModel.Web;
using System.Web;
using Location.DataAccess;
using System.Linq.Expressions;
using System.ServiceModel.Activation;

namespace Location.Service
{
    public class ZipCodeService : DataService<ZipCodesDataContext>
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("ZIPUSAs", EntitySetRights.AllRead);
            config.DataServiceBehavior.AcceptCountRequests = true;
            config.DataServiceBehavior.AcceptProjectionRequests = true;
            config.SetEntitySetPageSize("*", 25);
            config.DataServiceBehavior.MaxProtocolVersion = System.Data.Services.Common.DataServiceProtocolVersion.V2;

        }
    }
}

This works perfectly. I browse to the service and see the following XML:

<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<service xml:base="http://localhost:10903/ZipCodeService.svc/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app">
  <workspace>
    <atom:title>Default</atom:title>
    <collection href="ZIPUSAs">
      <atom:title>ZIPUSAs</atom:title>
    </collection>
  </workspace>
</service>

But that Collection title of “ZIPUSAs” just bugs me. So, I go into my DBML and change it to ZipCodes. Hit F5 to run and I get this error:

The server encountered an error processing the request. The exception message is 'Exception has been thrown by the target of an invocation.'. See server logs for more details. The exception stack trace is:
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Data.Services.DataServiceConfiguration.InvokeStaticInitialization(Type type)
   at System.Data.Services.DataService`1.CreateConfiguration(Type dataServiceType, IDataServiceMetadataProvider provider)
   at System.Data.Services.DataService`1.CreateProvider()
   at System.Data.Services.DataService`1.HandleRequest()
   at System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody)
   at SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

Yikes! What happened?

Well, I updated the entity name, but did not update the corresponding string in the ZipCodeService.InitializeService method. I need to change this:

config.SetEntitySetAccessRule("ZIPUSAs", EntitySetRights.AllRead);

to this:

config.SetEntitySetAccessRule("ZipCodes", EntitySetRights.AllRead);

But this continued to seem inelegant to me. I wish that there was a way to have the string change when I refactored my DBML entity.

With a hat tip to @brakower, here is a suggested solution:

config.SetEntitySetAccessRule(typeof(ZipCodes).Name, EntitySetRights.AllRead);

Works great.

Categories: .NET, Programming

New Nightmare On Elm Street Trailer

February 25, 2010 Leave a comment

Normally I am not a huge fan of remakes, but this looks pretty good. Jackie Earle Haley as Freddy Krueger is pretty inspired casting.

Categories: Uncategorized

Pittsburgh Steelers Ticket Office

January 12, 2010 Leave a comment

A man goes to the Pittsburgh Steelers ticket office and inquires about purchasing playoff tickets. The teller replies that there weren’t any tickets for sale because the Steelers did not make it to the playoffs.

The following day the same man goes to the Pittsburgh Steelers ticket office and inquires about purchasing Steelers playoff tickets. The ticket teller politely replies that there weren’t any tickets for sale because the Steelers did not make it to the playoffs.

This goes on for an entire week. The man goes to the Steelers ticket office inquiring about playoff tickets and the teller says none are for sale because the Steelers did not make it to the playoffs.

Another week of this goes by and the man still is asking the ticket teller about Steelers playoff tickets. Finally the ticket teller in a loud voice says, “I’VE TOLD YOU FOR THE LAST 2 WEEKS THERE WERE NOT ANY TICKETS AVAILABLE BECAUSE THE STEELERS DID NOT MAKE THE PLAYOFFS!”

The man replied, “I know. I drive all the way from Cleveland just to hear you say that!”

via TheOBR.com

Categories: Cleveland Browns

William Shatner vs. Sarah Palin

December 14, 2009 Leave a comment

Sarah Palin has had a good sense of humor about herself recently and she went on the Late Show recently and gave William Shatner a bit of his own medicine.

Categories: Uncategorized

Rihanna and Shy Ronnie (SNL Digital Short)

December 6, 2009 Leave a comment

Shy Ronnie’s name seems pretty apt.

Categories: Uncategorized

Braylon Edwards Still Has Trouble Catching The Ball

December 3, 2009 Leave a comment

I feel terrible for Braylon Edwards. This pass was perfectly thrown and would have turned into an 84 yard touchdown pass.

Braylon Drops from Patrick Veverka on Vimeo.

Categories: Uncategorized

Lost Episode Of Star Trek

December 3, 2009 Leave a comment

This has to be the silliest video ever. They are overdubbing to what it LOOKS like the character is saying.

[via]

Categories: Uncategorized

We have nothing to fear from love and commitment.

December 2, 2009 Leave a comment

Sen. Diane Savino (D-Staten Island) speaks out in favor of same-sex marriage ahead of today’s failed vote in the New York Senate.

Categories: Uncategorized