Implementations

From Geohashing
Revision as of 20:36, 9 August 2008 by 64.66.192.61 (talk) (Alternative Perl Implementiation)

This wiki page has recently been a spam target. To effectively combat this, please use the "undo" function in the page history rather than deleting the spam outright. Spambots don't just add content, but delete legitimate content as well. If you just delete the spam, the net effect is a loss of content. Please use caution when restoring pages, and hold off on constructive edits if this problem persists.

If you're looking to code your own utilities, you will need a source that provides the Dow's opening price for any given day. Details on such services are available at Dow Jones Industrial Average.

cool work thanks <a href=" http://www.diigo.com/profile/redtubez ">www redtube c om</a> and <a href=" http://www.diigo.com/profile/pornhub ">www pornhub</a> bookmark you =_)

Good crew it's cool :) <a href=" http://www.imeem.com/people/4qnNSOH ">very young little nude pre preteen boys</a> 7800

Punk not dead <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/CQKMDZmv/favicon_northwest_airline ">robots lowest fares travel tickets </a> mhgqy <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/38f87aqt/favicon_cheap_international_airplane_ticket ">Favicon Cheap International Airplane Ticket</a> oxds <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/0OAMH9kS/favicon_cheap_international_airfare ">Favicon Cheap International Airfare</a> 5090 <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/s5m_dM-H/favicon_malaysian_airlines ">cheapest airline tickets flights</a>  %[[[ <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/hvFeX4pp/favicon_lowest_fare_airline_ticket ">Favicon Lowest Fare Airline Ticket</a> 2500

i like this site man thx <a href=" http://www.diigo.com/profile/youporno ">porntube vs youporno</a> =) <a href=" http://www.diigo.com/profile/hqtube ">hq tube movies</a>

Very funny pictures <a href=" http://www.imeem.com/people/IlkRNIP ">april hunter tits</a> naqq

interesting site man 10x <a href=" http://ourmedia.org//user/168813 ">redtube fullscreen</a> =) <a href=" http://ourmedia.org//user/168814 ">www pornhub</a>

great site thanks <a href=" http://forums.invisionpower.com/index.php?showuser=134890 ">downloading from redtube</a> =) <a href=" http://forums.invisionpower.com/index.php?showuser=134891 ">pornhub con</a>

real beauty page <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/g7IxTQow/finder_air_travel_finder ">cheapest airline tickets flights</a> dbgehs <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/-zIaA6E8/first_class_airline_tickets ">robots lowest fares travel tickets </a> >:OOO <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/VXwmm1qp/favicon_quantas_airlines ">Favicon Quantas Airlines</a> >:PP <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/k9G_Rd-f/first_class_airline_flights_tracking ">cheap airline tickets</a> 54233 <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/cJKq0XlR/first_class_airline_discount_central ">cheap airline tickets</a> 2210

Excellent work, Nice Design <a href=" http://www.imeem.com/people/s8Vox6y/blogs/2008/07/15/h0oI9d_l/air_line_tickets ">robots lowest fares travel tickets </a> 154 <a href=" http://www.imeem.com/people/s8Vox6y/blogs/2008/07/14/_fhj1sh5/air_flight_orbitz_travel ">first class cheap student airlines flights</a> =PPP <a href=" http://www.imeem.com/people/s8Vox6y/blogs/2008/07/14/lFSHXHvN/air_canada_vacations ">discount airline tickets</a> =]]] <a href=" http://www.imeem.com/people/s8Vox6y/blogs/2008/07/15/MXzCl8eQ/air_france_airlines ">first class cheap student airlines flights</a> aeyg <a href=" http://www.imeem.com/people/s8Vox6y/blogs/2008/07/15/YywBGB6s/air_force_inns ">robots lowest fares travel tickets </a> abqh

beautiful site thx <a href=" http://forums.invisionpower.com/index.php?showuser=134892 ">www youporno conm</a> =) <a href=" http://forums.invisionpower.com/index.php?showuser=134893 ">hq tube tv</a>

It's serious <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/BWneyIzX/first_class_cheap_airline_fares ">cheap airline tickets</a> emuovv <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/EAjfSEyd/first_class_austrian_airlines ">discount airline tickets</a> 351 <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/Gb2xjEAm/first_class_american_airlines_home ">first class cheap student airlines flights</a> 72728 <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/BzDqjBIi/first_class_cheap_airfares_flights_travel ">discount airline tickets</a> =-(( <a href=" http://www.imeem.com/people/MbM0ntq/blogs/2008/07/19/DYkYjFAs/first_class_bid_on_airline_tickets ">First Class Bid On Airline Tickets</a> 05160

Ruby Geohasher v1.1

This implementation IS FULLY 30W-compliant.

ScottKuma did this as a first excursion into Ruby. Yes, it's long. Yes, it's kinda clunky. However, IT WORKS!

Any changes, suggestions, etc. are happily accepted!


#!/usr/bin/ruby
#geohasher.rb

# Can be run without any command-line arguments (and gets the current geohash for the graticule specified in myLat and myLong, below),
# a single argument (the date in YYYY-MM-DD or YYYY/MM/DD format), 
# two arguments (the latitude & longitude "base" coordinates), 
# or three arguments (latitude & longitude "base" coordinates, followed by the date),
# or four arguments:  (latitude & longitude "base" coordinates, the date, then the desired opening #),

