source code bean

When Rails 3 was released a coworker was very excited about it and he convinced me to give it a try. I have tried different version of Rails 1 and version 2, but at the time something about it didn’t really feel right to me, so I decided to stick to PHP for my own web projects and .NET for my professional work.

My coworker recommended to read the tutorial on http://railstutorial.org. After giving it a try and playing around with some applications for about 2 months now, I must say that I am really impressed. Everything in Rails is super streamlined for developing web applications.

Setting up your development environment is actually quite easy, no matter what OS you are on. I have tried both on my Mac and on my Windows 7 machine. Let me show you how to set it up on Windows:
Read the rest of this entry »

07 Dec, 2010

How to backout a merge in Merciural

Posted by: Peter In: Version control

Recently we ran into a problem when a coworker accidentally merged the wrong branches and pushed this onto our main repository. Everyone on the team is relatively new to Mercurial (this is the first bigger project we are using it for), so i asked the guys on Stackoverflow how to backout the merge from the repository.

Several people contributed with some really good solutions, read more here if you are interested.

Two weeks ago I went to the EPiServer Meetup where Bartek Tatkowski talked about EPiServer and CI. This got me inspired to write about how we do CI and deployment in my current project. The site we are building is an EPiServer 6 CMS Enterprise site based on .NET 4.0 and ASP.NET MVC 2.0 (I blogged about it back in April). When we started the project we had very clear goals regarding CI and deployment:

  • The build process should be totally automated
  • Building the site should result in a release package
  • The build server should run unit tests, code analysis and test code coverage every time the build is run
  • The deployment process should be totally automatic (for the test environment and for the production environment)
  • It should always be possible to rollback an update (files, database, IIS-settings, etc.). Rollback should also be fully automated.

I am very happy to say that we have fulfilled all our above goals, let me tell you have we did it.
Read the rest of this entry »

Microsoft WebDeploy (MSDeploy) is a very useful tool, not only for deploying web sites. In this post I will show you how MSDeploy can be used as a tool for synchronizing local and remote folders and executing commands on a remote server.

Read the rest of this entry »

13 Nov, 2010

Understanding output in PowerShell

Posted by: Peter In: .NET|Powershell

Lately I have been programing quite a lot of PowerShell. The release of PowerShell 1.0 in 2006 and more recently version 2.0, is probably one of the best things that has happened to development on the Windows/.NET platform for a long time (even though it takes some time to get used to the “wackiness” of PowerShell ).

What is really interesting with Powershell is that is is fully integrated with .NET, everything is PowerShell is .NET objects, which makes it very easy to use existing .NET DLLs from PowerShell. In comparison to most other scripting languages I have used, instead of just being able to pass text between different scripts, PowerShell takes a more powerful approach and allows for passing .NET objects between the scripts.

Read the rest of this entry »

04 Oct, 2010

Entity Framework 4 – Code First

Posted by: Peter In: .NET|C#

Entity Framework 4 itself is interesting but what really got me hooked was the CTP 4 preview, and what Microsoft call “Code First”. Code First allows us to describe our model using regular POCO classes, instead of designing our model using either the EF editor or creating in directly in the database.

Read the rest of this entry »

06 Jun, 2010

Two new features I really like in PHP 5.3

Posted by: Peter In: PHP

Namespaces
Finally PHP has support for namespaces, not one day too late! Before the days of object oriented PHP name clashes for functions was usually prevented by adding a prefix to your function names. When object oriented PHP was introduced function name clashes was less likely, but class names still had to be unique, ie you could only have one class named for example “User”. This led to the need of prefixing class names. From PHP 5.3 we no longer have to do this!

Read the rest of this entry »

Recently I started a new assignment at a customer where we are going to build their new public web site and their intranet, both of them based on EPiServer CMS 6. The person leading the project is very found of ASP.NET MVC, so my first task was to experiment with EPiServer and ASP.NET MVC, to try to get a running prototype up.

I did some research online to see what others had done. I found two great posts by Joel Abrahamsson and one from Fabio Fabrizio, who based his solution on Joels experiments.

Joels first attempt was to create a base class from which all Controllers inherited. However, this made the controller do more than it should and made it very hard to test. His second attempt was to create a custom model binder and make every action receive currentPage as a parameter. This approach makes it much easier to create unit tests for the code, since it is now possible to moc the currentPage parameter.

Fabio took a different approach and decided to implement a custom MVC handler and a controller factory. This approach fits very well with MVC and felt like the right way to go, so I decided to create a prototype based on Fabios code. Fabios code was based on EPiServer CMS 5 and ASP.NET MVC 1.0, but I wanted to use EPiServer 6 and ASP.NET MVC 2.0, so I started porting the solution.

Porting the solution to EPiServer 6 and ASP.NET MVC 2.0 required some changes to both code and configuration, which not all of them was trivial. At the moment I have a prototype up running, and it works remarkably well! I will continue my experiments and post my results.

Recently I got a request from a customer to perform some search engine optimizing for an old EPiServer site we are maintaining. One of the optimizations was to fix the paging on their product page. The products are fetched from an external data source and are not stored as pages in EPiServer, thus normal EPiServer paging controls can not be used. Image a normal paging control like this:

Prev 1, 2 , 3, …, 99 Next

A fairly normal approach to this would have been to use a query parameter for handling the paging. Like this:

  1. <a href="/products/?page=4">4</a>

By using this approach each page would have a unique entry point, using query strings is however not optimal for SEO, but even worse is using asp:LinkButtons. Read the rest of this entry »

08 Mar, 2010

Trying out CouchDB for the first time

Posted by: Peter In: NoSQL

CouchDB is a document-oriented database written in the Erlang programming language. It is a NoSQL product designed for local replication and to scale vertically along a wide range of devices.

There are several good libraries that will abstract accessing CouchDB from various programing languages. However, in order to understand what goes on in the libraries, I think it is important to first understand what is going on on a lower lever, so that is what I will show you.

Read the rest of this entry »

About

Welcome to source code bean! On this site I post stuff that I encounter in my job and spare time. The content is mostly related to .NET development, but my interest in techonology is very broad, so often you will find posts on totally different subjects!