Google Cookie Monster, Part Deux – Where Is The Debate??

I’m rather disspointed by thispost on GigaOm, responding to Microsoft’s Dean Hachamovitch’s post doing a little Google Privacy exposé of his own. .

The GigaOm post, it seems, blames Microsoft for pulling Google up on its failure to adhere to an old standard, in this case the P3P standard. This standard is meant to allow a site to notify a browser, and hence the user, on what it will do with the information it collects from you. In other words, the standard is meant to solve the very problem that started Google Cookiegate.

Instead of blaming Microsoft for jumping into the fray and touting its own browser, rather we should be pointing out that not only is Internet Explorer the only browser to implement this privacy related standard, but the fact that Google has highlighted the need for it to be improved.

Why is it that no other browsers implement this standard?? Why is it that there is no movement for it to be improved? All those bloggers calling bloody murder over this Google Cookiegate should be urging the updating and wider adoption of this standard.

Far from being a damp squib, Hachamovitch’s post is an important contribution to the debate. It may be self serving, but who else would have known of the existence of this standard if it wasn’t for that post.

Come on GigaOm – I expect better than blindly bashing any contribution Microsoft makes.

The Google Cookie Monster

So everyone is up in arms because Google is using some nefarious tricks to bypass browser cookie privacy provisions.

 

Ok, So Google isn’t living up to its “Dont Be Evil” motto. Big deal.

 

However, let be clear here….. when we use Google and all those free Google services, do you really think Google is providing all this out of the goodness of its heart?? Seriously??

 

Of course not. As the Facebook IPO demonstrates so well, our personal information is worth money to advertisers – and worth a lot of it too.

 

So, taken to its logical conclusion, when we use Google and all those free Google services, Google puts tracking cookies on our machines, we effectively trade our this personal information for the use of Goolge services. Good trade, right??

 

Now, what do you expect Google to do in this market place? Facebook and its personalised advertising are beating down Google’s alley. Why do you think Google is fighting back with Goolge+ and including Google+ in its search results? (remember the kerfuffle that caused? Well, for a short period of time, anyway). You really expect them to sit on their hands when theres a way of collecting even more data??

 

You really need bigger excuses than putting some noses out of joint to pass on making money.

 

There’s a legitimate argument to be made that Google should be honouring web standards like the P3P standard that’s at the centre of this latest kerfuffle. the web with out standard is a bad place to be. But I’d argue that this is a natural occurrence in the evolution of standards. We’ll find a middle group between the privacy needs to users and the  need for advertisers to make money.

 

So, grow up techy people – the world outside Silicon Valley DOES NOT CARE!

PS – The US store chain Target uses almost the exact same techniques coupled with a little nifty statistics to tell when you’re pregnant.

 

PPS Go watch This Week In Tech Leo Laporte and Co have some excellent opinions on this.

Holiday Reading 2011

I’m off on holiday for the next two weeks.

As has become something of a tradition here, I’m posting my reading list.

 

Fiction

Ender’s Game – Orson Scott Card (Paperback)

Speaker For The Dead – Orson Scott Card (iBooks)

Captain’s Blood – William Shatner (iBooks)

Captain’s Peril – William Shatner (iBooks)

Captain’s Glory – William Shatner (Hardback)

 

Non – Fiction

Up Till Now – William Shatner (iBooks)

Steve Jobs – Walter Isasacson (iBooks – only fitting)

Bossypants – Tina Fey (iBooks)

Microsoft Official Course 6231B – Maintaining a Microsoft SQL Server 2008 R2 Database

Microsoft Official Course 6232B – Implementing a Microsoft SQL Server 2008 R2 Database

 

That should keep me busy. Of course, there are still 30 something other eBooks on my iPad should I get bored.

 

The Microsoft Official Course stuff is for exams in January. What Fun!!

ASP.Net MVC Tip: URL Anchor Tags

This is one of those features which should be baked into MVC by default, but isn’t.

Actually, it is partially supported by MVC. This Codeplex answer details it:

 

@Html.ActionLink(
    "Link Text",           // linkText
    "Action",              // actionName
    "Controller",          // controllerName
    null,                  // protocol
    null,                  // hostName
    "fragment",            // fragment
    new { id = "123" },    // routeValues
    null                   // htmlAttributes
)

will produce (assuming default routes):

<a href="/Controller/Action/123#fragment">Link Text</a>

But what if you want the returned redirect of an ActionResult method to include the anchor tag. There is no RedirectAnchorTagResult to return.

 

That same answer does some voodoo to pull it off:

