Lance Larsen - .NET Architect Madison Wisconsin

Presenting at ThatConference!

“Have you fired up a new ASP.NET 5 project in the new Visual Studio 2015? Wow does that look different or what?!?!

What’s new in MVC 6? What is .NET Core? What is Grunt? What is Gulp? Bower? Npm? Rosyln? Why are there JSON confutation files? Why is Node installed? Where’s my project file? No System.Web? Runs on Linux and OSX???

Wow — there is a lot of new stuff — in fact ASP.NET 6 is one of the most significant architectural updates Microsoft has done with ASP.NET ever!

Have NO FEAR fellow camper, come join Lance and your fellow campers!

Together we will leave this Pow-wow able to face a new day of ASP.NET web development with a much better understanding of what new tools have been added to our Swiss Army knives!”

Here are files…

Presentation PDF
Presentation Power Point
Demo Code

imageFound this fact very interesting in this Yankeegroup Mobile Analysis… 

Had felt that this was the case, but good to see that I really need to focus more on game development… :)

( Download Code )

Was looking for a simple and elegant way to log some metric for methods (mainly method name, start time, stop time and elapsed time) – I’ve done this in PostSharp in my article “Holy Grail of Application Profiling with AOP” – but client wasn’t using them.

I’ve used reflection with success in the past, but was having some issues with Async methods not giving their real method names, was getting “MoveNext” instead — so sleuthed around for an alternative and found some awesome C# attributes that I’d never seen…

[CallerMemeberName] – gets the method name calling the attribute
[CallerFilePathAttribute] – gets the path to the C# file
[CallerLineNumberAttribute] – gets the line of the method in code

Combining those with the C# Stopwatch Class – and using the Dispose patter that I love because you can easily code the “using” statement around what you’re looking at ( see below ) – came up with the following cool code that – as always – I love to share.

Emphasis on elegant, to call this code – you can easily do the following…

using (StopwatchLog.Track())
{
   // Your code here...
}

It collects the information about executing method and logs metrics when the stopwatch log is disposed.

Read more

Surface Pro 3

A lot more Surface 3 owners out there as sales of the Surface topped $1 billion in revenue for Microsoft – so more tips for my primary development computer!

Screen Brightness Shortcut: Press “Fn” + “Del” to increase brightness, and “Fn” + “Backspace” to decrease brightness.  Love it. 

If there are more cool tips that others have – ping me, love to know them.

image As I always emphasize – invest in yourself first!  So attend education events, user group meetings, sent aside time specifically to learn, etc.

Today I drove down from Madison to Chicago area to attend a free Microsoft WebCamp event. Worth the ~3+ hour drive. :)

“The new release of ASP.NET and Web Tools for Visual Studio 2013 make it easier than ever to build cutting-edge websites – and once you create a beautiful, interactive site, you can quickly deploy and scale it with Microsoft Azure! … no-fluff events created for developers, by developers.”

For those in Wisconsin, there is another one coming up in Waukesha on March 24th 2015 – but I didn’t want to wait… :)

Click here to Register — and here’s the Source and Slides.

Thanks to David Giard, our Microsoft Evangelist for leading the event.

Twitter: @DavidGiard, Blog: http://davidgiard.com

Surface Pro 3

Firstly, love my new Surface Pro 3 – finally the tablet PC I’ve been waiting for!  Have all of my development tools; Visual Studio 2013, SQL 2014, etc loaded up and running very quickly.

As a developer in Visual Studio however I need to use the function keys more than using the shortcuts across the top of the keyboard – and didn’t want to always have to press “Fn” + “F5” – so looked for a solution and found one and wanted to share…

Function Key Lock Tip: Press “Fn” + “Caps” and now all the Fn keys work without having to hold down the “Fn” key! w00t

imageLove sharing little gems of knowledge – this is a good one for anyone using Entity Framework 5 and the new’ish enumerations (emums) inclusion in EF5. 

So working on a MVC5 Code First application for a project of my own – and had the following Model.

