Wednesday, August 20, 2014

Strongly-typed function callbacks in TypeScript

The question:
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: 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>

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


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


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


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:

Here are the instructions on how to undo it: 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.