Wednesday, May 29, 2013

Privacy Policy

This Application does not collect any personal information

This Application does not connect to any online service

This Application does not contain any other features that could allow users to unintentionally share their personal information.

Wednesday, May 01, 2013

.html() stripping off form tags


Recently I have been working on jQuery and KnockoutJs a bit. A bit means, a lot. :) It has been really exciting times as I have been learning lot of stuff. There are also times where I pull my hair off. :)

I have a View which is a pure html file, with no bells and whistles, except the "data-bind"s for the Knockout. And I load it using .get{} and place it in a
inside a page. Kinda SPA we have in place.

.get ("/<SomeDir>/<Somefile.html>", function(data){
 
 $("#someDiv").html(data); 
 ko.applyBindings(new ViewModel, $("#formElement")[0]);
});
See the second line after the html placement? The ko binding, that is. The application crashes on the line. While debugging, I found that $("#formElement")[0] turns out to be "undefined". "formElement" is the
tag I have which wraps the contents in the html file. I was getting this only on IE10. I have no issues in IE8 and IE9. This really started bothering me. I looked around the internet and had no clue! I started debugging again, with my ultra modern debugging tool - alert() statements :). I place an alert statement right after the html placement. As:
.get ("/<SomeDir>/<Somefile.html>", function(data){
 
 $("#someDiv").html(data);
 alert($("#someDiv").html());
 ko.applyBindings(new ViewModel, $("#formElement")[0]);
});
This retrieved the html data that we placed in. What I saw really took my skin off! I saw that the
form tag (with id as formElement) had been stripped of! Yes, stripped off. Taken off! And that meant there was no "formElement" that got loaded in the DOM and hence the crash. I went hunting for answers again. And I found that I was not alone. Eventhough there was only one link which helped me: http://forum.jquery.com/topic/is-jquery-stripping-form-tags In HTML5, you cannot have a
tag inside a
tag. So, the html() strips the
tag out, without any warning! Thats bizarre. But thats what it does. In the article/forum post mentioned above, there are three workarounds:

1. Take out the "form" tag from the html file.
 This is the easiest and straightforward approach. But my case is different. I have validations in place, using jQuery UI Validation plugin. And that works only against "form"s.

2. Add a "form" tag in the beginning. Just before the opening "form" tag. Even though it would work, it seems like a hack to me. No, it is one.

 3. Use append() function instead of html(). Like,
 
$("#someDiv").html();
$("#someDiv").append(data);

Even though the 1st one is the right move, I would go with the 3rd one. Hope this would save hours of someone's life, as it did mine :) Have a wonderful programming day!

Seeding Junction Tables with EF Code First


My stint with Code First
My first stint with Code First was when I attended a code camp at Lebanon Valley. Mike Lukatchik (@mlukatchik) did a very energetic and informative session of Code First. He emphasized that code first is very useful in an agile environment. I kind of saw where it could be used, and I was very impressed with how he presented. But I should admit that Code First could be practical enough for a enterprise environment. I could almost hear the DBAs getting angry! :)

I was so impressed with Mike's presentation, that I invited him over to present the same session at the Central Penn .NET User Group's monthly meeting. Needless to say, it was one of the best presentations ever. Thanks, Mike!

What is Code First?
There are umpteen number of articles around Code First. But to give a simple answer, code first with Entity Framework is a technique where we create Entities first, instead of creating database objects. The database objects gets created by the Code First framework. If you are knew to Code First, I suggest you to take a plunge into this article -

Our Sample Entities
Now, let us dive into the core of the article. Suppose we have two entities - User and Role. And lets say, a User has more than one Role. And a Role could be shared among many Users. You are right - a Many-to-Many relationship. And, as you know, the Entities in EF are nothing but POCOs. Plain Old CLR Objects.

public class User
{
   public int UserId {get; set;}
   public  List Roles {get; set;}
}
public class Role
{
   public int RoleId {get; set;}
   public  List Users {get; set;}
}
Once you run the migration, the corresponding tables get created. Like the ones below:

--> Screen shot of tables in the database

Junction Table

Where is the relationship though, you may ask.

Well, do you see the collection of Roles entities in User entity? And do you see the collection of User entities in Role entity? The Entity Framework is smart enough to take these into account and create a "THIRD" table - a Junction table.


Note that the junction table DOES NOT have a corresponding Entity in our context. That is because we do not need it. We could use either User entity or Role entity to get the relevant collection data.

Seeding Data
Many a times, to test the application, we need seed data - test data, that is. The Configuration.cs file that EF creates, is used for placing the code to seed the data.

A Footnote:
In my new project, we use Code First. On my very first day, when my Technical Architect told me that we are using Code First,  all the slides and code from Mike's presentation poured in. Even if I didn't know the intricacies of Code First technique, I did not have a starting trouble - it just took 20 minutes of a sample code and little bit of reading to get into the groove. That was all because I had attended Mike's presentation.  Many of my programmer friends and colleagues do not see the benefit of attending a user group meeting or a code camp. Well, here is one! :) The biggest (and the lamest:)) argument I every hear is that "Oh, we wouldn't be using this technology… "… Well, you never know :)

Monday, November 05, 2012