namespace GeoBucketlist.Model
{
    public enum TagType { Location, Bucketlist, Member }

    public class Tag : Base.Model
    {
        public long Id { get; set; }
        [Required]
        [StringLength(25, ErrorMessageResourceType = typeof(ResourceMessages), ErrorMessageResourceName = "LengthMax25")]
        public string Name { get; set; }        
        public string Description { get; set; }
        public TagType TagType { get; set; }
    }
}

When you auto-create the View templates for editing / adding that model in MVC through T4 templates – the html is as follows follows…

<div class="form-group">
    @Html.LabelFor(model => model.TagType, new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @Html.EditorFor(model => model.TagType)
        @Html.ValidationMessageFor(model => model.TagType)
    </div>
</div>

imageWhich then shows up in your pages as a plain textbox – not a good solution for choosing an enumeration value… :(

So simple but elegant solution is to change that line to the following… (Note, would be lovely if this was the default behavior for the @Html.EditorFor – but alas that is a blog article (and more work) for another day – but if anyone else has that complete, always loved to see great code!)

<div class="form-group">
    @Html.LabelFor(model => model.TagType, new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @Html.DropDownListFor(model => model.TagType, new SelectList(Enum.GetValues(typeof(GeoBucketlist.Model.TagType))))
        @Html.ValidationMessageFor(model => model.TagType)
    </div>
</div>

Good coding!

//L2

So AngularJs is pretty sweet – especially considering the power and elegance of how you can use “filters” to change the way values appear in the UI.  There is a built in “number” filter that you can apply to a number value and have it always display a set number of decimal places, i.e. “1″ -> “1.0″  But, we wanted a filter that did the following…

“1.56″ => “1.6″
“1.5″ => “1.5″
“1.0″ => “1″
“1″ => “1″

So I wrote a simple custom filter, setDecmial! 

As I love jsFiddle – here’s the live working version: http://jsfiddle.net/lancelarsen/Tx7Ty/

If anyone has suggestions for further improvements, always love to keep making the code better. :) 

<div ng-app="myApp">
    <div ng-controller="Ctrl">
        setDecimal Filter (1): <span>{{val | setDecimal:1}}</span><br>
        setDecimal Filter (2): <span>{{val | setDecimal:2}}</span><br>
    </div>
</div>

var app = angular.module('myApp', []);

app.filter('setDecimal', function ($filter) {
    return function (input, places) {
        if (isNaN(input)) return input;
        // If we want 1 decimal place, we want to mult/div by 10
        // If we want 2 decimal places, we want to mult/div by 100, etc
        // So use the following to create that factor
        var factor = "1" + Array(+(places > 0 && places + 1)).join("0");
        return Math.round(input * factor) / factor;
    };
});

app.controller('Ctrl', function ($scope) {
    $scope.val = 1.56;
});

Event

Dates

Location

Chicago Code Camp

April 26

Grayslake, IL

Kalamazoo X

April 26

Kalamazoo, MI

Azure Developer Camp

April 30

Chicago, IL

ALM Chicago

May 1

Chicago, IL

Virtual Hackathon

May 1- June 5    

Chicago and online

VSLive

May 5-8

Chicago, IL

Code For Rockford Brigade Kickoff

May 10

Rockford, IL

//PUBLISH Hackathon

May 16-17

Chicago, IL

//PUBLISH Hackathon – Milwaukee     

May 16

Milwaukee, WI

SharePoint Saturday

May 17

Addison, IL

GoTo Conference – Chicago

May 20-23

Chicago, IL

Codestock

July 11-12

Knoxville, TN

Iowa Code Camp

July 19

Des Moines, IA

That Conference

August 11-13

Wisconsin Dells, WI

Madison Ruby

August 21

Madison, Wi

Devlink

August 27-29

Chattanooga, TN

Chippewa Valley Code Camp

Fall

Thanks to David Giard {djgiard@hotmail.com} for compiling these!

imageLittle things make me happy…

Easy way to get the RGB value for images / web pages

Check out ColorZilla plugin for Chrome.