This Dashing Dashboard widget allows you to see an estimate of how close the nearest Uber driver is to your location (in minutes). Useful if you're planning a fast getaway from the office.
Go ahead and register an application with Uber. It is a relatively painless process if you already have an Uber account.
From that, you really only need one of the credentials, the Server Token
. The other stuff is helpful if you are building a full-fledge OAuth application that can request rides, etc. This one just polls a single endpoint.
Your next step is to get the latitude and longitude of wherever this Dashboard lives. The easiest way to do this is to key your address into Google Maps and look in the address bar for the two sets of numbers. If your location is accidentally located in the middle of the ocean, try reversing them.
To recap, get this stuff:
- The server token from your registered application
- The latitude and longitude of your location
This is what polls the API for the estimated time to arrival (in seconds) per "product". A product, in Uber-land, refers to the kind of car that will come pick you up, with UberX being the small sedans, Uber XL the larger SUVs and Uber Black Car the more "formal" car service. Products will change based on the location you obtained above.
Place the uber.rb
file in the ./jobs
folder. You will need to either have the information above loaded as the referenced environment variables (recommended), or simply hard-code in those values into the Ruby code.
I did not do a custom widget for this iteration, so it simply uses the List widget. You can get more creative with styling if you want to.
<li data-row="1" data-col="1" data-sizex="2" data-sizey="2">
<div data-id="uber_pickup_time" data-view="List" data-unordered="true" data-title="Get an Uber" data-moreinfo="Estimated time to pickup from current location."></div>
<i class="icon-time icon-background"></i>
</li>