I hereby claim:
- I am jeroenroodnat on github.
- I am jeroenroodnat (https://keybase.io/jeroenroodnat) on keybase.
- I have a public key whose fingerprint is C85D 624C F094 F036 3996 BCC0 1C46 C7F9 6D7A 59F7
To claim this, I am signing this object:
require 'net/dns/resolver' | |
# Custom Domain | |
# | |
# Require net-dns gem | |
# | |
# A Rack middleware to to resolve the custom domain to original subdomain | |
# for your multi telent application. | |
# | |
# It's all transperant to your application, it performs cname lookup and |
## Based on example of http://gist.github.com/276455 but change to not use nokogiri but Activeresource | |
# define file in model directory | |
class Sixpp < ActiveResource::Base | |
class << self | |
# 6pp returns a xml where first item is hash. We need to enter hash["item"] and then check if there is 1 or more records. | |
def instantiate_collection(collection, prefix_options = {}) | |
unless collection["item"].kind_of? Array |
query = BSON::OrderedHash.new.tap do |query| | |
query["geoNear"]="locations" | |
query["near"] = lon_lat | |
end | |
lon,lat =lon_lat | |
query = Location.collection.db.command(query)['results'].sort_by do |r| | |
r['distance'] = Haversine.distance(lat,lon,r['obj']['lon_lat'][1],r['obj']['lon_lat'][0]) | |
end |
I hereby claim:
To claim this, I am signing this object: