The Joel Test: Still Relevant

Came across this while surfing the internet today and believe it is still as relevant today as it was 14 years ago.

Check out The Joel Test: 12 Steps to Better Code and see how well your team is doing. 

Mine is not doing so well so we have a lot of work to do.

Display User Full Name using Windows Authentication In MVC

It has always bugged me that the default Windows Authentication MVC template just displays the users domain\user instead of the persons full name. Here is how to create a Razor Helper that will display the full name.

Create the Razor Helper Extension by adding a App_Code folder to your solution and then creating a View.  The name of the view will be the identifier user after the @ symbol in your view.  I named mine MyHelpers.cshml just to keep it simple.

The contents of MyHelpers.cshtml

@using System.DirectoryServices.AccountManagement
@helper UserFullName()
    {
        using (var context = new PrincipalContext(ContextType.Domain))
    {
        var principal = UserPrincipal.FindByIdentity(context, User.Identity.Name);
        if (principal != null)
        {
            var fullName = string.Format("{0} {1}", principal.GivenName, principal.Surname);
            @fullName
        }
    }
}

You may have to add a reference to System.Directory.AccountManagement.  Also be sure to set it to Copy Local.

Now modify the _Layout.cshtml

Old Version

<section id="login">
    Hello, <span class="username">@User.Identity.Name</span>!
</section>

New Version

<section id="login">
    Hello, <span class="username">@MyHelpers.UserFullName()</span>!
</section>

Your new header output now looks like this.

image

Now that was easy!

Highway.Data Drivers Ed: Getting Started Video

The Highway.Data Team has just published a great video explaining the concepts and usages that you need to understand to get you up and running quickly.  The Highway.Data Drivers Ed series is designed to help answer many of the questions that the team has received or encountered ourselves.  It will cover basic to very advanced usages.

This Episode 3 in the series contains information about the following:

  • Patterns: 0:00
  • Getting Started: 3:16
  • Queries: 7:01
  • Scalars: 10:21
  • Commands: 14:22
  • Advanced Queries ( SQL based, and Projections): 16:58
  • Eager Loading: 20:56
  • What is IDomain?:22:22
  • Testing with Highway: 27:17
Highway.Data Drivers Ed Episode 3

Add Category Picker to Outlook 2010 New MailItem Ribbon

Recently I have started using Outlooks Categories to organize my emails.  It has made like much easier, I set a category on the received email, move it to the archive.  I have created custom search folders that look for that  category.  That way no matter where the email is it always shows up in the search results.  Except for outgoing emails.  I have to go into the Sent folder and set the category.  So, I set out to figure out if  I could set the category before I send the mail, thus saving me a step.

I found the following information on SuperUser.com in the thread In Outlook 2010, can you add “Categories” to the “New Email” Ribbon? 

Create a Macro, because believe it or not Outlook doesn’t not have the Category button available when you try to customize the ribbon.

  1. Open the Visual Basic Window (ALT + F11)
  2. Add a Module (Right-click “Modules” folder –> Insert –> Module
  3. Copy the following code into the module

    Public Sub CategoriesButton()
    
         Dim Item As Outlook.MailItem
    
         Set Item = Application.ActiveInspector.CurrentItem
    
         Item.ShowCategoriesDialog
    
    End Sub

  4. Close the editor

Now to add the macro to the menu

  1. Click the “New E-Mail” button
  2. Right Click –> Customize Ribbon –> Drop Down –> Macros –> Select “Project 1.CategoriesButton and add to a new group.
  3. Rename the group, and Menu item and add Icons if you wish

Thanks QBIK for posting this for all to enjoy.  I am posting to make it easier for me to find this in the future.  Thanks again QBIK.

Add ?Sleep command to Executor

I searched StackOverflow and Google to find out to set my laptop into Sleep mode from the command line.  There were tons of solutions and tones of failures.  I wanted to keep a record of the one the worked for me so here it is.

I wanted to add a ?Sleep command to my favorite launcher application Executor from http://executor.dk.  Like I said earlier there are a lots of opinions about how to do this.  I choose to use SysInternals psshutdown command.

So, I added a new keyword ?sleep with the following parameters:

Command: c:\_path_to_sysinternals\psshutdown
Parameters: –d –t 0
Open as: hidden 

Now I just fire up executor with my shortcut and type ?sleep and enter to set my laptop into sleep mode.

Others say that without turning hibernate off it does a deep sleep and takes longer to restart and will not restart with any key but only the power key.  Not sure about the deep sleep but I do have to kit the power key to wake the laptop up.  I am ok with this since I tend to hit keys on the keyboard when I don’t intend to.  Make the wake up process more intentional.

Calendar

<<  September 2014  >>
MonTueWedThuFriSatSun
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

View posts in large calendar

Month List

AuthorList