mha.dk

Random thoughts of wisdom - the personal blog of Michael Holm Andersen

ViewData and the null-coalescing operator

If you’re using ASP.NET MVC and are using the ViewData collection you might want to familiar yourself with the ?? operator.

The ?? operator is called the null-coalescing operator and is used to define a default value for a nullable value types as well as reference types. It returns the left-hand operand if it is not null; otherwise it returns the right operand.

Knowing this we can use the below syntax to e.g. display the title of a page in the browser with a value from ViewData and if this is null instead display a default value.

<%= ViewData["title"] ?? "Home Page" %>

MSDN has more info about the ?? operator.

Nice way to show off swimsuits

Take a look at http://avanteswim.com/09 if you want to see a creative use of Flash and video to sell / show off Avantes swimsuite collection of 2009

Google Calendar checker

Just a quick note: If you’re using Google Calendar, make sure to install the latest (BETA) version of Chrome and install the Google Calendar Checker :-)

chromecalextension

Enable Hibernate In Windows 7

My new Windows 7 install would not hibernate (which is really a nice feature, especially when hibernation is awesome fast using a SSD disk).

Anyways, after a bit of fiddling I found the solution – to enable hibernation do the following:

1. Open Command Prompt (with Administrator rights if UAC is enabled).

2. Next, type: powercfg /hibernate on

3. Close the Command Prompt .. you now (maybe!!) is able to hibernate (I was not)

… so if you can’t see the Hibernate option in Start menu then:

4. Launch Power Options from Start menu / Control panel

5. In the left pane, open the link labeled “Change when the computer sleeps” and then open the link “Change advanced power settings”.

6. Under the Advanced Sleep options, expand the Sleep tree and turn off Hybrid Sleep.

… and now in the Start menu you should see the Hibernate entry.

Chrome now support Extensions

…at last – Chrome Extension support is active and I for one have missed Xmarks synchronization (which luckily is one of the first to be released). Find your favorite extension at:

https://chrome.google.com/extensions

Windows 7 Libraries - Using network share locations

By default Windows 7 will not let you use a network share in “Libraries” unless it is either available offline (which kind of deny the purpose of a network share!) or it is indexed.

However, using some good old DOS/Shell tricks you can easily use network shares in “Libraries” anyway .. here how:

1. Create a folder on your hard drive inside c:\temp
2. Create another folder in the above folder called i.e. “myData” (c:\temp\myData)
2. Link the Library to this folder.
3. Delete the “myData” folder
4. Use the mklink in an elevated command prompt to make a symbolic link. Name the link the same as the folder you created above.
i.e - mklink /d c:\temp\myData \\server\myDataShare
5. Done. Now you have non-indexed UNC path as a library.

Google by default using “personalized search”

Google have changed the way they show their search results. In “the old days” (about a week ago!) Google only showed personalized search results if you were logged into your google account.

However this have changed. Google now always (even when the user is not logged in) now uses personalized search. If you’re working with SEO this – of course – changes the way things work (but that another story!), however .. when working with SEO you of course DO NOT want Google to use (show) personalized search (results).

So in order to turn this “feature” off we need to do this:

1. Go to WWW.GOOGLE.COM

2. Do a search

3. In the upper left corner, click the “Web history” link

4. Click the link “Disable customizations based on search activity.”

That’s it .. you’re now back to the “good old days” :-)

Assign a Shortcut Key to the Snipping Tool in Windows Vista

This one is mostly for myself (a reminder to do this on all my PCs):

http://www.howtogeek.com/howto/windows-vista/assign-a-shortcut-key-to-the-snipping-tool-in-windows-vista/

Cool 1920x1200 wallpaper

If you’re looking for a nice wallpaper for your 24” (1920x1200) monitor and are a bit tired of all the Windows 7 “art-deco” type wallpapers, take a closer look at this:

colour-wood-flip

A coloured (kind of RGB) wood – the original image is in 1920x1200 – click to download: