Many Niches

Jack of All Trades, Master of Some

How To Hate on Friends and Piss off Colleagues

February 11th, 2009 by Brandon Watson

It’s been a while since I have posted anything about motorcycle racing.  The pre-season testing has finally started, and while I am excited to see Hayden on a Ducati, it would appear the Bologna rocket is not too impressed with the former World Champion.

In reading one of my favorite sites (Kropotkin Thinks), I read this note about Honda introducing rev limiters for their satellite teams.  You see, in the world of racing, you have the haves, and have nots.  The privateer teams generally understand that they are never going to be contending for the win.  Unless they have Tony Elias on the throttle or some Japanese wildcard who is really riding factory equipment (Nori Haga, 1998 anyone?), you have no shot at being on the box.  None.  This is such a predicament that there was talk of running a separate championship within the MotoGP championship.  You know, to have a trophy ceremony for 10th loser.  I’m not dropping hate flakes on the privateers, but you have a choice to run in the series, and you choose to lose to the factories.

With that in mind, however, Honda probably had enough of Andrea Dovizioso crashing the party late in the season.  This year, the boys at Honda will have none of that non-sense.  In the name of “reducing costs” and “maintaining engines for longer life spans,” the satellite teams will find themselves with detuned engines.  Honda basically gave them the finger.

Even better, because there is talk of requiring engines to last 2 weekends in the 2010 season, Honda will be using the satellite teams as logistics testing for the 2009 season, ensuring that parts get where they need to go.  That would be the second finger.

The way Honda treats riders (see Rossi and Hayden departures and the tangled stories of pain they told post exit), and now how they treat their satellite teams, it’s any wonder anyone wants to work with them.  It’s too bad they can field so many bikes, and the green boys have to leave the series and the blue bikes were close to bowing out, if not for the amazing run of Capirossi and Vermuelen at Sepang.

Posted in Motorcycles | No Comments »

Customer First Design

February 4th, 2009 by Brandon Watson

I came across this article on the birth of Amazon EC2. Buried in the middle is this gem:

…in the amazon style of "starting from the customer and working backwards", we produced a "press release" and a FAQ to further detail the how and why of what would become EC2.

Before one mockup, diagram, line of code, or anything had been done, they wrote the FAQ and the press release. Customer first design makes things very black and white during a dev cycle.

Posted in Uncategorized | 1 Comment »

ASP.NET MVC – Passing Data Around

February 4th, 2009 by Brandon Watson

I’ve made no secrets of the fact that I am n00btaculous with regard to ASP.NET.  The first week or so with the MVC was pretty painful for the simple fact that the available information online is somewhat dated.  That sounds weird when talking about something that hasn’t even shipped yet, but here’s what I mean.  If you do a search for “ASP.NET MVC”, you will find that some of the links head off to Scott Guthrie’s blog.  This is a good thing, since he’s the big cheese here at Microsoft responsible for a great many things, including MVC.  Here’s the problem: that link is from a blog post in late 2007.  As a n00b, I’m wasn’t sure whether or not anything has changed, especially since we are now at a release candidate for ASP.NET MVC, rendering the code samples useless in my mind.

With that in mind, I have been scrabbling around looking for information.  To quote Jaime Escalante, I was “like a blind man, in a dark room, looking for a black cat that’s not even there.”

It turns out that the ASP.NET site completely redid the samples that they had for MVC, which is pretty awesome when you think about it.  Head’s up, it’s easy to get lost in the site and not find the “new hotness.”  You want this link to their MVC content, and not this link off their “Learn” tab.

Now, to the task at hand.  With the Controllers and Views, you can separate your data from the presentation.  Awesome.  How do I get the data from Controller to View?  When I first started learning, it wasn’t clear that I could pass more than one piece of data, because most of the samples I saw had something along the lines of:

return View(data);

where “data” could be any single object.  As with any function, you wouldn’t expect to be able to return multiple objects.  So, n00b that I am, I was trying to create all kinds of complicated structures to pass different data back.  For example, I did something like:

List<Dictionary<string, int>> myData;

