Subscribe: Cool Programming
Added By: Feedage Forager Feedage Grade B rated
Language: English
address  bmi  convert todouble  don  firefox  google  mailto  mobile device  mobile  public  stats  website  weight  widget  windows 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Cool Programming

Cool Programming

Cool Programming Tips with C#

Published: Tue, 17 Jan 2012 18:12:37 GMT

Last Build Date: Tue, 17 Jan 2012 18:12:37 GMT

Copyright: Copyright 2005 Randy Charles Morin

BMI C# Class

Tue, 17 Jan 2012 18:12:37 GMT

Today, I wrote a BMI (body mass index) C# class.  Sharing. public class BMI { public double weight; public double height; public enum bodyType { underweight, normal, overweight, obese, } public BMI() { } public BMI(double weight, double height) { this.weight = weight; this.height = height; } public BMI(string weight, string height) { if (weight.Contains("lbs")) { this.weight = Convert.ToDouble(weight.Replace("lbs", string.Empty)) * 0.45359237; } else { this.weight = Convert.ToDouble(weight); } if (height.Contains("'") || height.Contains("\"")) { if (height.Contains("'")) { if (height.Contains("\"")) { string[] s = height.Split("\'".ToCharArray()); this.height = (Convert.ToDouble(s[0]) * 12 + Convert.ToDouble(s[1].Replace("\"", string.Empty))) * 0.0254; } else { this.height = Convert.ToDouble(height.Replace("'", string.Empty)) * 12 * 0.0254; } } else { this.height = Convert.ToDouble(height.Replace("\"", string.Empty)) * 0.0254; } } else { this.height = Convert.ToDouble(height) / 100; } } public double Calculate() { return this.weight / (this.height * this.height); } public bodyType BodyType() { double bmi = this.Calculate(); if (bmi < 18.5) { return bodyType.underweight; } if (bmi < 25) { return bodyType.normal; } if (bmi < 30) { return bodyType.overweight; } return bodyType.obese; } }[...]

Word Count Javascript

Thu, 11 Jun 2009 14:18:12 GMT

Minimal Javascript code to preform a simple word count.

This free script provided by JavaScript Kit

Mobile Redirect

Thu, 04 Jun 2009 16:19:16 GMT

The stupidest mobile device algorithm is when the redirect all mobile hits to their non-mobile site to the mobile site homepage. Like I'm gonna search your site for the link I was expecting. That's simple laziness. If you are stupid enough to have a separate mobile site in the first place, at least try to redirect me to the proper page or provide me some option of going to the non-mobile page.

Stats Lie

Thu, 23 Apr 2009 20:22:04 GMT

Ninety percents of stats are simply used to justify untruths. Especially when you don't have a verifiable source for them. For example, my own first sentence. Where does that come from? I made it up. But even stats that do have a source are likely to be misused or miscommunicated.

On one project, we were using the Clearspring widget platform. Not only was our widget horrible, but the Clearspring wrapper was mostly broken as well. I knew this widget wasn't gonna fly, but the powers that be insisted otherwise. We had a deadline and we went live with the bad widget. We agreed to revisit the widget post launch. A few months after the launch, we reviewed the adoption of the widget. The manager in charge of the Clearspring integration said we had millions of placements and we should keep the widget as-is. Millions? Where? I could only find one or two. I told him I didn't believe him. He gave me the password to the Clearspring dashboard so that I could double check the data. I reviewed the data and noticed that almost every single placement had occured on our own website or internal development servers. Clearspring was counting our previews of the widget as placements. In actual fact, we only had a few placements. I explained this to the manager and he didn't believe me. He said he would review the stats himself and get back to me. I never heard from again. The project was basically dead because the manager had stats indicating we were getting adoption, when we weren't.

The lesson. Doubt everything involving stats. It's probably untrue. At least 50% of the time.

Behavioral Algorithms

Tue, 21 Apr 2009 03:50:53 GMT

Honestly, I'm fed up with behavioral algorithms. It's stupid. It's in every game you video or online game play. Lately, I'm playing NASCAR Cart for Wii. If I lose twice in a row, the third race is a cake and they actually slow down at the end of the race to let you feel good about yourself. What is the point of putting the game on the most difficult setting, if they are gonna flub the 3rd race and let you win.

It's the same in my NASCAR 2009 for PS/2. If you are losing, the lead cars slow down to let you catch up. Even on the hardest settings. It's also true of online (free) Texas Holdem Poker. When I try a new poker room, I get 4 of a kind, straights and flushes every few hands. But after playing for awhile, I can't get any of them. I worked for a gaming company and I couldn't believe it when they told me to implement this feature.

Honestly, I hate this shit. I know why they do it. They want you do feel good about yourself. If you lost every game, then you'd likely think the game sucked. I personally cannot stand winning every 2nd or 3rd NASCAR race on these stupid games. Give me something challenging. This is stupid.

