Wednesday, September 27, 2006

Replacement for geocoder.us functionality in cfgooglemaps

I was playing with the cfgooglemaps CFC. It's a great CFC, but I was having a few small problems.

Since most of the addresses I needed to map were non-American, it was returning blank locations, and the non-commercial license bothered me (not that I'm doing anything commercial at this point).

So I rewrote it using the new Geocoding features in the Google Maps API.

There were two easy steps:

1. Replace the 'v' parameter in the main JavaScript include line to be version 2 instead of 1.

<cffunction name="getMapJS" access="public" returntype="string"
description="Get javascript include">
<cfset jsstring = "<script
src='http://maps.google.com/maps?file=api&v=2&key="
& this.key & "' type='text/javascript'></script>"
& chr(13) & chr(10) />
<cfreturn jsstring />
</cffunction>


2. Replace the geocode_address function as indicated below.

<cffunction name="geocode_address" access="private"
returntype="struct" description="Geocode address using
Google geocoding">
<cfargument name="address" required="true" type="string" />

<cfset newUrl = "http://maps.google.com/maps/geo">
<cfset newUrl = newUrl & "?q=#URLEncodedFormat(address)#">
<cfset newUrl = newUrl & "&key=#this.key#&output=csv">

<cfhttp method="get" url="#newUrl#" charset="UTF-8"></cfhttp>

<cfset geocode = StructNew() />

<cfif ListLen(Trim(cfhttp.fileContent)) EQ 4>
<cfset geocode.lat = ListGetAt(Trim(cfhttp.fileContent),3) />
<cfset geocode.lon = ListGetAt(Trim(cfhttp.fileContent),4) />
<cfelse>
<cfset geocode.lat = 0 />
<cfset geocode.lon = 0 />
</cfif>

<cfreturn geocode />
</cffunction>

Connection failure for CFHTTP and Google Maps Geocoding

Had a really tough time trying to connect to http://maps.google.com/maps/geo using CFHTTP in CFMX 7.

Lucky, I stumbed across this posting on Pete Freitag's Blog - Connection Failure with Yahoo Web Services and ColdFusion.

I want to add that this is exactly what happened for Google Maps as well, specifically the Geocoding web service at http://maps.google.com/maps/geo.

I had to update the charset attribute on the CFHTTP tag to 'utf-8'. Thanks for the blog post Pete!!

T

Tuesday, September 26, 2006

Limiting Databases in Enterprise Manager

Wow, this was a cool tip. I hate when I connect to certain databases and I have to wait a few minutes for the list of databases to load up. The funny thing is, I don't even have access to most of them, so why even show them to me?

Did you ever connect to a an SQL server using Enterprise Manager where the server in question had a hundred or so databases installed? If you have you will know there is a significant delay when you expand the tree to find your database.
This KB Article from Microsoft includes a stored procedure that modifies the process of creating that browse list and shows the connecting EM only the databases they are entitled to see.


Article on ColdfusionMuse - Limiting the Databases Seen in MS SQL Enterprise Manager

Microsoft Knowledge Base Article

Friday, September 15, 2006

Six JavaScript features we do not need any longer - Wait till I come!

Nice post on a great JavaScript blog.

Six JavaScript features
we do not need any longer!


From the article:
You can use a screwdriver to screw in screws or to clean your ears, however, the latter needs real skill, determination and a lack of fear of injuring yourself. It is much the same with JavaScript, you can use it for great things, but you can also use it to make a product inaccessible, confusing and not usable.


I like his points, especially number 3 - avoiding the href=javascript: notation. Ick.

Monday, September 11, 2006

Getting Google Analytic stats for 404 pages


Another tech post. This was a great tip on the Google Analytics blog about getting stats for 404 pages:

I'll have to be sure to add this to our development plan at work, especially since I've done some cool work with handling 404 errors recently. Awesome idea.

Thursday, September 07, 2006

Congrats to J and R

Congratulations guys on your wonderful wedding. It was fantastic and EVERYONE had a great time. Best wedding that most of us have EVER been to.

J's Wedding
Sep 2, 2006 - 14 Photos


I've posted a few pictures, most of them are non-professional. It's not my right to distribute the pictures on their behalf so we'll wait until they get back to see anymore.

You guys look great!

T

Context menu for IE links to 'Open In Firefox'



Obviously most of our development has to be done with an eye to how it works in Internet Explorer, but I get tired of pasting links into FireFox, my primary browser. This is especially annoying when I need to open links in Gmail or Google Reader from IE to FireFox.

So using information from the kunal.kundaje.net site , I created a new context menu entry for 'Open In Firefox'.

I created an HTML file in c:\windows\ie_open_in_firefox.html with this content:

<script language="JavaScript">
var foo = new ActiveXObject("WScript.Shell");
foo.Run("Firefox " + external.menuArguments.event.srcElement);
</script>


And added the entry to the registry as discussed.

  • Create entry:
    HKCU\Software\Microsoft\Internet Explorer\MenuExt\Open In Firefox
  • Update Key '(Default)' to the string c:\windows\ie_open_in_firefox.html
  • Add new key 'Context' with the DWORDS value HEX 20


Photo from tdenham at SXC

Tuesday, September 05, 2006

Making JS functions work like CF functions

Stumbled across a site that had some JavaScript functions that mimic some of ColdFusion's powerful string functions.

As ColdFusion developers, we are used to having function like Left(), Right(), UCase(), LCase and Trim() at our disposal. They are particularily handy for validation routines. Javascript does have support for some of these functions, but their syntax is not as straight forward.


Fixing Javascript To Match ColdFusion's String Functions

Cool, thanks! Now I have to look for similar things for ColdFusion's list functions. I use those all the time.

T