Recap my online year 2012

The year 2012 was for me a year that went way to fast. In the year 2012 I learned a lot new stuff, wrote several blog posts and read lots of blog posts and articles. First of all I want you to give a list of all blog posts I wrote this year. You can find the complete list here http://marcofranssen.nl/2012/ and here http://marcofranssen.nl/2012/page/2/.

JavaScript:

Windows 8:
Windows Phone:
Powershell
I even wrote a non-technical article:

Second I want to share my starred articles from my reading archive. I used pocket to bookmark, read and archive my articles, which enables me now to share all starred articles with you. Continue reading

Knockout JS mappings

Knockout JS is a JavaScript library for creating MVVM JavaScript libraries. In a previous post I already showed some of the cool features of Knockout.

http://marcofranssen.nl/2011/09/13/knockout-that-cascading-dropdown/

If you want to spike your knowledge on Knockout a little more first, please visit Knockout’s documentation.

In this article I want to zoom in on the Knockout mapping plugin. The Knockout mapping plugin enables you to easy map your JSON object into an observable JavaScript object. So here is a short example of what you’ll be able to do with it. So when you do an ajax request and receive a JSON result you can for example do the following.

Continue reading

Windows Phone Theme colors

Phone theme colorsWhen developing Windows Phone apps I love to use the theme accent colors in my apps. Since there are some new theme colors in Windows Phone 8 I started searching for their color codes. Lucky me I found them on msdn.

Now you may be thinking how to use the colors in your own Windows Phone apps. The Color object doesn’t contain a color called Emerald. So I created a small class to help me out with this issue. First of all I created a small static helper method to convert the hexa colors to a color object. So we are able to put in the hexa color string and the function returns a color for us.

Then I made some properties that caches the colors for us on their first use. The Color properties looks like this. Continue reading

Unblock downloaded files with PowerShell

Have you ever got in the situation that you downloaded a zip-file and figured out to late the files are blocked? So you extracted the zip file into a folder with existing items. It will be damn hard to figure out which files needs to be unblocked. Besides that it will cost you many work to do so by right-clicking all of the files and clicking the unblock button.

Luckily we have PowerShell and we can easily write a little script to execute the unblock operation on the files in a specific directory. So start by opening PowerShell and key in the following command.

gci  ’c:\Somefolder’ | Unblock-File -WhatIf

The above command will unblock all the Child Items in the given directory. The WhatIf parameter will actually not execute it really, but it will show you what the script is going to do. To really execute the action you have to remove the parameter.

gci ‘c:\Somefolder’ | Unblock-File

As you may have seen when using the WhatIf parameter, only the files in this folder will be unblocked. What if you want to unblock the files in the sub folders. This can easily be done with the Recurse parameter on your path.

gci ‘c:\Somefolder’ -Recurse | Unblock-File -WhatIf

Because I used the WhatIf parameter again I can pre-check what the command actually is going to do. When I’m sure I want to do it I can just remove the WhatIf parameter again and run the script against the files.

gci ‘c:\Somefolder’ -Recurse | Unblock-File

So now you wont have to worry about files being blocked just execute the script and you’re ready to go. Bookmark this article to easily access the commands when you need them and share it with your friends to make their lives also a little easier. Oh and don’t forget to have a look at the ‘PowerShell Getting Started Guide‘ for more information on using PowerShell.

Install Windows 8 from rusty 256 MB USB stick

This is the fourth time I installed Windows 8. This time I installed it on my personal notebook instead of a VHD, because Windows 8 is finally ready to market. So I started with downloading the enterprise edition from my MSDN subscription. Unfortunately my USB drive died so I had no storage large enough to put the image on and boot from. So I started thinking to install it over the network. Luckily me I still had my rusty 10 year old 256MB USB drive which perfectly fits a Windows PE image. So I also downloaded the Windows 8 ADK to make a Windows PE boot image.

First install the Windows 8 ADK. Then open a command prompt and, key in the following commands to create a image.

mkdir c:\winpe_amd64
call copype.cmd amd64 c:\winpe_amd64
Makewinpemedia /ufd c:\winpe_amd64 F:

The first command makes a directory on your c:\ drive and can be removed afterwards. The second command creates all the necessary files for a 64 installation. The third command copies the files to your usb drive (in my case F:) and makes it bootable. If you need a 32 bit installation replace amd64 with x86.