public ActionResult Index()
{
    var url = UrlHelper.GenerateUrl(
        null,
        "Action",
        "Controller",
        null,
        null,
        "fragment",
        new RouteValueDictionary(new { id = "123" }),
        Url.RouteCollection,
        Url.RequestContext,
        false
    );
    return Redirect(url);
}

 

It is this that should be baked into MVC by default. Thats an awful lot of complexity to expose just for the sake of a simple anchor tag. So, yes, a RedirectAnchorTagResult would be a nice addition.

 

Thanks to Darin Dimitrov for providing the answer. Go ahead and upvote his answer.

Codeplex Projects of the Week.

Two Codeplex projects have come in quite handy for  me this week and I thought I’d pass them on.

 

WSUS 3.0 – WSUS Smart Approve

I installed Windows Server Update Services on my Windows Home Server 2011 this week.

As usual, I was in a bit over my head. I hit the Approve All Updates nuclear option. Knowledgeable sysadmins are possibly cringing or screaming at me (or both). By the time i figured out that approving updates puts them in the download queue, 4 and a half gigabytes were in the queue. Ordinarily this wouldn’t be a problem. But my broadband has had issues and it’s ridiculously slow (0.85 MBPS) and WSUS was eating up all the bandwidth.

So this was a problem. The solution was, of course to approve and download only needed updates. Amazingly, WSUS has no way of automatically approving needed updates (even as a checkbox buried five or six option screens down and off by default).

So, Codeplex to the rescue!

WSUS Smart Approve does exactly what it says on the tin – automatically approving updates according to certain rules. One of those is, of course, to approve needed updates automatically.

 

MetaWeblogAPI – ooMetaWeblog

One of the nice things about the MetaWeblogAPI is that almost everyone supports it. One of those is, of course, Windows Live Writer 2011.

Using Windows Live Writer as a WYSIWYG editor would be convenient.

There are a number of options to implement a server-side MetaWeblogAPI endpoint. Scott Hanselman has one approach.

I used another approach  – the Matlus.MetaWeblogAPI.

The corresponding Codeplex project is ooMetaWeblog.

 

Hope they come in helpful for somebody.

Why Silverlight Should Stay

Mary Jo Foley just published a post discussing the future of Silverlight.

I’m not a Silverlight Developer by any stretch of the imagination. I never played with it. Never touched it at all.

Then, for the Flying Shakes website,  I had to have the control below in a web form. Naturally I turned to Silverlight.

image

 

With no knowledge or experience of Silverlight it took me 90 minutes from idea to working control.

And yes, I realise that I could write a HTML5 version of that now. But it would probably take much, much longer (don’t nobody suggest Flash).

Silverlight is good, not just for rich client experiences it allows us to build, but also because its part and parcel of the tools we Visual Studio devs work with every day.

The flip side to this, of course is the user perspective.

Here in the UK we have Sky satellite television. The reason why I like them so much is that they are fairly technology friendly. Besides streaming on the go (iPad, iPhone, etc), you can log on to their Sky Go website to stream on-demand or download and watch on your desktop offline.

This experience is delivered by, wait for it, Silverlight. The impressive part of this whole thing was the Sky Go Desktop Client. Its an offline Silverlight application, popping straight out of the browser and installed silently.  Was downloading from my queue 10 seconds after hitting the download button.

Satisfied does not even begin to describe it.

I HTML 5 may be the bees knees, but there is still a business case for keeping Silverlight around.

I’ll consider HTML 5 a contender when we have the same level of support and tooling for it as we have now for Silverlight.

Windows Home Server 2011–Update Rollup 1 Connector Install

Having just upgraded my WHS server to WHS 2011 (post coming soon) , installing the connector was next on my list of things to do.

The original connector that ships with 2011 worked like a charm on both desktop and laptop.Then Windows Update kicked in and installed UR1 sometime last night and thus caused havoc this morning.

Now, in the spirit of voodoo trouble shooting, there are a number of things people have done to get things working again.

Please note that I’m just some computer guy doing some stuff. If this doesn’t work or screws your PC up, don’t hold me responsible. Proceed at your own risk.

Firstly, try restoring to a pre-Connector state and restart. This should give you a clean slate to install the new UR1 connector.

Secondly – Start or stop the NetTCPTransportService in services.msc (Control Panel-> Administrative Tools –> Services) and try installing again. You can restart before or after trying to install. I can’t remember precisely in what order I did that.

Thirdly, or in combination with the second step above, you need to fire up regedit and navigate to registry subkey HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control. There you need to modify and or create the DWORD entry ServicesPipeTimeout and set the decimal value to 100000.

Remember regedit is not for the faint of heart – you may want to backup your registry FIRST BEFORE messing around with it.

