Windows 7 cursors in Windows 8

I upgrade to Windows 8 at work (my Win8 dvd is sitting at my house for me to get around to it for my home pc) and the new hyperlink cursor I felt looked really stupid. Well someone else thought that too and fixed it.

Windows 7 cursors in Windows 8.

 

Advertisements

Renaming a group of files

Today I needed to do a mass replacement of file extensions to a different extension, this is very painful to do in Windows from anything I could see.
In the past I’ve used DIR to get file names and then excel to create a bat file of ren file.foo file.bar to be able to be expanded to every file, very painstaking.
Today i decided I would use powershell, should be alot easier, started looking up how to do it and instead found: ReNamer by Denis Kozlov. This tool gave me what I needed within seconds! It’s free for personal use, paid for commercial (don’t know how much there’s only a contact form about it). It lets you set up rules to do all kinds of things, I only need a very trivial setup, 1 rule “replace foo with bar” and to uncheck ignore extensions.
It even gives you a preview of the intended changes!

Nuget package creation harmony with Visual Studio

Over a year ago I opened a post on Nuget’s Codeplex detailing how creating packages, to put it bluntly, just sucked. Nuget has gone through several major releases since then. With current state of Nuget, it’s exceedingly easy to create projects that manage their nuget package creation automatically.

Steps to reach harmony

  1. Right click the solution root in the solution explorer < Enable Nuget Package restore (this should create you a .nuget folder that has nuget.exe in it)
  2. Right click the project you wish to turn into a package, properties and goto the build events tab
  3. In the post build event command line enter:

    “$(SolutionDir).nuget\Nuget.exe” pack “$(ProjectPath)” -Verbose -Properties Configuration=$(ConfigurationName)

Save the project changes, then build your project and you’ll see your packages dropping out in the relevant Bin\Debug or Bin\Release folders!

BloggingContext.ApplicationInstance.CompleteRequest();

DateTime.ParseExact “R” the liar liar pants on fire API aka how do I make Response.Cache.SetLastModified work right

