Skip to content

Instantly share code, notes, and snippets.

View kenton's full-sized avatar

Kenton Newby kenton

View GitHub Profile
@kenton
kenton / gist:1597674
Created January 12, 2012 00:22
Shell command to copy all gemsets from one ruby version to another
# you'll need to adjust the names of the source and destination ruby versions
# you may also need to adjust the number of fields that are cut (the -f 7 flag in the cut command) if the output of "rvm gemset list" changes at some point down the road
rvm gemset list | sed 's/^[[:space:]]*//' | cut -d ' ' -f 7 | while read gemset; do rvm gemset copy 1.9.2@$gemset 1.9.3@$gemset; done
(@ondemand)(1m|feature/ondemand-geogrid!?) ~limos $ git pull origin feature/ondemand-geogrid
From ldc.beanstalkapp.com:/ldc-git
* branch feature/ondemand-geogrid -> FETCH_HEAD
Auto-merging lib/ondemand/pricing/geographic_shapes/disambiguation.rb
Auto-merging lib/ondemand/pricing/TESTING.txt
Merge made by the 'recursive' strategy.
app/models/geographic_shape.rb | 3 ++-
lib/ondemand/pricing/TESTING.txt | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/ondemand/pricing/geographic_generator/market_geometries.rb | 9 +++++++-
lib/ondemand/pricing/geographic_shapes/database_installer.rb | 6 ++++-
>> dropoff_coords = "37.3716, -121.921"
=> "37.3716, -121.921"
>> pickup_coords = "37.3741595214844, -121.925221923828"
=> "37.3741595214844, -121.925221923828"
>> quote = Ondemand::Pricing::Ride::QuoteRide.new_from_rate_card(:dropoff_latlng => dropoff_coords, :pickup_latlng => pickup_coords)
{"rows":[{"elements":[{"status":"ZERO_RESULTS"}]}],"destination_addresses":["37.368,-42.2769"],"status":"OK","origin_addresses":["37.3769933814132,-42.2951683058561"]}
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
from /Users/kentonnewby/dev/limos/lib/ondemand/pricing/routes/google_distance_matrix_api/request.rb:94:in `perform'
>> pickup_coords = "37.7296575656584,-122.45277792457"
>> dropoff_coords = "37.7835680142054,-122.469833645424"
=> "37.7835680142054,-122.469833645424"
>> quote = Ondemand::Pricing::Ride::QuoteRide.new_from_rate_card(:dropoff_latlng => dropoff_coords, :pickup_latlng => pickup_coords)
#<Ondemand::Pricing::Formula:0x10a3088c8
@kind=:quote,
@market_rate=#<BigDecimal:10a2fd7e8,'0.2E2',9(27)>,
@minimum_price=#<BigDecimal:10a2fd928,'0.15E2',9(27)>,
@pricing_tiers=nil,
@ride=
# variables set in the controller's setup method:
@pickup_coords = "37.7970456263422,-122.395925521724"
@valid_dropoff_coords = "37.7835680142054,-122.469833645424"
@out_of_range_dropoff_coords = "35.5,-119.5"
# the controller test...
test "returns an empty price and the correct response code when user requests dropoff location too far from center of OndemandMarket" do
# calling this curl command from command line
(@ondemand)(1282m|feature/ondemand-geogrid!?) ~limos $ curl http://localhost:3000/od/rate_card/from/37.7970456263422,-122.395925521724/\?token\=ABC123
# gives this response
# I edited the result returned when a generic exception is raised to also include the backtrace
{"error_message":"'NoMethodError',
'undefined method `lng' for \"37.7970456263422,-122.395925521724\":String',
/Users/kentonnewby/dev/limos/lib/ondemand/pricing/grid/geo_helpers.rb:18:in `latlng_to_point'
/Users/kentonnewby/dev/limos/lib/ondemand/pricing/geographic_shapes/lazy_grid_lookup.rb:35:in `find'
/Users/kentonnewby/dev/limos/lib/ondemand/pricing/rate_card.rb:26:in `get_pickup'
1) Failure:
test_POST_ondemand_ride_hail_status_completed(Ondemand::RideControllerTest)
[test/functional/ondemand/ride_controller_test.rb:287:in `test_POST_ondemand_ride_hail_status_completed'
/Users/kentonnewby/.rvm/gems/ruby-1.8.7-p334@ondemand/gems/after_commit-1.0.10/lib/after_commit/connection_adapters.rb:14:in `transaction'
test/functional/ondemand/ride_controller_test.rb:237:in `test_POST_ondemand_ride_hail_status_completed']:
<nil> expected to not be nil.
# saving tiers to the DB
> market = OndemandMarket.first
> market.pricing_tiers = { :first_five_minutes => 3.0, :second_five_minutes => 2.5, :additional_minutes => 1.0 }
> market.save
# pulling tiers from the DB
> market.pricing_tiers
{ :first_five_minutes => 3.0, :second_five_minutes => 2.5, :additional_minutes => 1.0 }
# to update rows on a table
@kenton
kenton / development.log
Created June 6, 2012 20:39
Error message
Started POST "/users/login" for 127.0.0.1 at 2012-06-06 16:38:28 -0400
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"JbvUKZgnvn1Do1coifcSqnhptH69MUsqXVupqItL6Xw=", "user"=>{"email"=>"george@example.com", "password"=>"[FILTE>
Completed 401 Unauthorized in 1ms
Processing by Devise::SessionsController#new as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"JbvUKZgnvn1Do1coifcSqnhptH69MUsqXVupqItL6Xw=", "user"=>{"email"=>"george@example.com", "password"=>"[FILTE>
Rendered devise/shared/_links.erb (0.4ms)
Rendered devise/sessions/new.html.erb within layouts/devise/sessions (2.9ms)
Completed 200 OK in 7ms (Views: 5.7ms | ActiveRecord: 0.0ms)
Loading Configuration Settings!
Loading Configuration Settings from file: /Users/kentonnewby/dev/limos/config/application_configuration.yml
Loading Configuration Settings from file: /Users/kentonnewby/dev/limos/config/application_configuration_development.yml
== ChangePrivateRatePoliciesTableSchema: migrating ===========================
-- Altering private_rate_policies table
-- execute("ALTER TABLE private_rate_policies ADD unique index_prp_on_id (id);")
rake aborted!
An error has occurred, all later migrations canceled:
Mysql::Error: Duplicate key name 'index_prp_on_id': ALTER TABLE private_rate_policies ADD unique index_prp_on_id (id);