Archive for the ‘Uncategorized’ Category
To whom it may concern
For the last four years, this country has been governed by an African-American president. A little more than four years ago, (soon-to-be) President Barack Obama excited a large variety of citizens of this country – particularly, the citizens that do not share the same racial or gender demographics as the previous forty-three presidents. We were excited by his charm. We were excited by his cool. We were excited by his race. More importantly, we were excited by his priorities, his promises, his resolve, and his confidence that he could lead this country into a much brighter, more just, and more united future.
That was then.
Today, I reflect back on the presidency of this man and I am amazed. I’m not particularly amazed by his policies or compromises. But, I am amazed at the cool way he has conducted himself in the face of a country that has shown a very hateful side of itself.
When the ink dries on the pages written about President Barack Obama, the record will reflect the uprisings of Americans that simply had enough. The books will reflect photos of citizens that united against this president, with signs scarred by hate-speech and caricatures of our president with exaggerated lips and ears. And, sadly, somewhere (not just here), a story will be written about the gas station in NC where a staged lynching of our president and other African-American men was put on display for all to see.
I don’t live too far from that gas station.
Today, I feel like me and my family were just threatened. In my head, I hear the voice of some of my more conservative associates reminding me that no law was broken by the person(s) responsible for this display. However, when I consider the intent of the messenger(s) and the history of Black Americans and lynchings in this country, I see this as an act of terror.
I see this as yet another very serious offense that will go unpunished, unexplored, and unquestioned. Why? Because it is not uncommon.
In turn, I’ll look to the current leader of these United States for something I can’t get from a Mitt Romney or Paul Ryan. I’ll look to him for an example of how a man could conduct himself in the face of hate. I’ll be cool. I’ll keep my charms. And, I’ll do the terrorists a favor by not being fearful or terrified.
On a nodejs kick today
I’ve recently increased my interest in nodejs. Today, I revisited a framework called Mojito by Yahoo. I first learned about Mojito on InfoQ.com, an awesome site for the IT-minded.
Mojito uses nodejs. It is a framework for developing applications in javascript. Interestingly, Yahoo also developed a project called Manhattan that serves as a platform-as-a-service for your Mojito applications – similar to Nodester.
As great as that all sounds, there is more! Check out this 5 minute demo by the lead engineer. It’s interesting stuff.
SEWDI (Someone Else Will Do It) Disease
What is it?
A productivity block that often affects the work of developers that habitually search and find solutions to technical problems.
History (feel free to skip to “How it affects us” below)
- traveling to a library that may not have computers
- learning and utilizing the Dewey Decimal system to increase efficiency
- identifying possible books and/or periodicals on the topic
- reviewing many sources to adequately research the topic and add depth to the research
- compiling the research into a format to be reused
- consuming and/or sharing the research
- open a web browser on one of the many computers available to us (even at libraries now)
- type a term or phrase into one of many search engines
- click on a few of the links that were instantly presented
- use what you learned and move on (no need to compile it or save it because we can always just search and find it again later)
In other words, research is relatively cheap and easy.
How it affects us
- Our search terms need to be refined
- The solution is not available … yet.
- refining our search terms
- asking colleagues how they solved similar problems
- or, distracting ourselves with a new problem until someone else solves the first problem – thus, this blog entry 🙂
Don’t let my face stop you from giving to a good cause
Hey You,
As you may or may not know, I’m participating in a very exciting event called Movember. It is when people everywhere set their own pride and vanity aside, and grow mustaches throughout November to raise money to help combat common Men’s health issues like Prostate Cancer.
One requirement was to start the month cleanly shaven. Here is me on November 2nd:
Here is what I looked like on November 11th:
If the whole purpose of Movember is to grow a mustache in order to raise awareness, I am failing badly. I can’t help it. My face just isn’t cooperating.
However, I still owe it to you, LexisNexis (my company and Movember team), to provide something that will raise awareness and money for the cause.
Without further ado, here are some pics of me with potential mustaches.
Obviously, I need help. I’m borderline desperate. Since my mustache refuses to work with me on this, please work with me on this. Checkout my Movember page and donate dollars to the cause.
UPDATE (11.18.2011)
.NET Devs: Make |DataDirectory| resolve to a path of your choosing
I’m working on a desktop application that uses and embedded database. In my case, I’m using Sql Server Compact Edition 4.0 with Entity Framework 4.1. This tip could also apply to usage of Sqlite. In my app.config file, I have a connection string that tells my application to put the database in the “Data Directory” by using a syntax similar to this:
<connectionStrings> <add name="DbConnection" connectionString="data source=|DataDirectory|\MyDb.sdf" providerName="System.Data.SqlServerCe.4.0" /> ...
In ASP.NET, the |DataDirectory| token would expand to an App_Data folder under the root of my web application. For desktop applications, it is the bin directory. But, what if I wanted to point to a different location?
It turns out that DataDirectory is a macro. It is resolved using the AppDomain. The following line of code allows me to set the DataDirectory path prior to using the connection string:
AppDomain.CurrentDomain.SetData("DataDirectory", @"C:\temp\data");
That would expand my connection string to: data source=C:\temp\data\MyDb.sdf
Code Camp Report
Name: Chicago Code Camp 2010
Where: Illinois Institute of Technology, Chicago, IL
When: May 1, 2010
My Talk
I had an opportunity to present at the Chicago Code Camp. My talk was titled, “Seven Habits of Highly Effective ASP.NET MVC Developers.” It is a long title derived from Stephen Covey’s best selling business book, “Seven Habits of Highly Effective People.”
Similarly, the content of my presentation was derived from the habits and principles that Stephen Covey introduces in his book. The difference is the technical spin that I apply to make these principles relate to the job of developing web applications using Microsoft’s ASP.NET MVC framework. I presented habits that we as developers should adopt in order to effectively begin and maintain our web applications over their respective lifecycle.
Surprisingly, this topic was very popular at the Chicago Code Camp. Initially, I was expected to present in a room that seated about thirty people. However, the room quickly exceeded capacity and I was asked to present in a larger room. The seats in the larger room were quickly taken, and some attendees sat along a window sill in the back of the room.
At the conclusion of the talk, I had some great discussions with a few people with questions ranging from organizational concerns to technical implementation. I was able to answer many of the questions or offer relevant suggestions.
Overall, I felt like the presentation was well received. The initial feedback available on Twitter gave me the feeling that the experience was a pleasant one. Here are some example tweets that I read shortly after the talk:
“Learned a lot from your MVC talk. Hopefully you can go to CVNUG code camp some day” – @cksanjose
“Highly Effective Habits of MVC Developers by Curtis Mitchell. This guy is crazy awesome” – @jonathanbaltz
“Liking the MVC presentation. The speaker is really up beat. Keeps you interested.” – @itsff
Talks I attended
Ioke ( by Ola Bini )
Ioke is an experimental language written by the presenter of this talk. It runs atop the Java Virtual Machine and it is inspired by many of the features in languages like Ruby and Lisp. It is a very impressive programming language. However, it is not intended for use in production applications. Ola Bini did mention he is working on a newer programming language. I am hoping the new language implements many of the features in Ioke, and become a viable language to use in production scenarios.
Limelight ( by Micah Martin )
Limelight is a framework written and actively maintained by Micah Martin’s company, 8th Light Incorporated. The framework allows developers to create desktop applications in the popular Ruby scripting language. In addition, the development experience is simple yet powerful. Limelight employs a web development-like paradigm. And, it makes deployment of these applications over the web very easy.
Micah also explained that Limelight applications should be considered rich internet applications (RIA) as well. He demonstrated Limelight links – a hyperlink that can be used to download and launch Limelight applications from a server. This eases versioning and maintenance of desktop applications because the deployed software is hosted on a server like a web application. And, users automatically get the most recent version when they launch the application from a web-enabled computer.
Making the web “F#”unctional w/BistroMVC ( by Scott Parker )
This talk focused on two things of interest to me: Microsoft’s newest .NET language, F#, and an alternative Model-View-Controller web framework, BistroMVC. The presenter was entertaining and very comfortable throughout the talk. He did a good job at targeting the “F# newbies” like myself and many others in attendance. The talk included a good introduction to F#. Unfortunately, due to time constraints, we weren’t able to get a good introduction to BistroMVC.
However, I learned enough to pique my interest in both technologies. I am going to definitely learn more about F# and do some more investigation into BistroMVC.
Web Testing with Visual Studio 2010 ( by Richard Campbell )
Microsoft released Visual Studio 2010 on April 12th of this year. They have put a lot of work into improving the features related to testing. Richard Campbell gave a very entertaining and educated talk on how to leverage a small portion of these new features to stress test our web applications.
Personally, I have been looking into some of the web testing capabilities of VS2010 from an automated integration test perspective. It was great to learn about and see the stress-testing features.
Richard is the founder of and Product Evangelist of StrangeLoop Networks. His company specializes in optimizing web applications. He demonstrated his expertise in the subject matter and delivered a great presentation on how to use VS2010 to make sure your web application can perform.
Conclusion
I am very happy I attended this event. There were approximately 550 registrants and slightly more than 300 attendees. The attendees, presenters, and organizers included notable leaders from the .NET community such as:
- Scott Seely, co-author of "Effective REST Services via .NET: For .NET Framework 3.5", founder of Friseton, LLC
- Micah Martin, founder of 8th Light Inc. and co-author of "Agile Principles, Patterns, and Practices in C#"
- Robert “Uncle Bob” Martin, author of "Clean Code: A handbook of Agile Software Craftsmanship", co-aurthor of "Agile Principles, Patterns, and Practices in C#", and founder of Object Mentor
- Rocky Lhotka, creator of the widely-used CSLA.NET framework
- Carl Franklin, co-host of the popular .NET Rocks podcast
- Richard Campbell, co-host of the popular .NET Rocks podcast
To name a few.
This code camp met my criteria of successful code camps. It was well-organized, supported by a great development community, consisted of diverse technological topics, and concluded with downright awesome giveaways. I hope I have an opportunity to attend future Chicago Code Camps.
Two ways to handle unauthorized requests to Ajax actions in ASP.NET MVC 2
Problem: I have created a view that posts to an action via Ajax with the expectation that the action will return the requested data or an empty string. Even better, I would like it to be configurable to return whatever value I see fit.
The problem arises when I decorate the called action with the [Authorize] attribute. If the request is not authorized and I have a loginUrl configured in my web.config, my ajax request will return the html output of my loginUrl view. That is undesirable.
Solution #1: I need to implement a custom ActionFilterAttribute that I can use on the ajax action to handle the request appropriately. Here is the code for my ActionFilterAttribute:
public class AjaxAuthorizeAttribute : ActionFilterAttribute { public string View { get; set; } private bool renderView; public override void OnActionExecuting(ActionExecutingContext filterContext) { if (!filterContext.HttpContext.Request.IsAuthenticated && filterContext.HttpContext.Request.IsAjaxRequest()) { renderView = true; } base.OnActionExecuting(filterContext); } public override void OnResultExecuting(ResultExecutingContext filterContext) { if (renderView) { filterContext.Result = new ViewResult { ViewName = View }; filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext); return; } base.OnResultExecuting(filterContext); } }
And, here is how I would decorate my ajax action in my controller class:
[AjaxAuthorize(View="AjaxAuthorizeError")] public ActionResult AjaxRequest() { return View(); }
That would handle the issue by checking whether the request is authenticated. If it isn’t authenticated and the request is being submitted via ajax, a specified view will get called. The content of that view determines what my ajax call will receive back when the request is not authenticated.
Note: There is no default view page being rendered if one is not passed to the ActionFilterAttribute. That’s room for improvement.
Solution #2: I can extend the existing Authorize attribute by inheriting from the AuthorizeAttribute class. Here is the code that extends the Authorize attribute:
public class AjaxAuthorizeOverrideAttribute : AuthorizeAttribute { public string View { get; set; } protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) { if (!filterContext.HttpContext.Request.IsAjaxRequest()) { base.HandleUnauthorizedRequest(filterContext); return; } filterContext.Result = new ViewResult { ViewName = View }; filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext); } }
Here is the decorator for the ajax action in the controller class:
[AjaxAuthorizeOverride(View="AjaxAuthorizeError")] public ActionResult AjaxRequest() { return View(); }
Note: Again, there is no default view page being rendered.
Changing the default Virtual Directory/[TARGETVDIR] name in a Visual Studio Setup Project
While working on a Visual Studio Setup Project for an ASP.NET MVC application, I ran into an interesting dilemma. The installer automatically uses the Title of your setup project as the default virtual directory value. From a user experience standpoint, it can serve as a visual indicator that this "virtual directory" is specifically for the application that you (the user) are installing.
However, it isn’t ideal. See, usually the title of an installer is human readable e.g. "My Application". However, I don’t think user would want their virtual directory to contain spaces since spaces typically get escaped to a hex value, making your site’s address http://someserver/My%20Application. Visual Studio Setup Projects do not offer a straight-forward way of editing this default value, except to edit your title to read "MyApplication".
There are a handful of solutions that have been conceived by various people that include passing command line arguments or using custom dialog windows that set the TARGETVDIR parameter explicitly – to name a couple.
For different reasons, none of the proposed solutions satisfied my dilemma.
So, here is what I did:
I opened the deployment project in notepad++ (a very handy text editor), found the line that says, "VirtualDirectory" = "My Application" and changed it to "VirtualDirectory" = "MyApplication". After saving the file, reloading it in Visual Studio, and building my installers, my dilemma was solved. I hope this is helpful to you as well.
Slides from Raleigh Code Camp 2009
This weekend, I had the pleasure of presenting a talk on Spark View Engine at Raleigh Code Camp (#rducc). It was a well organized event with a schedule full of great topics and presenters. The Triangle .NET User Group (TriNUG) did a wonderful job at organizing and running the event. Thanks, TriNUG!
As promised, I am posting the slides that I used in the Spark talk. Although the true context of the talk is not present on the slides, I hope these are helpful to someone using the Spark View Engine or considering it.
Stay tuned, or subscribe to the rss. I am planning to post a series of short to-the-point screencasts that demonstrate how to practically use Spark in your ASP.NET MVC application.
In the meantime, checkout http://www.dimecasts.net for some great videos on Spark.