require 'net/http'

myLat = "39"	# Change me to set the desired default graticule's latitude
myLong = "-84"	# Change me to set the desired default graticule's longitude

def hexFracToDecFrac(hexFracPart)
	#I wish I had a neat little algorithm to do this in one line - but this works!
	#NOTE:  do not feed the preceding "0." to this function....only the fractional part (the part after the decimal point)
	fracLen = hexFracPart.length
	fracPortion = hexFracPart[0..(fracLen-1)]
	fracLen = fracPortion.length
	myLen = (fracLen - 1)
	sum = 0	
	for i in (0 .. myLen)
		numSixteenths = fracPortion[i..i].to_i(16)
		conversionFactor = (16.**(i+1)).to_f
		conversionFactor = 1./conversionFactor
		sum = sum + ((numSixteenths) * conversionFactor)
	end
	return sum.to_s[2..8]
end

t=Time.now
myDate = t.strftime("%Y-%m-%d")
dow = ""

if ARGV.length == 1
	myDate = ARGV[0]
end

if ARGV.length == 2
	myLat = ARGV[0]
	myLong = ARGV[1]
end
	
if ARGV.length == 3
	myLat = ARGV[0]
	myLong = ARGV[1]
	myDate = ARGV[2]
end

if ARGV.length == 4
	myLat = ARGV[0]
	myLong = ARGV[1]
	myDate = ARGV[2]
	dow = ARGV[3]
end

dateSplit = ''
if myDate.split('/').length == 3
	dateSplit = myDate.split('/')
else
	dateSplit = myDate.split('-')
end

myDate = Date.civil(dateSplit[0].to_i, dateSplit[1].to_i, dateSplit[2].to_i)

#fix for the "-30 rule"
fixDate = Date.civil(2008,05,25)
timeDelta = 0
if myLong.to_i > -30 and (myDate > fixDate)
	puts "-30 rule in effect!"
	timeDelta = 1
end

algorithmEncodedDate = myDate.to_s
urlEncodedDate = (myDate - timeDelta).strftime('%Y/%m/%d')

baseURL = 'irc.peeron.com'
basePath = '/xkcd/map/data/'
fullPath = basePath + urlEncodedDate
if dow==""
  Net::HTTP.start(baseURL,80) do |http|
    dow = http.get(fullPath).body
  end
end

if !dow.include? "404 Not Found"
	ghash = algorithmEncodedDate+'-'+dow
	digest = Digest::MD5.hexdigest(ghash)
	digest1 = digest[0..15]
	digest2 = digest[16..31]
	puts "(" + myLat + "." + hexFracToDecFrac(digest1) + ", " + myLong + "." + hexFracToDecFrac(digest2) + ")"
else 
	puts "Dow information not available for "+urlEncodedDate
end


Here's one way you could do hex to dec fraction in one line - it's "little", I'm not so sure about "neat"

def hexFracToDecFrac hexFracPart
  hexFracPart.split('').inject((cf=1)-1){|sum,c|sum+ c.to_i(16)/(cf<<=4).to_f}.to_s[2..8]
end

macHasher

This implementation IS FULLY 30W-compliant.
macHasher screenshot

Scottkuma worked feverishly to:

  1. learn Apple OSX Programming and...
  2. put together a geohash calculator for the Mac.

Installation:

It's a normal mac application - drag it to your Applications folder, OR just run it from inside the DMG. I think I compiled it as a Universal Binary. If you can't run it on a particular system and/or version of OSX, please let me know.

Usage:

Start by entering your graticule's Lat/Long numbers. The given numbers are for Cincinnati, Ohio.

For today's graticule, just click "Generate!" For dates in the past (or the near-future, for Saturday & Sunday graticules), select the date on the calendar, then click "Generate!"

Known bugs:

  • Requires a valid network connection; locks pretty good when one doesn't exist.
  • does not calculate east of -30 correctly for dates prior to 5/27/2008
  • window doesn't lock its size like I thought it would...

Planned enhancements:

  • will allow for saving of a known "home" location
  • will calculate distance & bearing to a known location
  • will calculate same for adjacent graticules to find a closer geohash

Geohash for the iPhone

This implementation IS FULLY 30W-compliant.
Geohash screenshot

Geohash for the iPhone is available here in the app store (for free).

The new version of Geohash now supports looking forward over the weekend. Yay!

Next feature up? The most requested feature by far is the ability to view Geohash locations in surrounding graticules. I'm working on it, trust me.  :) Unfortunately, I'm off to vacation in Spain in a couple days, so I probably won't have it done until I get back in September. Sorry! I may try to release an interim version which lets you modify your graticule in a kludgy fashion. It'll work, but won't be up to the full vision I have for this feature.

I'll also be publishing the source code when I get a chance. (Update: I'm still a little unsure about the implications of Apple's NDA on their SDK. I'm trying to determine if releasing the source violates the NDA or not. It'll be out for sure once I make sure I won't get spanked by Apple!)

Thanks to Scottkuma for a spot of help with the MD5 hash conversion.

PS. Obviously, feel free to leave reviews on the app store telling everyone what you think, good and bad, but also send feedback to me (casey@kckd.org), so I can respond directly!