OCDProgrammer.com

It's Microsoft's World, and I'm just living in it
View Clarence Klopfstein's profile on LinkedIn

Clarence Klopfstein's Facebook profile

This site is under construction...

Categories

New Comments

Referring Sites


Disclaimer

  • This is MY blog. The views represented here are not in relation to anybody else. Please read my full disclaimer for a more complete disclaimer.

Death to IE 6

February 26, 2009 17:02 by ckincincy

Any developer knows the fun that IE 6 causes us.

Things will work on EVERY other browser, but once that is opened up in IE 6… you are hosed!

In my Google Reader, I saw the following post telling everybody to ‘Grow up already and throw IE6 Away!”.  Couldn’t agree more so I clicked on the link, read the article which led me to this solution.

So now my websites will show a warning for all IE 6 users. 

If you own a website, why don’t you join me?


Love It – I’m staying

February 4, 2009 03:00 by ckincincy

I am a subscriber to CodingHorror.com.  A recent post from Jeff Atwood referenced a post from The Joel on Software.

Joel was responding to a comment from a person on his blog saying that they were going to leave the industry and move on.  They were just that unhappy.  Joel then went onto question it.  How the timing couldn’t be worse, pay was pretty darn good, and the overall coolness of being able to create new stuff for a living. 

Jeff Atwood responded by agreeing and then going on a bit of a side rant that I agree with.

If you’ve been in the industry for any length of time you come to see a bunch of people that shouldn’t be in the industry.  They just don’t have ‘it’.  They don’t have the analytical skills to program, but more importantly they don’t have the attitude it takes.  If you don’t love what you do in this industry, you need to move on.  Because if you don’t love what you do, you are not going to spend 8 hours fighting a bug that makes no sense.   If you don’t love what you do, you are not going to be up till 3 AM finishing a product that is needed ASAP. 

I love what Jeff says in closing:

So if a programmer ever hints, even in passing, that they might possibly want to exit the field -- they probably should. I'm not saying you should be a jerk about it, obviously. But if someone has any doubt at all about programming as a career choice, they should be encouraged to explore alternatives -- and make room for another programmer who unashamedly loves to code.

In my own closing:

I love it.  I’m staying.


Abusive Spiders - GateKeeper

January 11, 2009 15:39 by ckincincy

image

Chris Blankenship has been on a crusade lately about abusive spiders.  I was interested in some of the fixes he was applying to it, but a few weeks ago I got an email from him about a solution he was developing, ‘GateKeeper’.  I reviewed the code and it all looked good, but he wasn’t ready yet to fully release it into the wild.

It finally got to that point and I installed it on my two DotNetBlogEngine.net blogs. So far I have been really impressed with it.  I’m really interested to see how it affects my overall traffic.  Right now I have four blocked user agents:

baiduspider, larbin, sogou, sosospider.  All of those came from Chris’s recommendation.  Then I immediately got a Slurp violation, though I am going to give them one more failure before I block them.  Chris also has MSN blocked.  A lot of my traffic comes from Live Search, so I’m a little scared to do that.

I did fall on one issue with the solution though.  When I installed it, I had it set to automatically block violators.  Unknown to Chris and I is that Google caches the robots.txt file!  So since they didn’t get my new robots.txt file, they were blocked!  So it is recommended to not turn on the automatic blocking for at least a few days.

Related post from Chris’s site:
The Continued Struggle With Spiders
To catch a spider…
Abusive Web Crawlers
Blocking Bad UserAgents and IP Addresses
The elusive Robots.txt file


Is 800 x 600 finally dead?

November 8, 2008 15:50 by ckincincy

OK, I need your help.  I want to know what your stats say about your visitors.

I have been giving some consideration to redesigning my site and was wondering if the restriction of 800 x 600 screen resolution was still an issue. 

So I looked at stats from a few sites I run and I think the answer is yes.

Sites two and three are church web sites, so the statistics are a bit skewed toward an older crowd, and even those are low.

Site 1
site1

Site 2
site2

Site 3
site3

So what does your stats show?


Category Control Edited

November 5, 2008 19:00 by ckincincy

For the longest time I've wanted the ability to choose which categories show on my site.  Took the time tonight to add a small patch to the category list control to add a display property to it.

Download the file below and just copy it over your current files, or consume the changes if you've made customizations.

Its pretty simple to use, go to your admin screen on the category tab and use the check box to set the value.  It defaults to true for all of your existing categories.