mailto Link Handlers

Sun, 05 Apr 2009 15:58:49 GMT

On, the users quite often report that their mailto links handlers are not working. This is most comon with Mac users, but it also happens to Windows users. This article will summarize the solutions that I've provided to users who complain that mailto links are not working on their Mac or Windows computer.

Gmail on Macs and Windows

Download the Gmail notifier to enable mailto link with Gmail on both Macs and Windows.

We haven't tested which Web browsers these work for, but we assume they work for the three major browsers; Internet Explorer, Safari and Firefox.

Yahoo! Mail on Firefox

This works on Firefox 3 and later.

  • Go to Tools | Options from the menu bar.
  • Go to Applications tab.
  • In the Search textbox type 'mailto' (no quotes).
  • Change Action column to Use Yahoo! Mail. 
  • Click OK.

Credit to 

Yahoo! Mail on Safari

We recomend installing Firefox and following the instructions for Yahoo! Mail on Firefox above.

Hotmail on Windows

Download and run the Register Hotmail with Default Programs utility.

Gmail on Greasemonkey and Firefox

Download the mailto to Gmail handler Greasemonkey script.

You will also need to installed Greasemonkey for Firefox.

Help us!

Please send us any further solutions that you discover (

Browser Stats

Tue, 24 Mar 2009 19:48:08 GMT

Latest stats for my most popular website

  • Internet Explorer 63%
  • Firefox 23%
  • Safari 11%
  • Chrome 1.0%
  • Opera 0.7%


  • Windows 84%
  • Macintosh 12%
  • iPhone 1.6%
  • iPod 0.5%
  • Linux 0.4%

Blaming the Previous Guy

Wed, 18 Feb 2009 01:52:58 GMT

Let me define irresponsibility. Not taken taking responsibility for something. We are all responsible for our current situation. Blaiming it on the economy is irresponsible. Blaming it on the guy that quit three months ago is irresponsible as well. You had months to fix it. Fix it!

Most often when someone blames the previous guy, you can assume that the current guy is simply irresponsible. I can't remember how many times a programmer tried this on me. It's not my fault, the previous guy's code is horrible! That's a phrase said as often as the national anthem.

Blaming the previous guy is a sign of irresponsibility. It's sometimes justified, but rarely. Even if justified, then you should have fixed it. Period. Mobile

Tue, 03 Feb 2009 03:07:37 GMT

Possibly one of the worst mobile website implementations is that of I've always avoided on my mobile device because it didn't work at all. It looked like they were serving me a full HTML website with lots of graphics, CSS and Javascript that don't work on my mobile Internet Explorer.

All of a sudden today I'm being served a mobile version of on my desktop computer (not a mobile device) and I don't know how to get back to the full website. 101 in mobile design, give the user the ability to escape back to the non-mobile version of the site. Morons!

Username is Case Insentive

Tue, 13 Jan 2009 17:37:02 GMT

I've always been told that usernames should be case sensitive for security reasons. After running my own sites for years, I can tell you that this is a user support nightmare. Users don't understand that case matters. You are best to make usernames case insensitive. Otherwise, the support cost will kill you.

Google Maps for Mobile goes Useless

Tue, 13 Jan 2009 17:33:09 GMT

Today I noticed that Google Maps no longer works on my Windows Mobile device. WTF? Not even Google can program for mobile devices. Does anybody test this stuff? When I do a search I get a blank white result page. I'm going to bet that doesn't even know and when they find out they won't even fire anybody. Pathetic!


Thu, 18 Dec 2008 22:34:40 GMT

Over-validation is a real problem on the Internet. Some programmers assume that all addresses fall within their knowledge of what an address is. They design website to meet their limited knowledge and it works for 90% of the cases. You just lost 10% of your customers. I was applying for a credit card at PC Financial and I couldn't enter my mailing address as their validation did not accept the address. More oddly, the validation on cell-phone numbers was also constrictive. Somebody needs to fire a development.

HowTo C# Mobile

Sat, 15 Nov 2008 03:53:24 GMT

I've been struggling with just how to write a mobile website. What I've noticed is a bunch of really crappy mobile websites and I sure didn't want to do one of them. My approach was to simply tweak my existing HTML websites for mobile devices. Here's what I wrote. When mobile is true, I simply remove the clutter normally in my HTML websites. Sorry for the lack of formatting. My code was partially based on code written by Richard Jones.

bool mobile = false;
MobileCapabilities cur = (System.Web.Mobile.MobileCapabilities)Request.Browser;
  if (cur.IsMobileDevice
    || (Request.UserAgent.IndexOf(
"Windows CE") != -1)
    || (Request.UserAgent.IndexOf(
"iPhone;") != -1)
    || (Request.UserAgent.IndexOf(
"iPod;") != -1))
    mobile =
"mobile", true);

Facebook Mobile Sucks

Fri, 14 Nov 2008 18:52:39 GMT

