Wednesday, December 10, 2014

Properly serving SVG files in IISExpress

If you just edit your web.config file it will actually break your website under IISExpress. Instead, follow the instructions found here: http://tomasmcguinness.com/2011/07/06/adding-support-for-svg-to-iis-express/
  • Open a console application with administrator privileges.
  • Navigation to the IIS Express directory. This lives under Program Files or Program Files (x86)
  • Run the command appcmd set config /section:staticContent /+[fileExtension=’svg’,mimeType=’image/svg+xml’]



Wednesday, November 05, 2014

Git line ending fixups revisited

I blogged about this a few years ago. I discovered how to do this when using .gitattributes, which is automatically created when you use Visual Studio to create a project that uses git as its version control system.

I have a .gitattributes file that contains (among other things) this line at the top:
The sequence of commands is the following:

First, add all changed files: Then, edit the .gitattributes file to comment out the "text=auto" line and save this file: Then issue this command to un-stage all the files. It doesn't matter whether some of the files have meaningful changes. You're not resetting or undoing any file edits, you're merely removing them from the index: Finally, restore the "text=auto" line in your .gitattributes file and save that file: You should be all set. If you issue a git status command again you should see only the files that have meaningful changes, if any.

Friday, September 26, 2014

Beyond SOLID: The Dependency Elimination Principle

http://qualityisspeed.blogspot.com/2014/09/beyond-solid-dependency-elimination.html
Last post I explained why I don't teach the SOLID design principles. Read the post for more detail, but the primary reason is that SOLID encourages heavy use of dependencies. Applying SOLID to a codebase for even a short time will yield dependencies on abstractions everywhere -- quickly producing a codebase that is unintelligible.

Friday, September 05, 2014

git cherry

My mnemonic for git cherry, i.e. git cherry upstream [head]

My quick understanding is that in many cases it means: show me everything that's NOT in upstream.

In other words:

git cherry branch-without-stuff branch-with-stuff

or

git cherry less-stuff more-stuff

or

git cherry present future

or

git cherry past present


So to see what's in develop but not yet in master, type this:

git cherry master develop

Which means, essentially, show me everything in develop that's not (yet) in master. 

Wednesday, August 20, 2014

Strongly-typed function callbacks in TypeScript

The question: http://stackoverflow.com/questions/14638990/are-strongly-typed-functions-as-parameters-possible-in-typescript
In TypeScript I can declare a parameter of a function as a type Function. Is there a "type-safe" way of doing this that I am missing?
My favorite answer: http://stackoverflow.com/a/24034429/53107 from Drew Noakes:
Here are TypeScript equivalents of some common .NET delegates:
interface Action<T>
{
    (item: T): void;
}

interface Func<T,TResult>
{
    (item: T): TResult;
}

Renaming a remote branch in Git

I don't quite understand this, but I'll post it here anyway. It comes from StackOverflow user sschuberth.

git push <remote> <remote>/<old_name>:refs/heads/<new_name> :<old_name>

Example:
git push origin origin/hotfix/Cant-load-assembly.0:refs/heads/feature/Fix-cant-load-assembly :hotfix/Cant-load-assembly.0

Source: http://stackoverflow.com/a/21302474/53107

Friday, June 20, 2014

Git - Refreshing a repository after changing line endings

Who knew? My repositories sometimes contain problematic commits that are just about fixing up line endings, but here's a solution to that from GitHub. (I haven't tested it yet.)
Refreshing a repository after changing line endings
Here's the StackOverflow post from which GitHub gets their answer. There's also something interesting about removing the index, which I never knew about.
Trying to fix line-endings with git filter-branch, but having no luck

Thursday, April 10, 2014

Use Date Based File Archiving with NLog

My quick and dirty way of doing it. The target tag is the most relevant part if you're already using NLog.

Wednesday, April 09, 2014

My Favorite .NET Code Decorations a.k.a. Attributes

[MethodImpl(MethodImplOptions.Synchronized)]

The method can be executed by only one thread at a time. Locks the instance or, for static methods, the class.

[EditorBrowsable(EditorBrowsableState.Never)]

Hides a method from Intellisense.

Thursday, March 27, 2014

Migrate away from MSBuild-based NuGet package restore

Very nifty trick. In the end, your solution will look like the following. Note the .nuget folder has only a NuGet.Config file:


Link: http://www.xavierdecoster.com/migrate-away-from-msbuild-based-nuget-package-restore.
Here are the instructions on how to undo it: http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore. Note: where the article says "using TFS," read it as "using version control" because the instructions also apply to Git.

Update 4/4/14: You might have to close the solution and delete any .suo files or Visual Studio will stubbornly bring back the .csproj settings that you deleted.

Update 4/9/14: This doesn't appear very stable when using version control features where you backtrack in history -- for instance to merge a feature branch. Visual Studio stubbornly resurrects the import and target tag in the project file, and killing this won't work unless you first close the solution and delete the .suo file.

I'm actually considering moving back to NuGet package restore. At least it's reliable.

Second update 4/9/14: This doesn't play well with ReSharper's cool feature where it automatically adds NuGet packages to a project instead of just a reference.

Tuesday, February 18, 2014

How to do a rebase with git gui

Who knew? I thought it wasn't possible, but apparently it is if you modify git config.

http://stackoverflow.com/questions/4830344/how-to-do-a-rebase-with-git-gui

Add this to the .gitconfig file in your home directory to add rebase commands to the Tools menu:
[guitool "Rebase onto..."] cmd = git rebase $REVISION revprompt = yes [guitool "Rebase/Continue"] cmd = git rebase --continue [guitool "Rebase/Skip"] cmd = git rebase --skip [guitool "Rebase/Abort"] cmd = git rebase --abort [guitool "Pull with Rebase"] cmd = git pull --rebase

Wednesday, January 29, 2014

AngularJS Dependency Injection Cheatsheet

I finally get it. A cheatsheet for AngularJS dependency injection is as follows:

var somethingController = angular.module('What_it_provides', ['what', 'it', 'depends', on']);

somethingController.controller('Name', ['$what', '$it', 'depends', 'on', function('$what', '$it', 'depends', 'on') {
    // implementation, which returns a value, presumably.
}];

The core Angular dependencies (those in ng) are not listed in the angular.module() call, but they are listed in the .controller() call and in the function signature.

The 'What_it_provides' name seems to be used by the dependency injection framework in calls to angular.module(), i.e. the provider name, e.g. SomethingService. But the name would just be Something.
The 'Name' name seems to be used in parameter lists of implementation functions and in calls to controller(), factory(), etc.

See the example from the AngularJS tutorial step 11.

Friday, January 24, 2014

My git alias configuration

[alias]
        tree = log --graph --oneline --decorate
        st = status