Archive for April, 2008

RE: Switching from Linux to Windows 2008

I’ve gotten so much feedback from my post “I switched from Linux to Windows Server 2008” that I think I need to clarify a few things. The responses have ranged from agreement to personal attacks. I’m impressed by the emotion of the people that really believe in their operating system. Personally, I’ve always tried to use each tool for different situations.

Most importantly, I’d like to explain why I wrote the post. I was simply sharing my personal experience, which may or may not be your experience. I know that Linux is very popular, and my opinion is that it is a superior operating system in many ways.

Now for a little history of my experience, which may help understand my feelings.

Confused!

Years ago I was running Windows 2003 for a home server. I was frustrated by the poor performance, high resource usage at idle, and tricky to configure. I have years of Windows experience, and I could never quite get it set up the way I wanted. I also wanted to avoid the cryptic Windows licensing, and their policy of locking you into the products of their choosing.

So, I built a brand new computer, and installed Ubuntu Server 64 bit edition. I spent weeks getting it configured (not continuously of course). I kept notes, and I was pleased at the fact that I could use a single command line to install pretty much everything I needed:

Sudo apt-get update; sudo apt-get upgrade; sudo apt-get -y install ssh subversion dovecot-imapd samba xinetd build-essential getmail4 p7zip-full ia32-libs mdadm bind

 

How cool is that!

I was very happy, except when things would go wrong. For example, 4GB of memory wouldn’t work with Linux, but anything less would. It turns out that I had to blacklist the “intel_agp” module. I really wish I could get back the hours of my time that were wasted. Am I any better for the experience? No. Can this happen in Windows? It certainly can.

Here were the additional problems I had, which subsequently wasted additional hours of my time:

  • The software RAID array would stop working 50% of the time when rebooting. It’s not fun having your heart sink when it says that there is a problem with the RAID array that all of your data is on (yes, I have off-site backups, but it’s still a hassle).
  • The VMware server console would not work when I reinstalled the host OS. VMware itself worked fine, and I used the “vmrun” command over Putty to manage my virtual machines. Believe me, that is not fun.
  • Samba was ridiculously slow. Try searching for samba optimizations in Google. Why isn’t the performance better out of the box?
  • Random network errors would appear on the server console. Sometimes the network would simply fail. Sometimes it took a reboot to get it working again. Simply calling “sudo restart /etc/init.d/networking” didn’t work.
  • Dual monitor support. Don’t even ask me how many times I’ve modified my xorg configuration file.

Could I have taken the dozens of hours and fixed all of these issues? Maybe. I did my due diligence and searched Google and the Ubuntu forums for help. I even posted my problems without getting answers. I’m certainly not against learning. I’m a software engineer by trade, so I would rather be spending time learning Adobe Flex, Silverlight, MVC frameworks, and new coding methodologies. Is it so bad that I want to choose what I want to learn?

I just want a solution to my problem that works with the minimum amount of hassle, so I can focus on what I enjoy.

That is my opinion, and you can’t say it’s wrong!

Recently I read quite a few articles about .NET developers switching to Windows 2008 as a workstation operating system. I took the leap and did the same. My experience has been very positive, and my opinion is that it’s a great operating system. I intend to write a post specifically about that in the future.

Because of the frustrations I was feeling on my server, I decided to give Windows 2008 a try on there as well. In total, I’ve spent about 2 hours getting it set up, from start to finish. Some of the new setup features deserve an entire blog post (stay tuned!). The only thing I haven’t set up is subversion and my off-site rsync backups. I’ll be running the Subversion virtual appliance for my source code (which coincidentally, is my project).

On person said that I’m just trying to get attention. Well, it’s my blog, and I admit that part of my motivation is to get readers.

Another person said that the post was an advertisement (at least I think that’s what he meant). Well, to prove I’m not being paid by Microsoft, I’ll admit that they have a ton of software that just plain sucks. I’m looking at you Vista.

Avoiding duplicate content with your site or blog

One of the most important rules in SEO (Search engine optimization) is avoiding duplicate content. Google has some information on their page about how they handle duplicate content. Unfortunately, the Googlebot is rarely smart enough to know which content is original. Google wants to avoid users that copy and/or republish someone else’s work simply to get content for their site.

You also want Google find pages on your site that have substance, and that are not just a copy of content from one of your other pages.

printer

So how do you avoid it on your site? The first step is to identify potential pages that have duplicate content. It’s probably happening without you even being aware of it.

Type this into Google: site:http://www.yoursite.com

I’m using blogger, and by default here are some pages that are indexed that should not be:

  • http://www.ytechie.com/2008/04/aspnet-linkbutton-and-seo.html?widgetType=BlogArchive&widgetId=BlogArchive1&action=toggle&dir=close&toggle=YEARLY-1199167200000&toggleopen=MONTHLY-1207026000000
  • http://www.ytechie.com/2008_03_01_archive.html

Now that we’ve identified the offending pages, we can create or modify our robots.txt file, at the root of our site.

Here is what I could add to my robots.txt to block those pages:

