Wednesday, November 14, 2007

System.Drawing.Image.Save() results in ArgumentException: "Parameter is not valid"

If you are using the .NET Image.Save() method to save an image, and you receive an ArgumentException with the message "Parameter is not valid," you probably spent a while examining the parameters you were passing into the Save() call, right? You probably banged your head against the wall and said, "Dear GOD, please tell me WHICH PARAMETER is not valid!"

Unfortunately, the error message is completely unhelpful, and you are seeing it because you had a brain fart. You have called Dispose() on the image object before you tried to Save() it.

If this helps you, please comment on this post, thanks.

Friday, November 2, 2007

Google Maps GIcon imageMap Property

Been fooling around with Google Maps API lately. When using custom markers on the maps, you should specify the imageMap property, so that the markers are still clickable even when beneath a "shadow," in Firefox. Yet the Google Maps API never describes the format in detail, simply stating it is "an array of integers representing the x/y coordinates of the image map we should use to specify the clickable part of the icon image in browsers other than Internet Explorer."

I searched high and low and could not find anyone that explained the format in more detail, but after studying the HTML image map formats, it became clearer that Google wants you to use the same format for this imagemap array as the "polygon" type of imagemap that HTML uses.

Specifically, your x,y pairs should denote points OUTLINING the area you want to be clickable. In very simple terms, if you have a square icon that is 8x8, and you wanted the entire square to be clickable, you would use an array of: [0,0, 7,0, 7,7, 0,7]. The first pair is the top/left corner, the second pair is top/right, the third is bottom/right, and the fourth is bottom/left.

They key is to think of your starting point, and traveling from point to point in order, encircling the area to make clickable for your GIcon (aka google.maps.Icon).

Tuesday, October 2, 2007

Filter for Spam on GMail

I've been getting a ton of spam on GMail lately that falls into two categories: Russian-language spam, and another spam with several variations, of the form:

  • Hello! I am bored this evening. I am nice girl that would like to chat with you
  • Hello! I am bored this morning. (etc)
  • Hello! I am tired this evening. (etc)
  • Hello! I am tired this morning. (etc)
  • And so forth...
So I've been honing a Gmail filter that knocks both out at once. So far I don't have any false positives, and I have about 5000 legitimate emails and 5000 spams in my gmailbox. Create a filter, and in the box for "has the words," just paste:

и|KOI8|windows-1251|("Hello! I am" (tired|bored) (today|tonight|this))

You can also test this against your mailbox in general by putting that exact text in the search box in gmail, and if you want it to search everything, add a space and then in:anywhere.

If you have any other filtering tips, post a comment.

Wednesday, July 11, 2007

Handler "$HANDLER" has a bad module "IsapiModule" in its module list

If you've seen this error when trying to get a CGI handler working in IIS7 on Windows Vista, check your applicationHost.config file (in c:\windows\system32\inetserv\config). Specifically, look in the <modules> list to make sure you have an entry specifying:

<add name="IsapiModule" type="" precondition="" />

I was beating my head against the wall with this error message until I added this. (In my case it was within <location path="My Website"><system.webserver><modules>, just to be specific.)

I already had an entry for IsapiModule in globalModules, mind you. I have no idea why this is required, so far the IIS7 configuration system leaves a lot to be desired.

Microsoft, when providing a gun that can shoot you in the foot, it might help to add some safeties. How about making it really easy to configure common CGI modules like Perl, PHP, Python, Ruby, etc?

Wednesday, May 23, 2007

Ummm... my BlackBerry has GMaps+GPS and NO support?

Official Google Blog: Cingular BlackBerry 8800 has Google Maps and GPS

Steve acts like this is some new development in phones... yet my BlackBerry 8703e has full GPS support, runs Google Maps, and does not benefit from this special code unlock that google has provided for these 8800 phones.

Why?

Oh... my phone runs on Sprint PCS network. Perhaps Sprint hasn't paid google for the favor yet?

Wednesday, April 18, 2007

Handy SQL Server Query: Date String For Filename

Here's a simple piece of code for creating a string in YYYYMMDDHHMMSS format, suitable for use as a filename:

REPLACE(REPLACE(REPLACE(CONVERT(char(19), GETDATE(), 120), ' ', ''), '-', ''), ':', '')

If you ran this at 1:23:05 PM on December 3, 2006, it would return "20061203132305".

SQL Server 2000 Database Doesn't Shrink After Removing Columns

If you've ever come across a situation where you've removed text, ntext or image columns from a SQL Server 2000 database, and the size of your database doesn't shrink even after compressing it, you may have run into the problem described here:

DBCC SHRINKFILE and SHRINKDATABASE commands may not work because of sparsely populated text, ntext, or image columns

The solution is to create a DTS package to transfer all of your database objects into a new database, and remove the old one, and then rename the new one to your original database name (if necessary). We did this recently and recovered 50% of the disk space wasted.

Hopefully this problem was solved in SQL Server 2005.