Saturday, November 29, 2008

Finding distances between two zip codes in PHP

I found this script to calculate distances between two zip codes from PHP (requires MySQL). According to this Idealog post, the calculation relies on a text file of Zip code lon/lats from CFDynamics, available on the downloads page.

I have yet to try it; however, I have a specific implementation that I was needing it for. Does anyone else have a better way to align searcher's proximity to location-based data? I'd like to classify by city, but I'm sure that is a lot more of a gray area than allowing the searcher to specify a specific radius in which to search or letting the resource specify maximum distance to travel.

Added 2008.11.30:
I love Twitter. A few hours after posting this, I received a suggestion that I could get longitude/latitude from Google Maps.

On code.google.com, I found the following question: I need to convert addresses to latitude/longitude pairs. Can I do that with the Maps API?
Yes, this process is called "geocoding." The Google Maps API provides two methods for performing geocoding. If you wish to geocode from within your Google Maps API application you can do so using the GClientGeocoder object. Alternatively you can send geocoding requests directly to the HTTP geocoder.

Labels: , ,

Thursday, November 20, 2008

Gmail terminal theme--for your inner nerd

I don't know if I like it for nostalgia and geekiness, or just plain geekiness. There's only one thing I'd change with the terminal theme... make it truly like the BBS experiences of 15+ years ago. I want ANSI animation and color ANSI art--especially for the Gmail logo.

Added: Even more importantly, the terminal theme works great if you get LISTSERV mailings that have tables rendered in all ASCII characters or code.

Labels:

Saturday, November 15, 2008

I suspect that the delicious bookmark plug-in for Firefox 3 is not keeping me logged for two weeks.

Not only that, but whenever I'm required to log-in to bookmark a page, the plug-in does not continue on to actually creating the bookmark.

This morning I was forced to log in. I believe the loss of information is coinciding with Firefox updates. Anyone else have this experience?

Home PC:
2008.11.15, 9:15 AM
2008.11.29, 2:29 PM
2008.12.14. 6:16 PM

Work PC:
2008.11.26, 10:01 AM
2008.12.11, 5:08 PM

Updated 2008.11.29: So far, no glitches. However, I still dislike the fact that the log-in prompt prevents tagging and you have to have to select the tag icon again after logging in.

Updated 2008.12.11: Looks like everything's fine, just that I'm overly sensitive to having to login.

Labels: ,

Monday, November 10, 2008

Autotext lines in Word (using 2003 here)

Sorry if this is pretty trivial for the true power users of Word...

I don't know if Word 2007 works this way or not, but I've discovered a couple additional characters in Word that auto-correct to divider lines. (Other than 'equals', 'minus', and 'underscore'). The 'hash' divider was of the most interest to me, as I'm trying to write a white paper and need distinctive, yet compact, format markings. (The quicker the better, as well.) Just enter 3 successive '#' (hash), '~' (tilde), '-' (minus sign), '=' (equals), '_' (underscore), or '*' (asterisk) characters and immediately press enter. The text will be replaced by a dividing line.


(This trick does something similar OpenOffice 2.4.)

Labels: ,

Sunday, November 09, 2008

Reading List by Amazon

It looks like LinkedIn has found a way to make itself relevant for day-to-day use... The Amazon Readling List provides a way for you to post what you're currently reading, want to read, or have read. You can also see the contents of other people's reading lists--in your network, in your industry, or all recent updates. Your reading list will automatically appear on your LinkedIn Home and Profile pages.

So far, I only have one book listed. I'll probably start adding to this reading list from my Safari bookshelf list, and all the various other lists that I've been compiling over the last couple of years.

You can get to my LinkedIn profile at http://www.linkedin.com/in/twilliampowell

Reading List Application full view:


On your LinkedIn Home:


On your LinkedIn Profile:


Adding from featured applications page.

Labels: ,

Monday, November 03, 2008

99 bottles of beer and hello world programming examples

I'm a sucker for different programming languages, especially in trivial and whimsical implementations...

99 Bottles of Beer in 1200+ programming languages

Esoteric Programming Languages wiki - contains Hello World samples.

The hello world collection (420+ languages)

Hello World project

List of hello world programs on Wikibooks

Labels:

Found some Gtk/Ruby signal stuff.

(For gtk2+ruby, I used the Windows installer package)

For some reason, I'm trying to learn a portable language/toolkit.

First, I had to find the correct signal to connect to.  Looks like focus_out_event is it.


currentMileage.signal_connect("focus_out_event") {
  mileagePerDay.text=((targetMileage.text.to_f  - currentMileage.text.to_f)
   /(Time.parse(targetDate.text)-Time.now)*3600*24).to_s
}

signal_connect vs signal_connect_after...  apparently, improper usage of signal_connect (for "focus_out_event") will generate the following warning which the signal occurs
Gtk-WARNING **: GtkEntry - did not receive focus-out-event

From the description, what has happened is a timeout with a now invalid pointer (because of the signal's redirect).  Using signal_connect_after() ensures that the default handler has run first.

currentMileage.signal_connect_after("focus_out_event") {
  mileagePerDay.text=((targetMileage.text.to_f  - currentMileage.text.to_f)
   /(Time.parse(targetDate.text)-Time.now)*3600*24).to_s
}

Next up:  Encapsulate some of this stuff.  In this exercise, I realized that I forgot some of the basics, like how variable scope is defined in Ruby:  http://www.informit.com/articles/article.aspx?p=18225&seqNum=2.

Some additional Ruby links...
Rubyist reference
RubyDocs reference to global variables
6 Ways to Run Shell Commands in Ruby