Today, I was trying to use Facebook mobile. Wow! That realy sucks. Most everything in Facebook is unavailable in their mobile offering. You can barely do anything. This is perfect example of what I've complained about; mobile specific version of sites. Stupid! Website designers, especially mobile website designers continue to be some of the dumbest people on this planet.

Online GUID Generator

Mon, 10 Nov 2008 04:34:33 GMT

Nice idea!

Eat Your Own Dog Food

Thu, 06 Nov 2008 04:30:23 GMT

Eating your own dog food means using your own product. It's very common in software development. The advantage of doing this is that you quickly recognize bugs, deficiencies and potential new features.

Recently Google announced that they are moving their AdSense Help Forum away from Google Groups to a new platform. They describe a few new features that weren't available in Google Groups. I quickly asked myself why they didn't simply add those new features to Google Groups? That's part of eating your own dog food. Recognizing potential features and implementing them. I wonder if their was a conversation at Google where the AdSense team asked for the features and were refused by the Groups team? Or is the Groups product in maintenance mode (no new features)?


Tue, 28 Oct 2008 17:53:47 GMT

The most important part of any development process is quality assurance. It's also the least most important part of comedy.

Today, while working on a paid review for a website, I discovered the following sentence on their homepage.

"Sites that ... have a reputation for treating players fairly will not be listed on ..."

QA. QA. QA. Pay your best tester more than your best developer.

Broken Olive

Tue, 28 Oct 2008 01:35:34 GMT

More and more, I'm amazed just how broken most websites are.  Today, I was looking for an Olive Garden in Indiana and stumbled upon an Olive Garden Canada website. I started looking for location in Canada. It asked for city or province in the search textbox for locating an Olive Garden restaurant. I typed each province in Canada and it returned "We're Sorry. No results were found near your location. Please search again." for all. I knew their was an Olive Garden in Edmonton, Alberta, so I typed the name of the city "Edmonton" and got a match. Searching on the province "Alberta" and you get no results. It's no wonder their are few Olive Gardens left in Canada. You can't find them. The same functionality worked fine from the US website.

EAMobile is Stupid

Fri, 17 Oct 2008 16:13:45 GMT

More Mobility stupidity. Today I type NASCAR 09 AT google, my favorite video game. I click through to EASports webpage for their game. They redirect to, a stupid Morons version of their website. If you don't know how to create a good mobile version of your website then leave good enough alone, please don't f-it up. Creating a mobile version of your website is dumb, unless you know what you are doing. Try tweaking for mobile rather than making a completely useless mobile version like the EA idiot developers.

How to Screw Up a Mobile Website

Thu, 16 Oct 2008 16:48:44 GMT

I work about one hour per day now on a mobile device. There are three types of mobile websites.
  • those that present the same website to both desktop and mobile users.
  • those that tweak their site for mobile devices.
  • those that offer a unique mobile experience.
  • Tweaks tend to work very well. Mostly these sites hide some ads and sidebar content for mobile devices. On the other hand, those that offer a unique mobile experience are almost always broken. The biggest example is Facebook, which is completely b0rked on my device. I think the problem is that unique means twice as much testing, which means several fold more missed bugs. This is amplified on mobile device since their are more target mobile platforms than on desktops.

    Don't develop unique presentations for mobile devices. Rather, just tweak your desktop presentation.

    Hug a developer today...

    Fri, 12 Sep 2008 14:13:45 GMT

    Too funny! Hat tip to Robin. Been there, done that.

    (object) (embed)

    Don't Over Validate

    Sat, 06 Sep 2008 17:32:09 GMT

    One problem I encounter a lot on the Web is crazy developers who try to over validate everything. In this case, I was updating my address information for a service I use. The website is quite nice on one hand, in that, it was able to determine most of my address when I entered my postal code. On the other hand, it got the street address slightly wrong. I decided the address was 295 Queen St E, when it's actually 6-295 Queen St E. The developer was so sure of his amazing algorithm that he wouldn't let me edit the address.

    I often experience the same problem with phone numbers. My Motorola Q doesn't understand phone number extensions, so when I enter the extension in the address book, the phone dials the wrong number.

    Macs Suck

    Mon, 30 Jun 2008 15:18:24 GMT

    I keep getting the same "Well I have a mac and can't send a report this comment message 2 u..." When I ask Mac enthousiast, they deny there's a problem with mailto links in Safari.  What's up? Can anybody give me the story here? It's my most common user problem these days.

    More specifically, it has to do with mailto links that have the subject URI request parameter. For some reason the subject request parameter doesn't work in Safari or so most all my users claim. I don't have a Mac to test this with.

    $20,000 Software

    Sun, 29 Jun 2008 03:24:02 GMT

    When you are IBM, it's not hard to sell software. But when you are Joe, then you should read this. This blogger explains how he's selling software at $20,000 a pop to big companies. I might read it 10 times myself.