This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"reservations":[ | |
{reservation JSON object} | |
], | |
"page":1, | |
"total":9, | |
"total_pages":2, | |
"links":[ | |
{ | |
"rel":"next_page", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id":16, | |
"name":"New York Marriott Marquis", | |
"phone":"1 212-3981900", | |
"full_address":"1535 Broadway, New York, NY, 10036, US", | |
"latitude":40.758408, | |
"longitude":-73.985517, | |
"checkout_time":null, | |
"time_zone":"America/New_York", | |
"address":{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Automatically adds lock_version to model forms if the underlying | |
# model has locking_enabled. | |
module ActionView | |
module Helpers | |
module OptimisticLockingFormFor | |
def self.included(base) | |
base.alias_method_chain :form_for, :optimistic_locking | |
base.alias_method_chain :fields_for, :optimistic_locking | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "address" : { "city" : "Sao Chingcha", | |
"country" : "TH", | |
"postcode" : null, | |
"state" : "Krung Thep Mahanakhon", | |
"street" : null | |
}, | |
"featured_article" : { "copy" : "Thailand may be best known for post-collegiate backpacking and beach-bumming, but thousands jet there each year for the endless spa and wellness offerings, not to mention the welcoming Buddhist vibe, cheaper prices, and jaw-dropping beaches. Find nirvana—spiritually and physically—at two of Bangkok's plushest pampering destinations, both recently pimped out with huge expansions. All treatments at the uber-plush Peninsula begin with a tea ritual and ginger foot buff, while the The Oriental Bangkok's debut of its Ayurvedic Penthouse means you'll be covered from head to toe with rejuvenating mind-body bliss.", | |
"credit_name" : "Tracie Broom", | |
"credit_url" : "https://openplac.es/users/traciebroom" | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "next_page" : "https://api.openplac.es/api/places.json?page=2", | |
"page" : 1, | |
"places" : [ { "address" : { "city" : "Sao Chingcha", | |
"country" : "TH", | |
"postcode" : null, | |
"state" : "Krung Thep Mahanakhon", | |
"street" : null | |
}, | |
"featured_article" : { "copy" : "Thailand may be best known for post-collegiate backpacking and beach-bumming, but thousands jet there each year for the endless spa and wellness offerings, not to mention the welcoming Buddhist vibe, cheaper prices, and jaw-dropping beaches. Find nirvana—spiritually and physically—at two of Bangkok's plushest pampering destinations, both recently pimped out with huge expansions. All treatments at the uber-plush Peninsula begin with a tea ritual and ginger foot buff, while the The Oriental Bangkok's debut of its Ayurvedic Penthouse means you'll be covered from head to toe with rejuvenating mind-body bliss.", | |
"credit_name" : "Tracie Broom", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
coordinate_map = Destination.only(:id, :coordinates).all.inject({}) {|h, d| h[d.id.to_s] = d.coordinates.reverse; h} | |
user_count = User.where(destination_id: nil).count | |
0.step(user_count, BATCH_SIZE) do |offset| | |
User.where(destination_id: nil).limit(BATCH_SIZE).skip(offset).each do |user| | |
next unless user.coordinates.present? | |
# This used to be a one-liner but broke it up to see if it helped mem-usage | |
distances = coordinate_map.each_with_object({}) {|(k,v), h| h[k] = user.distance_from(v)} | |
destination_id = distances.min_by(&:last).first | |
user.update_attribute(:destination_id, destination_id) rescue nil | |
distances = nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The problem below is that the JS responses were not being cached properly | |
# but the HTML responses were fine. | |
caches_action :show, :layout => false, :expires_in => 24.hours | |
def show | |
respond_to do |wants| | |
wants.html | |
wants.js { | |
# What... the... fuck... After tracing why the JS responses to this action |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.collection.find( { latlng : { $near : [50,50] , $maxDistance : 5 } } ) | |
> db.collection.find( { latlng : { $maxDistance : 5 , $near : [50,50] } } ) | |
error: { | |
"$err" : "missing geo field (latlng) in : { latlng: { $maxDistance: | |
5.0, $near: [ 50.0, 50.0 ] } }", | |
"code" : 13042 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scenario: Signup page - logged out # features/signup.feature:7 | |
Given I am not logged in # features/step_definitions/signup_steps.rb:1 | |
When I visit the signup page # features/step_definitions/signup_steps.rb:4 | |
Then I should see the signup page # features/step_definitions/signup_steps.rb:8 | |
WORLD: | |
Cucumber::Rails::World | |
WithinHelpers | |
NavigationHelpers | |
Capybara | |
Cucumber::Web::Tableish |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testing |