A classical musician turned programmer... or something

Recently installed Visual Studio 2013, and was shocked to find out that, by default, web projects aren't supported, unless you check the "Microsoft Web Developer Tools." There's an extra 30 minutes of my life I wish I could get back :)

In Visual Studio, how many times a day must I click the Reload All button? Switching between many branches a day, this has definitely worsened with the increased usage of git. Apparently the git + VS plugin is supposed[?] to help this, but in my minimal testing of it, it just doesn't cut it performance-wise.

So, how many times you ask? Doesn't matter. Anything > 0 is too many.

Hello friends! It's been a while, but I've been busy! Since you last heard from me I have switched gigs (still a .NET shop), switched locations (Cambridge!) and started a metal band: Vrawsche.

In the programming world, been working a lot lately on Backbone/RequireJS and Jasmine unit testing... and C#/ASP.NET MVC, all really hot stuff...

Oh, and I'm also on github now!

This is a neat trick that you can use if you're not using Visual Studio 2010 yet. It allows you to have multiple web.config files for each type of build configuration that your project has. No longer do you have to do any sort of copy/paste. Plus, if you use something like MSBuild in CruiseControl.net, it will work there too (if you're building from the sln file)!

You will need to create two additional web.config files. I name them like this web.buildConfiguration.config where buildConfiguration is Debug, Release, etc. Each of your new config files will contain the settings appropriate for the build configuration you are targeting.

Open your project properties and select Build Events. Under the 'Pre-build event command line' paste this in :

if $(ConfigurationName) == Release copy $(ProjectDir)Web.release.config $(ProjectDir)Web.config
if $(ConfigurationName) == Debug copy $(ProjectDir)Web.debug.config $(ProjectDir)Web.config

when you build, your web.config will be replaced with the correct one for _that_ build configuration.

I'm going to start a series of posts tagged [Beginning], to try and help new programmers, or anyone with an interest in programming understand concepts using real-world examples.

The first in this series, value types and reference types.

So, what is a value type?
msdn says:

Variables that are based on value types directly contain values.

more value types at msdn

And, what is a reference type?
msdn says:

Variables of reference types, referred to as objects, store references to the actual data.

more reference types at msdn

that's like defining the word the word, right? It seems like that's what everyone says for both... I think we can do better.

In simplest real-world forms:

value types are like money, cash, dinero, coin, dough...

you got the cash in your hand, now go buy an LCD TV!

reference types are like personal checks...

you got something in your hand, but you have to walk to the bank and turn that piece of paper into real money. (Now you can get your LCD TV)

Here's a quick little one-liner I use all the time.

It will create a concrete instance that implements 'I' interface. This has a string as a parameter, but there are lots of other possibilities (and overloads for Type and CreateInstance).

But, be careful with this, you can easily get into trouble, as the magic happens at runtime, so watch your speeling.

public class Activator<I>
    {
        public static I Create(string s)
        {
            return (I)System.Activator.CreateInstance(Type.GetType(s));
        }
    }

Tags:

Here are my favorite Firefox add-ons

Web Developer tool bar (gotta love Ctrl+Shift+f)

Firebug (the best javascript debugger and more)

Html Validator (great for seeing all your awesome htmlz c0dez)

Sqlite Manager (the version for Firefox 3.5 is much improved)

Greasemonkey (custom scripts)

Modify Headers (I use to test other user agents)

Live Page Rank (get google page rank for the site you're on)

Search Status (lots of SEO goodies)

Add n Edit Cookies (easily add and/or modify cookies)

Remove Cookies for Site (removes cookies only for the site you're on)

ColorZilla (eyedropper tool to get any color on a web page, in an image, or html)

refspoof (change the referring url)

YSlow (figure out why your site is slow :( )

Hackbar (test your site with various sql injection strings)

So, to begin, the following has NOT happened to me, but I wanted to make sure people understand why public computers and certain browser features can be bad... very bad for you.

Let's say you sign in to your email account on a public, or unfamiliar computer. The machine asks you to save the password for that site, and silly you, chooses to accept. OK. So, now you've finished your work,you haven't erased your tracks, and the next person comes along... if the next person comes to the same email provider that you have visited, they'll see something like this :

username
password

yikes

So yeah, they can login as you, see all your mail, perhaps other sensitive information in emails...in short, they can find out a lot. If they were really naughty, they would just do this in the address bar and get your password :

javascript:alert(document.getElementById('Pass').value);

without looking at the src code on this page, you can try it here and see what I've set as the password above.

What can you do? Well, here are 5 safety tip for using a public computer.

Tags:

Year after year you know you have a product that will be updated at a[round] a certain month. It happens a lot with my business domain. Rather than changing lots of text, this should work nicely for my needs. (I didn't use any timezone or culture considerations)

the pivot month is the int that decides when we flip to next year.

/// <summary>
/// Figures out if should use this year 
///or next based on a defined pivot month.
/// </summary>
/// <returns>4 digit year</returns>
public int YearPivot(DateTime dt, int pivotMonth)
{
     return (dt.Month <= pivotMonth) ? dt.Year : dt.AddYears(1).Year;
}

couple tests showing it in action...

DateTime dt = new DateTime(2009, 10, 1);
//returns 2009
Assert.AreEqual(2009, m.YearPivot(dt, 10));
//returns 2010
Assert.AreEqual(2010, m.YearPivot(dt, 5));

Tags:

I work for a fabulous company, I've been with them for about 3 years. They are incredible about making sure developers have what they need to get the job done, whether it's software or hardware (or classes, or books). In fact, I'm on my third development machine! Most software requests are usually also granted.

So what does your gear look like? What development software has your company gotten for you to help better your work?

This is what it looks like for me:(as of posting)

Hardware:

  • Windows XP 64, core 2 quad @ 2.5 GHz, 8 gigs of ram
  • 3 19 inch widescreen monitors
  • microsoft natural ergo keyboard
  • trackball mouse
  • physical server 03 box [for testing]
  • various XP/03 virtual machines [more testing]

Software:

  • Resharper 4
  • dotTrace
  • NDepend
  • NCover complete
  • RegexBuddy
  • BareTail Pro
  • All the microsoft dev. stuff (VS 03,05,08, SQL server 05,08)
  • Snag it
  • ultramon

What about you?

kick it on DotNetKicks.com

About Brian


profile for bluevoodoo1 on Stack Exchange, a network of free, community-driven Q&A sites

Brian Canzanella brings you nifty tips and tricks for most things .NET. read more...

Readers / Stuff