Disallow: /*?
Disallow: /*_archive.html$

Once you’ve updated your robots.txt file, you can use the Google webmaster tools to test it. For more information on how to edit your robots file, including syntax, consult Google.

There is one big problem. If you’re using a service like Blogger (like this blog), you can’t edit your robots file. There has been talk of adding support, but we have to deal with what is available.

The best I’ve been able to come up with, is adding this into the head (look for <head>) of my template code:

<b:if cond='data:blog.pageType == "archive">
 <meta name="robots" content="noindex, nofollow" />
</b:if>

This adds a noindex and nofollow meta tag to the generated archive pages. I have not yet figured out how to remove pages that contain parameters (?param=value). If anyone has a way to do it, please let me know! I’ve actually been considering removing the archive widget to solve it.

Can LEAN be applied to software?

The company I work for has recently started a major LEAN manufacturing initiative. When I first heard about it, I started having flashbacks to the Six Sigma training in me GE days. While the concept of Six Sigma makes sense, the approach that GE took was completely useless.

Fortunately, LEAN thinking actually makes sense to me. The basic philosophy is optimizing what you have by eliminating all forms of waste.

Optimizing

So can LEAN be applied to software? I believe it can be applied in at least two broad categories.

LEAN can be used before you even write your first line of code. You need to ask yourself if it even makes sense to write the code. Software engineers such as myself often see the answer to all problems in code. It’s like the saying “if all you have is a hammer, everything looks like a nail”.

Instead of writing the software yourself, evaluate if there is an existing product that will accomplish the same goal. If not, try to break the problem down into smaller pieces, and see if there are existing solutions that may eliminate or minimize the number of pieces that need to be built.

Obviously you’ll have to weigh the costs of custom code against the costs of integrating a third party product. When doing so, be careful to not simply compare the amount of time coding. Every line of code will need to be debugged, supported, quality checked, version controlled, and successfully be part of your overall solution.

Once you have made the decision about what code you are actually going to write, you have now entered the second category of LEAN software thinking. You now need to optimize the actual development process. There are several methodologies that attempt to use this philosophy, such as Agile programming.

I’ve ordered a few books from Amazon so that I can more familiarize myself with Agile and LEAN programming thinking. Stay tuned for some more in depth posts.

Using the Luhn algorithm to validate credit cards

Today’s post is inspired by this blog post. The author posted a number of regular expressions for the different types of credit cards. I’m sure there are cases when they are useful, but there is typically a better way!

The Luhn algorithm was designed exactly for the purpose of validating credit cards. It’s basically a checksum check for the exact purpose of verifying that a credit card number was entered correctly. It does not pick up all errors, but it’s perfectly fine for real world use.

The best part is that we can easily use the Luhn algorithm in an ASP.NET validator. To do so, you’ll first need to add the Luhn JavaScript to your page. You can use a scriptblock on your page, or put it in a separate js file and include it. The script that I have tested and use is available on this site.

Here is an outline of the JavaScript you could use:

function ccValidator(sender, args)
{
    var ccString = args.Value.replace("-", "");
    args.IsValid = luhn_check(ccString);
}
function luhn_check(s)
{
    //Insert Luhn algorithm here.
    //Example at: http://www.brainjar.com/js/validation/default2.asp
}

The next step is to add an ASP.NET validator:

<asp:CustomValidator
    runat="server"
    ControlToValidate="txtCCNumber"
    ClientValidationFunction="ccValidator"
    ErrorMessage="Invalid credit card number"
    Display="Dynamic"
    EnableClientScript="true" />

You’ll need to change the "ControlToValidate" property to match the TextBox control that you’re validating.

Now you’ll have a validator that can check the credit card number in real time, before a postback! You’ll still need to determine how you’re going to do validation on the server if the client doesn’t support client-side validation.

There is only one other thing worth mentioning. If you’re running an e-commerce site, you typically want to avoid any issues that could cause you to lose an order. Over-validating is one of them. In many cases, even if the credit card does not get charged successfully, you should let the order go through. You can then contact the user and try to correct the situation. It might just be worth the sale!

What it would take for me to switch to a Macintosh

Apple could come out with a killer technology that would increase their sales like nobody’s business.

VIRTUALIZATION

I know what you’re thinking. Everyone has virtualization products for the Mac. VMware, VirtualBox, and Parallels to name a few.

Here is the problem, virtualization is a pain in the ass. The average person would have no idea how to do it. You have to:

  1. Create a virtual machine and know what hardware specifications to assign it.
  2. Have access to an OS CD to install Windows, Linux, or another OS. If it’s Windows, you’ll need a retail or volume license copy.
  3. Install the OS in the virtual machine.
  4. Configure the OS, and install the software you want to use.

If you get to that point, you still have to start up the virtual machine every time you want to run a Windows program. Parallels has really made progress due to the fact that they create coherence mode, which allows you to use your Windows applications seamlessly in OSX.

Electronic CPU

Now we’re do the biggest problem. You have to decide how to allocate your resources. Let’s say you have a Macbook Pro with 1GB of RAM. If you give the virtual machine 512MB of RAM, that may be too little, or it may be more than you have to sacrifice. You shouldn’t have to make that decision.

Step 1 to solving this problem is somehow sharing the memory. The OS should be smart enough to evaluate what is running, and fit it all in.

Step 2. Now, lets take it a step further. Why should I even have to configure a virtual machine? I don’t want two file systems, just show me one. I don’t want to have to start, suspend, or stop the virtual machine.

So now imagine with me for a moment. This means that you could use your Mac to run Windows programs. I’m not claiming that it’s easy, but imagine if Apple could say that they can run all of their software AND 99% of the Windows software that is available. The productivity and beauty of a Mac, and the support of the Windows software industry.

Would you switch if it were possible?