and proceeded to dump data into this complicated structure.  Don’t do this.  I then tried to create custom classes for returning different sets data as one repository.  Please don’t do that.  There is a much, much simpler solution, which I missed in the tutorial sets, because it’s not clearly called out as to what they are doing.  You can pass whatever data you want back to your view, and label it.  I took advantage of this as follows:

ViewData["myDict1"] = myDict1;
ViewData["myDict2"] = myDict2;
return View();

Once you do that, your View can access the data as follows:

<% foreach (KeyValuePair<string,int>kvp in (Dictionary<string,int>)ViewData["MyDict1"]) %>
<% { %>
<%= String.Format("Key: {0}, Value: {1}",kvp.Key, kvp.Value) %>
<% } %>

You can replace the “myDict1” with “myDict2” if you want to access that data set.  The data structures can be whatever you want – I just used two dictionaries for illustrative purposes.

Posted in N00b Notes | 2 Comments »

ASP.NET – Membership Hides Its Privileges

February 3rd, 2009 by Brandon Watson

One of the problems I have had thus far with my foray into ASP.NET has been a simple concept.  How do you deal with users logging in.  Not so much the actual mechanics of it, but where is the data, and how can I get to it?  By default, when you are using forms based authentication, that data is stored in tables that you cannot easily get to, and certainly not in the Solutions Explorer.  Essentially, nothing is showing up in your “App_Data” node, and there is no .MDF file to add from your project directory.

What then are you to do when you want to have direct access to your membership tables from within Visual Studio?  Well, let me walk you through the steps, as I did them, to achieve this.  I won’t say that this is the official way, but it’s what worked for me.  I hope to save you some of the pain and suffering associated with my searching on the web to find these answers.

Create your new project

This is self-explanatory.

Turn on forms based authentication

This is accomplished by editing your web.config file.  Look for the following:

<authentication mode="Forms">
  <forms loginUrl="~/Account/Login" />
</authentication>
Run the ASP.NET Configuration

It’s important that you don’t look for this option (under the “Project” menu) when you have the web.config file as your open window.  It won’t be there.

Add A User

Click on the security tab, and from there you can manage your users.  Add one.  One time when I did this, I saw the following error:

The following message may help in diagnosing the problem: Could not find stored procedure ‘dbo.aspnet_CheckSchemaVersion’.

The annoying bit was that when I tested the connection, through the tool, it was able to successfully establish a connection.  Wonderful.  I am not sure how I fixed this the one time I hit it, but I wanted to throw it out there as a potential issue.

The Unfun Complicated Bit

So, this is where having a friend on the dev team is important.  I had read one of the tutorials over at asp.net which had content on this topic. They tell you to run “aspnet_regsql” from a Visual Studio command prompt.  If you do nothing else, know this: if you are using SQL Express, your server that you want to connect to is in the form of <machine name>\sqlexpress.  If you get that wrong, this tool will fail.  Always.  That’s roughly two hours I just saved you.

I am not sure what this tool did that this command line bit didn’t do for me (courtesy developer friend).

NAVIGATE TO:

C:\Windows\Microsoft.NET\Framework\v2.0.50727>

RUN:

aspnet_regsql.exe -d "<path to project dir>\<projectname>\App_Data\ASPNETDB.MDF"

With the following options:

-A all -C "Data Source=.\SQLEXPRESS;Integrated Security=True;User Instance=True"

If everything goes according to plan, you will see:

Start adding the following features:
Membership
Profile
RoleManager
Personalization
SqlWebEventProvider
…..
Finished.

If not, you will see many errors. This broke for me when the ASPNETDB.MBF file was not already there.  It showed up for me only after I had successfully built and run the project and added a user.  The asp.net mvc default app has a new user wizard, which I could also use (which I did when I hit that stored proc error above in “Add a User.”  Of course it worked, and I don’t know why.

Add the Database File

In the Solutions Explorer Window, right mouse click, and select “Add/Existing Item.”  Select ASPNETDB.MDF.  Careful that you don’t select the _log file.  I did that.  Don’t do what I did.  Fail.

There you go.  A step by step, “how the hell do I get my user tables into my project so that I can edit them” tutorial.  Hopefully this saves some poor unsuspecting n00b some time.

Posted in N00b Notes | 1 Comment »

 
© 2009 Many Niches Powered by Wordpress