Restart and pray, possibly not in that order.

Some have suggested that the task scheduler service is a culprit on some Windows 7 and XP machines. The solution being to delete all the service cedentials and start again. The folder is located at: C:Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA-S-1-5-18. Please note that I did NOT try this.

One think that did irk me was that after successfully installing the Connector and restarting at the prompt, Windows logged in as user:_clientsetup_$. This is not a big deal as you can log out, switch user, click the “Other User” tile and enter your credentials that way. I’ll update this post once thats sorted.

The curious think here is that the laptop updated the connector and prompted me to restart with no trouble at all. Very odd.

More posts on the move to 2011 coming soon.

LINQ + Google Charts + MVC : Pie Chart

A couple of weeks ago, I pointed out a LINQ snippet that was running against the Google Charts API.

This week, I’m back with my implementation of  the Pie Chart.

I’ve started with the Pie chart because its relatively simple and will lay the foundation for dealing with the complexities of the other charts.

Building Blocks

Since this is MVC, I created a new ChartsService class in the Services namespace of the project.

If you look at the snippets in the original ACM article, you’ll notice an extension method called “SeparatedBy”. So our first task is to create this extension method.

There are, of course, a number of ways to concatenate a list of string with a separator. This being an exercise in LINQ, we are going to use the LINQ Aggregate method.

   
public static string SeparatedBy(this List<String> list, string seperator)
{ 
return list.Aggregate((current, next) => current + seperator + next); 
}

 

I’m sure that you’ll agree with me when i say that it’s a nice and clean approach to what could be a messy block of code.

However, that extension method will only concatenate the list of strings passed to it. Why is this a problem? Because we are going to want to concatenate lists of int objects as well. So that extension method will just not do. We  could do some fancy work with generics, but the simplest thing to do is to supply to an overloaded method that accepts lists of type int.

public static string SeparatedBy(this List<int> list, string seperator)

List<string> thelist = list.ConvertAll<string>(x => x.ToString());

 return thelist.Aggregate((current, next) => current + seperator + next); 
}

There is one additional difference between these and our original method – the call to ConvertAll. Rather than have a foreach loop that does the conversation, we simply supply an inline lambda function that gets executed against each item  in the list and returns a list of the desired type. Again, very clean.

 

So, armed with these extension methods, we can now declare our classes.

Data

Google charts offers a wide range of functionality and many different kinds of charts. Each chart has a host of differing options and settings available to it. So when creating classes to represting thse charts kinds we have to bear in mind that there will be unique functionality not common to other charts that will come up.

Charts logically are made up of a number of  smaller complements:  bar charts have columns, pie charts have slices and so on and so forth. So we’ll represent these first.


public class Slice
{
public int Value { get; private set; }
public string Legend { get; private set; }

public Slice(int value, string legend)
 this.Value = value;
this.Legend = legend;
}

} 

Lets first look at the Pie class itself now.

Pie Class