Admin Screen for Updating
image

Admin Screen for Viewing
image

Version 1.0
CategoryPatch.zip (8.81 kb)


Deprecated functions in .NET

October 10, 2008 03:00 by ckincincy

When I started at my employer I inherited a bit of code that was poor at best.  Over the year I've been working with it, I've been refactoring the code significantly. 

Then we hired another developer and this process sped up a bit and I needed to mark some classes as deprecated.  So over time old code could be replaced with the new code.  I've done this before, but had to do a quick search and as an FYI here is the answer:

[Obsolete("Deprecated: Use GetCustomerID", false)]
public int GetCustomer(int custId)
{
           .... code in here

}

The first parameter is the warning/error message to show in the compiler.  The second option is whether or not to cause an error.  So basically you can say, this is broke don't use it.  Or this is old, use something else.  The first breaks the code, the second allows it to go on for a bit.

HT: Karpach.com


'.', hexadecimal value 0x00, is an invalid character. Line 1, position...

October 5, 2008 16:00 by ckincincy

Last week we upgraded our company from Sybase to SQL Server 2005.  All of a sudden one of our web applications started throwing this error:

'.', hexadecimal value 0x00, is an invalid character. Line 1, position 198128.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Xml.XmlException: '.', hexadecimal value 0x00, is an invalid character. Line 1, position 198128.

This was happening when I was calling a .NET web service via an ASPX page.  The web service call returned a serialized object:

For understanding, I have a class similar to this:

Model.Customer cust = new Customer();
cust.Id = 1;
cust.Name = "CK IN CINCY";

Now for the code that gave me this error (ie the ASPX code behind):

Model.Customer cust = new Customer();
WebSvc.GetCustomer(1, out cust);

This would blow up.

The web service looked like this:

[WebMethod]
public int GetCustomer(int Id, out Model.Customer cust)
{
     // Fill cust object from database
     return 1;
}

The problem was the data in the database contained null characters.  This is to understood as different than null records.  A null record is self explanitory and can be deal with inside the sql with an isnull call.  The problem was that the record existed but somehow has a null character.  CK IN [NULL CHARACTER] CINCY.  In this case, isnull won't solve the problem.  So after about five hours of searching I found this post.  Which contained this function, which did the trick for me.  Hopefully this saves you 5 hours of your time :-).

 

/// <summary>
/// Removes control characters and other non-UTF-8 characters
/// </summary>
/// <param name="inString">The string to process</param>
/// <returns>A string with no control characters or entities above 0x00FD</returns>
public static string RemoveTroublesomeCharacters(string inString)
{
    if (inString == null) return null;

    StringBuilder newString = new StringBuilder();
    char ch;

    for (int i = 0; i < inString.Length; i++)
    {

        ch = inString[i];
        // remove any characters outside the valid UTF-8 range as well as all control characters
        // except tabs and new lines
        if ((ch < 0x00FD && ch > 0x001F) || ch == '\t' || ch == '\n' || ch == '\r')
        {
            newString.Append(ch);
        }
    }
    return newString.ToString();

}

Nullable Int type in C#

August 18, 2008 03:00 by ckincincy

I was recently doing some development that needed to allow for an int to be null.  However in .NET that isn't allowed by default.

So I started doing some searches and found that there is a way to have nullable types in C#.

There are two ways to do this:

1. Nullable<int> x = new Nullable<int>(125);

2. int? x = 125

Now what I find interesting is how you can find out if this is null.  You can do, again, one of two things.

1. if(x.HasValue).....

2. if(x != null)....

I actually prefer option two in both situations because that just looks normal to me. 

HT: Eric Gunnerson


Quick Tip - Getting the most out of Visual Studio

August 14, 2008 03:00 by ckincincy

Great page to read to get the most out of Visual Studion.


Failed to access IIS metabase

August 10, 2008 03:00 by ckincincy

At work we've recently hired a few new developers and they got this error.

Having worked at setting up many development boxes in the past I knew what the issue was, but honestly I need to post about it so I have a quick reference to the fix... and I figured it may help you as well.

The problem?  .NET framework was installed before IIS.  The fix is pretty easy, you need to 'reinstall' the .NET framework.  Thankfully Microsoft makes it fairly easy.

Open up a command line and type the following and you will be good to go.

c:\windows\microsoft.net\framework\v2.0.50727\aspnet_regiis.exe -i

Which will look something like this after the fact:

image

More info here.