Skip to content

Instantly share code, notes, and snippets.

Keybase proof

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:

@jeroenroodnat
jeroenroodnat / gist:849669
Created March 1, 2011 19:08
Mongo Geonear with Mongoid rough hack
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
@jeroenroodnat
jeroenroodnat / model.rb
Created January 17, 2010 11:41 — forked from hjblok/validate_by_6pp.rb
6PP KVDB with activeresource
## 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
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