Intellisense in VS2012 Express

I tried playing with the Visual Studio 2012 Expess for Windows 8, when I encountered thathe  Intellisense was off on my XAML window. It was on for C# though (I mean the code-behind).

All I had to do was to run the following at the VS command prompt:

devenv /resetsettings

And then just restart the Visual Studio. 

Friday, August 17, 2012

The new releases!

MS has released VS2012, Windows 8, and .NET 4.5 to MSDN subscribers! Time to grab them and get working!

Friday, June 01, 2012

Evening with Scott Hanselman


Disclaimer: If you are reading the post, and you are woking in ASP.NET, and if you do not know who Scott Hanselman is, then you have my sympathies. (Don't worry, living under a rock is sometimes more comfortable!)


As I had blogged earlier, I have learned quite a bit (maybe a little more) from Scott, all about ASP.NET. Not only ASP.NET, also about other things... When I started developing apps for Windows Phone, I wanted to develop Hansleminutes on it. For the ones living under the rock, Hanselminutes is Scott's weekly podcast. I got his blessings and set out to develop the app. The rest is history and the app is available for download in the marketplace.


I got the word from Andrew Schwam that Scott Hanselman was visiting Philly.Net UG. Well, should I miss it? I would be an idiot to do so! I registered for the event and there I was! yesterday, May 31st that is.


I reached P J Whelihan's in Blue Bell PA (around 2 hours drive from my place) where Philly dot net had arranged a social networking event. I got to meet lot of familiar faces and also some known figures in Philly dot net community.


I was in Montgomery College, at around 6:15 PM, but Scott was running late because of his flight delay in Chicago, due to the thunderstorm. He made it finally, and it all started. It was a delight seeing him in person, live. After seeing a ton of videos and demos of him presenting, I had got used to his speaking. But seeing him in person was something I could not explain in words.


After the session, I met him and introduced to him. And there it is, me standing with Scott.




Scott, thanks for coming down here.
Thanks to Philly.net for getting the show together. And Apprenda for sponsoring the event.

It all started here....

Inspired by Scott Hanselman's post :

She let me take the computer home. - How did you get started in computers and programming?



Rewind to 1985-1986.

I remember that day when my English teacher, Mr. Jaganathan, announcing the arrival of a computer in our school. That was during our 10th grade exams, and so we had no way of making time to go to the lab (which was setup in a different building) to see it.

I had read very little about computers back then. Just that they could do some marvellous things. Yeah, just that. And I was just eager to see it. Thats all.

My 10th grade exams got over (finally!), and my Dad enrolled me into a computer course, which was held by an institution located very near my house. It was a very basic course, and it was just to have fun with computers and to know them. The instructor introduced me to GW-BASIC. I could draw a house, a car, and what not, just by giving instructions to the computer. I was amazed by the experience. It went for some weeks and the course got over.

As computers were not part of the curriculum, I didn't pursue it further. But those days in the institute are crystal clear in my mind. I had so much fun, even when I did not know the inner workings of a computer program and logic and all...

Fast forward to 1992-1993. I was almost completing my bachelor's degree in Physics. Peer pressure  mounted to try Medicine (MBBS degree) and/or Engineering, both for which I was not interested. All I wanted to do was to write Civil Services and become a IPS (Indian Police Services) officer. My Dad had other plans. He convinced me to do higher studies in Computer Science (he said it was the future, which I am living it, thanks to him) and I got enrolled for MCA (Masters in Computer Applications) program in Bharathiar University.

I didn't exactly know what I was getting into. I was very much privileged and honored to have very supportive classmates, seniors and teachers (who became my very close friends). My senior friends advised me to spend the "free" times in the library and read all the computer related books I can. The first few tries were futile, as I did not understand a bit of what the articles in it were relating to. I still remember one of my senior friends and then mentor, Biju, telling me to continue spending my time in the library reading those books as it would make sense after a while. Wasn't that golden words?

It all started making sense, slowly. And the 'computer bug" got into me. The possibility of designing an idea and then implementing it, instantly, was very satisfying!

(Lesson learned here: Read all you can. Do not stop learning. You stop learning, and you are a dead mouse!)

While in college, I had done my summer internship in Tata Consultancy Services. It was for their product in Oracle 6.x. Once I finished my MCA course, I got into TCS as a full time employee. I spend 5 years in TCS. What a schooling it was! I learned quite a bit about Software Engineering those days, that I still apply to my day to day activities. But it is sad that most of the companies I worked for, are not at par with TCS's Software Engineering quality those days. I was in TCS when our home office got CMM Level 5 certification. That is when I learned that software engineering was more than just coding. This was 1998 my friends, many years ago, and most of you were on diapers :)

We have come a long way in engineering methodology and all, but, as I said before, I feel terrible when I see companies not giving the value to software engineering that we used to provide many many years ago in TCS.

Years passed by. I moved on. Different companies. Different projects. Different languages. Different architectures. My love of computing never died. And never will.



Words of Wisdom (:)):
Programming is an intellectual pursuit. If you don't think so, maybe we shouldn't talk to each other.

Cookies, anyone?

  Our application started having integration issues early March this year. Did I say that was intermittent? To add to our confusion, we coul...