Published in
Geolocation, Google, Howto, Javascript, Maps, Open-Source, Programming, Technology, Web
I’ve been fairly quiet for the past couple of weeks. I’ve been focused on some projects, including entries to the MapQuest OpenAPI developers’ competition.
One of my entries, which may or may not actually be considered a “mashup”, is a Firefox GreaseMonkey script called GreaseRoute that creates map and route icons for an Microformat formatted adr or geo locations. These are often used in an hcard.
One of the cooler parts is that the extension automatically determines the location of the person viewing the page. Using the HostIP IP-to-Location database, the user’s location is automatically entered as the starting location. So when a user is viewing the webpage of, for example, a store or business, they can click the “route” link and get turn-by-turn directions to that location. No more copy & pasting street/city/state to a form or asking the person next to you “where are we?”
Microformats are a stepping stone on the way to the semantic web. They are a simple way to encode useful information for viewing and mining by users and other applications (ala mashups).
Example adr
The proper format of the adr is as follows:
<div class="adr">
<div class="street-address">1517 N. Main St.</div>
<div class="extended-address">Box 203</div>
<span class="locality">Royal Oak</span>,
<span class="region">MI</span>
<span class="postal-code">48067</span>
<div class="country-name">US</div>
</div>
which will then be displayed as:
1517 N. Main St.
Box 203
Royal Oak,
MI
48067
US
Example geo
Instead of an address, one can instead just encode the latitude and longitude:
N 37° 24.491
W 122° 08.313
The Result
GreaseRoute has 2 version, the lite version and the embed version. The lite version displays a map and route icon next to the addresses found on the webpage:

The embed version displays a “route” link. When clicked, a pop-up map is displayed between the users location and the encoded address.
Give GreaseRoute a try and let me know what you think.
You can also go over to Userscripts.org, the GreaseMonkey script repository, and rate them and leave comments.
Published in
Open-Source, Programming, Rails, Ruby, Technology
A word to the wise of rails developers. Hopefully this makes it to Google search, because when I looked it up, there wasn’t an answer.
If you’re configuring ActionMailer and you try to run the console and get the following messages:
[host]$ script/console
Loading development environment.
./script/../config/../config/environment.rb:41:NameError:
uninitialized constant ActionMailer
/home/highearth/.gems/gems/actionpack-1.12.1/lib/action_controller/integration.rb:15:
NameError: uninitialized constant ActionController::Integration::Session::Test
./script/../config/../config/../app/controllers/application.rb:3:
NameError: uninitialized constant ActionController::Base
Make sure your ActionMailer configuration in your config/environment.rb file is after your Rails::Initializer.run do |config| block.
Published in
Howto, Javascript, Open-Source, Programming, Web
Sometimes it’s necessary, or nice, to be able to directly embed an image in code. Like a modern form of ASCII art, you then don’t have to distribute icons and images with your source, because the image is in the source itself. The method uses Base64 encoding. See the RFC for Data URI.
“Base64″ format used by MIME-encoded documents such as electronic mail messages with embedded images and audio files.
To convert a PNG (for example) image to Base64, you will need some utility. base64 is an open-source converter that does just this.
Do the configure, compile jig:
$ ./configure
$ make
$ sudo make install
Then encode your image:
base64 -e my_image.png my_image.png.base64
Open the my_image.png.base64 file in a text editor and then copy it into your code. An example is shown below, written in Javascript.
const png_image_src = 'data:image/png;base64,'+
'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAANbY1E9YMgAAABl0' +
'RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGAUExURcDYv1C8WdPrtIDAeWqk' +
'Oqnd2VLWaOX0x7ftwZzZlIjGxr7gxanLkdfu1FumybHSsJ3Cutbyx4S9fm2paMrq0Lfo1L/a' +
'o6PHiozL11aZJpnW2oG0ZLTcm5zjvovbvM3qtcror2q5vUaIRHLGZWWkR0aQGSR/BYy5baHY' +
'imrbd/z+/HO9bPb69m29xHy8c2OeMUGJPZDThZPPi3ivdGazzZbBgCuCEd3x2jaICs7ksqLZ' +
'mTp/N6zwtWu/YLDWvZHHeqLS0affzKfvsWDYpn7CvJHJh0+cSGWbY6PQka/Xkvj894W2a4DQ' +
'qIrDhF+hQ8fexJDN24PYgYGzWnXJy6zXpp3Fm5jCg37NdI++dWejWmCwVnSrT6nuyTuLELvh' +
'pV2gO6DSwI3qnd3wv6rQxK/fz1OZxrTvtaLim3rRr+bv5TuCN+jw557FiK7NlWzRkHDGhHLd' +
'fnHWmm2zx7Xe1m21zW65z9Ts0HTHaHrGb3vJb3yvVbTaxVGUTITLtV6w0////94DUpYAAACA' +
'dFJOU///////////////////////////////////////////////////////////////////' +
'////////////////////////////////////////////////////////////////////////' +
'//////////////////////////////8AOAVLZwAAAQxJREFUeNpiqAcCc87wcuVKTl4Qm6G+' +
'XstKOU6eu9ouxNbICySgZajBzluWUuzgkOyqpwMUsNJIEuQVYWUNkOCysxeqZzBXZk+z4RCV' +
'kiopquVUcPNn4JSRd4oRkZAwUSwsKPAQN2YIZ0pPFBUpNQnWZGNj0xOrYShPCtSUdeTTlXNm' +
'0WcUtjRgUE4Kz5Plq0vVzWAJkoy0zGKokDeU4+JjYWHRr+KJVhVTYjDylMn34WPJzeXhiRBX' +
'sXBnKIti0tZW1M9VV/eWlg6LV2Oo943wZHaR5BEXz/EOUzHTYajXEfZWSJBUVY2NN1UxywR5' +
'TsfYIFRAQIDfws8sG+xbICGsZG2tpKamBWQDBBgAU049f2kd9aAAAAAASUVORK5CYII=';
var my_link = document.createElement('a');
my_link.title = "Go to example.com"
my_image = document.createElement('img');
my_image.src = png_image_src;
route_image.border = 0;
my_link.href = "http://example.com";
my_link.appendChild(my_image);
document.body.insertBefore(my_link, document.body.lastChild);
Published in
Geolocation, Maps, Open-Source, Programming, Technology, Web
Plazes, a very nice user-location mapping site, has released a API for all your mashup/application consumption. Announced here
With all these API’s I wonder about conflicts of licensing and terms. They all have their little niggles: no realtime, no commercial use, limited number of queries, limited by directory, etc. etc. I have a feeling people are going to break lots of these terms without realizing it. Of course, the data originators probably won’t mind until either their servers start getting crushed, someone tries to sue them for bad data, or the masher makes serious bank.
Other Quicky Links: