Monday, January 25, 2010

Find the static methods on an object using powershell

[System.IO.Path] | Get-Member -Static

That "-Static" part took me way too long to find. My Google-Fu needs work.

Saturday, January 23, 2010

Week 4: Head to Head Tic Tac Toe

I've completed Tic Tac Toe head to head. "Complete" is of course relative. Right now, there are still serious usability issues, but they are all UI work. The back end and ajax calls won't need to change.

Same URL as last week. :)

How to scroll a textarea to its end using JQuery

var myHeight = $('textarea#TextArea1').height();
$('textarea#TextArea1').scrollTop( myHeight );

Tuesday, January 19, 2010

Week 3: Simple Chat integrated with MVC

The leap from simply having an MVC 2.0 project integrated with Sql Server to having the project do something moderately useful was a bit more work that I expected. Not that any bit is hard, mind you, but the sheer number of bits was interesting.

Bit 1: ASP.Net Web Services is different from WCF Web Services is different from MVC. Maybe if I hadn't come late into the web programming game, that would have been a bit more obvious. I had previously set up a simple program to act like a chat program using a JQuery/javascript web client and an ASP.Net Web Service back end. Once I tried to move the ASP.Net web service into my MVC project, I realized that well, you can't do that. An ASP.Net web service is its own project. Forcing them together seemed like a bad idea. It turns out it is a bad idea. MVC enables returning pure JSON to an ajax enabled web page, so in retrospect, that is the way to go, but I hadn't stumbled upon that piece of information yet, so I put a WCF Web Service in the MVC project and got it working. There were a number of gotchas in setting up the Web Service correctly and also aligning it with the correct JQuery syntax.

Bit 2: Connecting Entity Framework 4.0 to an external Sql Server. This was straight forward, and in retrospect, everything I did with the EF was straight forward. In retrospect that is. Being a total noob in EF cost me some time, but I'm becoming a huge fan. Note that I'm talking about EF 4.0. Not the single earlier version.

Bit 3: Hitting F5 is different from browsing to your site through the internet. The first time I hit it from the internet, it didn't pick up any of the stylesheets or the jquery files. So it wasn't very functional. I had to share the folders in windows explorer before it would allow them to load. I spent much time futzing with IIS settings hoping the answer was in them.

Bit 4: I don't know how the Publish menu item in the solution explorer works. Oh sure it looks cool, push one button and your web site is automagically made externally browsable. But setting up a Publisher or whatever it is has eluded me for the 5 minutes that I've allotted to investigating it.

Bit 5: I don't know how to get MVC 2.0 deployed on my web server. My web server is of course, a virtual machine running Windows 2008 R2, but theoretically, that shouldn't matter. I've also failed to deploy SqlServer on my virtual machines.

I have resigned myself to using both SqlServer and MVC 2.0 on a real machine. So I pointed IIS at the directory where my VS 2010 MVC project is, and it all seems to work for now.

Week 3

Sunday, January 10, 2010

Week 2: MVC integrated with Sql Server

This week looks quite unimpressive. I have simply integrated the IIS authentication with Sql Server. So it uses a Sql Server database and not a Sql Express database. There were a few hangups that kept this from being a trivial exercise.

1) I couldn't install Sql Server on one of my Hyper-V machines.

I would get most of the way through the installation process and then it would fail, with "an external component has thrown an exception." I tried several variations, including virtual machines and real machines, virtual drives and real drives. All were on Athlon dual core machines.

Eventually, I gave up and installed Sql Server on my dev machine, which is an intel quad core.

2) I had to prep the Sql Server as descrbed in this article: How To: Use Forms Authentication with SQL Server in ASP.NET 2.0.

The salient bit is that one has to run aspnet_regiis.exe. This launches a wizard that does most of the work.

3) I had to make sure that the local user that had the same name as the domain user had the same password locally and on the domain, even though I explicitly specified the domain user. Confused? Just don't have a local user with the same name as a domain user and you shouldn't have to worry about this.

I wish I hadn't floundered so much getting this all set up. I'm still not happy with the set up since I want the whole thing deployed in virtual machines and it isn't right now. Next week I should have the boggle, chat, and MVC working together.

As for now, they are separate:
MVC integrated with Sql Server as the backing for Forms Authentication

Boggle Clone



And the Chat program isn't exposed yet. :(

Saturday, January 2, 2010

Chat program

This week, and I think I'll try to write an application per week, I wrote a very simple chat program using JQuery, Entity Framework, and Sql Express. I'd put up a link to it, but I've spent the last two nights trying to get it deployed. I finally decided that it isn't worth it. The goal was to write the application not spend an infinite amount of time fiddling with IIS to get it deployed.

The actual application is still quite rudimentary. Just a few text boxes on an HTML page. The server side, while simple, should elegantly suffice. The single function takes username, message, and a conversation guid as arguments and returns the entire conversation. I figure that should continue to work at nearly any scale.

JQuery and Ajax are still very cool.

Entity Framework was also mostly painless. I'm rather impressed with it and will be using it again soon.

Some problems that I encountered during this week's exercise:
1) How do you get a text box to scroll to the bottom in HTML and Javascript these days?
2) Deployment was a total failure.

What's Next?
1) Use MVC 2.0 to log in and capture the username automatically.
2) Tic Tac Toe in JQuery
3) Figure out how to get any of this .Net 4.0 stuff deployed.

Tuesday, December 22, 2009

Boggle - Fun with JQuery

I've gotten my first JQuery application running. It's a boggle clone.

The dictionary is taken from hunspell. The Hunspell dictionary as it is, didn't allow me to search on the start of a word, only the whole word. So, to ensure that the board could be solved within a human lifetime, I only searched the words up to seven letters in length.

The timer counts down, but never actually stops.

It might be fun at some point to make it player versus player, and to have words longer than 7 letters.