Then create a share on a pc in your network and extract the contents of the Windows 8 iso to the network share. Make sure you configure the security to allow everyone to access it. Also make sure your firewall responds to ping commands, this comes in handy when trying to connect to the share. I created a share called Win8. Continue reading

Secure your web app fluently

When building a big web application with ASP.NET MVC 3 I ran into a problem to secure my web application in a maintainable way. There are lots of examples with attributes, but this isn’t maintainable. So I started searching for other solutions, however most of the information is leaning on those un-maintainable attributes I finally found “Fluent Security“.

What does Fluent Security offer you?

Fluent Security provides a fluent interface for configuring security in ASP.NET MVC. No attributes or nasty xml, just pure love. Go get it on NuGet!

What does that mean?

Well it simply means you can bootstrap your security just from your Application_Start() and maintain it on a single place. Besides that you can easily unit test your security setup. So you can test if your security configuration matches the security setup you described in your unit tests. This is a huge advantage because you know for sure the controller actions are secured the way you like it without having the need to click through your complete web application. You can only fail when not defining your tests correctly. That’s not all… You can easily extend, modify etc. by adding your own implementations of the interfaces.

Let me start to show you some code so you see for yourself how easy it is! My example is based on a default MVC 3 application and I have added a CategoryController like below to have some extra actions for my example. Continue reading

Sokoban 7

Sokoban 7 is a classic puzzle game, the first version of Sokoban was published in 1982. Now it is also available on Windows Phone. The game includes 50 levels and will gain periodic updates with new levels. The game uses your phones theme, this way you keep the look and feel you like. The trial version doesn’t has any limitations. If you prefer to play without ads, please consider purchasing the game. Please let me know any feedback so I can improve the game. If you like to provide me a translation in your own language, don’t hesitate to contact me, so I can add it. Thank you in advance and share it if you like it!

Download

Download sokoban 7 from the marketplace

Screenshots

Shortify for Windows Phone 7

Always wanted to easily share a link on multiple social platforms at once, or just by email or SMS. Then install Shortify for FREE on your Windows Phone and start sharing your favorite webpages with your friends immediately. The application takes full advantage of your personal theme configured on your Windows Phone. So you won’t lose the look and feel you’re happy with while sharing your favorite webpages. Just try it out and let me know what you think about it. Please give me feedback so I can improve the app for your own goodwill and experience. Thank you and please share it if you like it.

Download

Download shortify from the marketplace

Screenshots

Delegate your equality comparisons

When using Linq on your Entity Framework objects, you often need to distinct your query results. Therefore you need to implement an IEqualityComparer for the more advance scenario’s. For example if you want to distinct on a specific property, or maybe on multiple properties. However this forces you to write lots of infrastructure code to distinct each type.

You probably would end up with several equality compare classes like this.

public class ProductIdEqualityComparer : IEqualityComparer<Product>
{
    public bool Equals(Product x, Product y)
    {
        return x.Id == y.Id;
    }

    public int GetHashCode(Product obj)
    {
        return obj.Id.GetHashCode();
    }
}


However there is a solution which will save you the work to write all this classes. You will have to write only two classes. One will contain some extension methods, the other is a DelegateEqualityComparer.

Now you can simply distinct your query by providing a lambda. I tried it on IQueryable, but this doesn’t work. Linq will generate some SQL to do the actual query. We didn’t specified any code that can translate the equality comparer to SQL. If someone figures out how to make it work with IQueryable please let me know.

Share this article if you found it useful.

Minesweeper 7

Today will be again a milestone for me. Today my first Windows phone app “Minesweeper 7″ got certified. This app is just a port of a minesweeper version I made once with winforms. It is very basic and simple. I focused most on learning Windows phone, Silverlight and applying as much metro style as possible. The game is completely themed by your Windows phone settings, so you won’t lose the look and feel you like when opening the game. I included a full featured trial, without any limitations compared to the paid version. So you may be asking why making a trial version when there are no limitations. Well very simple, the trial version contains ads, the paid doesn’t. It is available in Dutch, English and German language. If you like to make a translation in your own language feel free to send it to me by mail and I will publish an update in the marketplace. The next update will include some visual improvements. Also highscores will be added in a future update.  So have a look at it and have fun! Ofcourse rate it so I can make improvements.

Download

Download minesweeper 7 from the marketplace

Screenshots