public List<Slice> Slices { get; set; }
public string Title { get; private set; 
public Double Height { get; private set; }
public Double Width { get; private set; }

public Pie(string title, double height, double width)
{
this.Slices = new List<Slice>();
this.Title = title;
this.Height = height;
this.Width= width;
}

We start by declaring a number of properties and a constructor. In the constructor we initialize our list of Slices. This is where we see a departure from the snippets of he ACM article.  We do not pass the slices into the constructor. Of course, this is an issue of style over substance. There is no reason why we could not have generated the slices before the creating the chart and then passed the slices.


public string Compile()
{
var tt = Title.Split(' ').ToList().SeparatedBy(' ');
var p = new List<string>(){
this.Slices.Select(slice =>slice.Legend).ToList().SeparatedBy("|"),
this.Slices.Select(slice =>slice.Value).ToList().SeparatedBy(",")};

return string.Format(@"http://chart.googleapis.com/chart?cht=p&chtt={0}&chs={3}x{4}&chl={1}&chd=t:{2}", tt, p.ElementAt(0), p.ElementAt(1), this.Width, this.Height)
}

This is where all the important stuff happens.

Line 3 properly formats the title by putting a + sign to signify spaces between words. Note that we are using the extension method we wrote earlier.

Line 4 creates a new list of strings, each string being the comma or | delimited list of values and legends. Using a List gives us greater flexibility later on when our implementation will handle multiple data series and legends

Line 8 uses String.Format to merge all this data into a url that we can use to call the Google Charts API with. For an explanation of what each of these parameters mean, see the Google Charts API Parameter List

 

ViewModel

Now, this being MVC, the way to display stuff is by using a ViewModel. So lets create one:


public class MonthlyReportsViewModel
{
public MonthlyReports Details { get; set; }
public Pie Chart { get; set; }
 }

The one property we are interested in here is the Chart Property.

Now that we have our ViewModel, we have to populate it. So, in our ActionResult method:


<pre>Pie chart = new Pie("This is my chart",200);
chart.Slices.Add(new Slice(25, “Slice 1”));
chart.Slices.Add(new Slice(25, “Slice 2”));
chart.Slices.Add(new Slice(25, “Slice 3”));
chart.Slices.Add(new Slice(25, “Slice 4”));
model.Chart = chart;
return View(model);

 

View

In our View itself, we’re going to have to render out the chart. Since the call to Google Charts API will return an image, we can simply do the following:


<img src = "@Model.Chart.Compile()" alt ="">

 

What one could do is to put the actual rendering code in a Helper Method and call the Helper Method from your view, like so:


@GoogleCharts.PieChart(@Model.Chart)

That, of course, further abstracts the code. It does have the advantage of being much cleaner and easier to do.

 

Conclusion

As you can see, using LINQ to abstract away the complexity of what your code is actually doing is not just the province of database code. One thing what I’ve enjoyed about working with LINQ is how code always comes out looking fresh, clean and crisp. Having worked extensively with LINQ and Lambda expressions, using foreach loops  to process Lists looks so much messier.

Next time, we’ll take a look at the somewhat more complicated Bar Chart. I’ll not cover every single possible piece of functionality, but I’ll cover the basics. All I want to show is how the foundation laid down today can easily translate over. My current implementation of bar charts is sufficient only for the limited functionality the app needs and nothing more. 

At some point in the future, I’d also like to implement Line charts.

 

Postscript

I must say that apart from working with LINQ, its been a very satisfying experience for me to implement a C# version of a web API.

There is GoogleChartsSharp on Codeplex that Implements a whole lot more of the functionality of Google Charts. I did indeed use it for a while before implementing it on my own.

So its been a satisfying experience for me to implement an API that allows me to work the way I want to work. Not only did I write something simpler and easier to work with, but I dropped a dependency in the process and that made me happier than I think its safe to admit. 

Writing against something requires you, the writer, to pay extra attention to the small details. It requires you to think of the relationship between your code,the web API  calls and the documentation that supports it. When one uses an already baked implementation such as GoogleChartSharp, its like working with a giant black box  you have no idea what goes on inside. And you really don’t want to know the finer details. But writing the API, you create a white box. And you HAVE to understand those finer details.

So while the LINQ is nothing special in and of itself,nothing earth shattering or ground-breaking, it is the experience and the satisfaction gained from it that makes this a worthwhile post to write.

The iPhone 4S: A Rose by any Other Name (a Response to Dan Gillour)

Dan Gilmour thinks Apple made a bit of a blunder by calling it the iPhone 4S rather than the iPhone 5 .

Sorry Dan, But I disagree completely.

On Google Plus I put the following argument forward:

I want to mention that Apple always thinks long term. They called it the 4S because:

  • Its convention – the minor versions (yes, this is minor, or we would have got a form factor change) always have a S appended to the name of the last major release.
  • Apple have something big on the horizon. They have big plans for the next major release of the iPhone. They want to reserve the "iPhone 5" name for that release.

The iPhone, the iPhone 3G and the iPhone 4 have all been major releases and have all sported form factor redesigns.

The iPhone 4S specs may seem to be major (in a parallel universe where all phone manufacturers but Apple went bankrupt in 2007), but they merely bring Apple to PARITY with Android.

The iPhone 5 is going to be the release that makes Android play some serious catchup.

Another important thing to note is that Apple would never every call it the iPhone 5 just because people want it to be the iPhone 5. I’m sure it was Steve Jobs himself who said something along the lines of “People don’t know what they want, they just think they do”, or words to that effect. People have no idea what they want out of an iPhone 5. People don’t know what they want until Apple shows it off to them and they go, “Yeah, I want that”.

Everyone is acting like Steve Jobs’ influence has gone. Nonsense. I think even Leo Laporte said yesterday that he got the impression that the reality distortion field was no longer there. What other company spends 53 minutes repeating what it announced at it’s last press conference and then spend half an hour on a new iPhone and Siri? Oh yeah, then announce as an after thought, “Yeah, we’re on Sprint”. That’s a Steve Jobs keynote if there ever was one,only without Steve. The only thing that changed was that we noticed it.

My bet is that’s it’s the same reason why Steve jobs wasn’t there: not major enough.

When there’s a One More Thing to announce, he’ll be there.

 

PS – Pardon the Shakespeare reference.