I generally have orders of praise for .NET (most specifically C#) and it’s immensely robust CLR.

Today I had to resolve bugs that have exist in the .NET API since atleast 1.1 if not earlier, this is just stupid.

When you’re working with Http Caching and the method

Response.Cache.SetLastModified()

This will emit a date over the wire effectively doing:

DateTimeUtil.ConvertToUniversalTime(date).ToString(“R”)

This returns us a date string similar to “Sat, 01 Nov 2008 19:35:00 GMT”.

Now the major major GOTCHA:

#FAIL DateTime.ParseExact(“Sat, 01 Nov 2008 19:35:00 GMT”, “R”, CultureInfo.InvariantCulture)#FAIL

will not actually parse this exactly. It will give you some other invalid time because of bugs in handling timezones.

The proper way to parse this is:

DateTime.Parse(“Sat, 01 Nov 2008 19:35:00 GMT”, null, DateTimeStyles.AdjustToUniversal);

Very deceptive, very deceitful of an API. Details explained at length on MSDN

BloggingContext.ApplicationInstance.CompleteRequest();

Donut Output Caching in ASP.NET MVC 3

Came across this today, Donut Output Caching in ASP.NET MVC 3. This project seems to solve all of the problems that you would encounter with ASP.NET built in OutputCache if you attempted to use it with MVC3. The builtin output cache is very unhelpful for real world MVC applications.

PM> Install-Package MvcDonutCaching

BloggingContext.ApplicationInstance.CompleteRequest();

Lync sign in error – personal certificate

So today I sat down at my chair at work and saw I was signed out from Lync. We use office365 (it is hotness) here at work, and was rather perplexed with the error message “Cannot sign in to Lync There was a problem acquiring a personal certificate required to sign in. If the problem continues, contact your support team.”

Called microsoft, and the answer was an extremely strange one but very trivial.

Click the gear to open options, on the personal tab, click advanced, set it to manual.

In the internal/external host addresses enter: sipdir.online.lync.com:443

Connect, all should go well.

Click the drop down next to the gear, file, sign out.

Click the gear, personal, advanced, set it back to automatic.

Sign in and the problem for me atleast was resolved.

Hopefully I’ll save some of you out there on the interwebs the 20 minute support phone call with Microsoft and just fix it yourselves. As to why this occurred, my only guess is Microsoft updated some SSL certificate or host IP that didn’t perk through properly for everyone where connecting to the server directly caused the SSL to refresh…. or something. I always love the or something answers.

BloggingContext.ApplicationInstance.CompleteRequest();

Elmah.MVC nuget

I figured since I haven’t been writing much I’m better off posting microblog posts instead of nothing. I came across this package today, Elmah.MVC by @alexbeletsky.

This made things so trivial to setup with Elmah. This is how I will configure all of my future MVC3 applications with Elmah as it takes literally 1 minute now.

(assuming the Nuget package manager console)

PM> Install-Package elmah.xml

PM> Install-Package Elmah.MVC

Uncomment the authorize attribute

[Authorize(Roles = "Admin")]
public class ElmahController : Controller {

Done.

I find only the XML version of elmah to be worthwhile. However at some point I might try out the Sql Server Compact edition. I require that my error logging solution not depend on external resources like an external sql server database because if the database goes down you lose even your error logging capability which defeats the purpose.

BloggingContext.ApplicationInstance.CompleteRequest();

Cassette for javascript and css minifying and combining

It’s been another long time since I’ve updated my blog. However this project definitely deserves a shout out. Cassette is the best CSS & Javascript minifier/combiner I’ve ever seen. Almost every other project has felt extremely lacking to me in one way or another but with Cassette it doesn’t.

After seeing the wide assortment of choices it’s finally clear Cassette is king. I hope work can be done to improve Cassette to end the high level of fragmentation among the projects. The wiki is a little bit confusing and documentation very sparse. For new users you want to start with the documentation following the migration to 0.6. This discusses the current version of Cassette and not outdated documentation that is not relevant to Cassette any longer.

Why can’t I a have string? aka Nullable<string>

It’s not often that I write a post to rant about something that is by design and not actually a bug or just hard to accomplish end but something that really bothers me is the fact I can’t declare a string nullable.

The number one response to that is ”surely you jest as string is already nullable. Which obviously it is, however it’s also created to behave as a primitive type. This being the case makes it the only primitive type you can’t declare as nullable. Once again people usually will re-iterate, ‘exactly, it’s already nullable.’

If string is nullable, why can’t I preform .GetValueOrDefault()?

This is one of the most useful methods available as it easily let you establish frameworks around your primitive types without ever once needing to worry about triggering a null reference exception. It also clearly defines all objects that you expect to be able to be uninitialized and null. This is why I hate that strings cannot be nullable, it’s impossible to tell the intent of the string. Is null an accepted value because it could imply string.Empty? This always has to be handled by convention and validation there’s no way to clearly define this, whereas if you could declare string? this would definitively tell you that null is an expected value and acceptable.

To further my proof is the static method on the string class, string.IsNullOrEmpty(string). This method was placed here because the C# team clearly knew that strings being complex objects treated as reference types is very ambiguous and knew to expose a standardization on how to check this. Why would none of the other classes provide a type.IsDefault(type) method? So in my conclusion I should be able to do string? and sadly I can’t and I guess would have very little regress other than perhaps downloading mono and probably needing to alter the source code for itself.

Great Blog on URL Rewriting with URLRewriter.net

It’s been a while since I posted anything and I came across this great post on Run Tings Proper, Advanced url rewriting for the rest of us – how to create a custom transform in UrlRewriter.net.

This is a great post that really sumarizes the most common needs in URL rewriting and how to handle it with URLRewriter.net (does anyone else find it ironic this website is php, of course I suppose it could be php in asp.net) while I didn’t try out what was on here yet or download the demo it definitely all looks right. At some point I wanted to implement an URL rewriting scheme in my applications and this post will be a great help when I actually start on that.