Skip to content

Instantly share code, notes, and snippets.

View andrewxhill's full-sized avatar

Andrew W. Hill andrewxhill

View GitHub Profile

Keybase proof

I hereby claim:

  • I am andrewxhill on github.
  • I am andrewxhill (https://keybase.io/andrewxhill) on keybase.
  • I have a public key ASCQCpQbOhKgXK6xK9-Xo-2vx_oQgf9v6vW7q6S_ry6FFgo

To claim this, I am signing this object:

SetSDK.register(context: beforeCommute) { event as
// Send new information or an opportunity that will be valuable
let content = UNMutableNotificationContent()
content.title = "Weather Alert!"
// ...
}
let beforeCommute = SetSDK.Context(
notificationTiming: .upon,
eventAction: .exit,
eventState: .place(type: .home),
timeOfDay: .morning
)
class RideFinderViewController: UIViewController, CLLocationManagerDelegate {
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
locationManager.startUpdatingLocation()
class RideFinderViewController: UIViewController {
...
override func viewDidAppear(_ animated: Bool) {
// this view indicates an intent to go someplace
super.viewDidAppear(animated)
// Get the user's likely destinations using the SetSDK
// For custom control of starting location, see: http://bit.ly/getDestinationV1
// departure subscription
SetSDK.instance.onDeparture(.home) { departure in
// on departure, predict their likely destination
if let destinations = SetSDK.instance.getDestination(fromLocation: departure.location, fromTimestamp: departure.date), let destination = destinations.first {
// Process the top destination predictions
}
}
SetSDK.instance.onDeparture(.home) { departure in
// Turn off lights, kill the music, lock the doors
}
@andrewxhill
andrewxhill / Small Multiples.ipynb
Last active June 25, 2016 13:57
Create small multiples through the Static Maps API
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andrewxhill
andrewxhill / batchAPI.py
Last active May 16, 2018 16:01
quick example of using the batch api over python
import sys
import urllib
import urllib2
import json
import requests
# Start a new batch SQL task
def cartoBatchQuery(username, api_key, sql):
r = requests.post('http://%s.cartodb.com/api/v2/sql/job?api_key=%s' %(username,api_key),
headers={'content-type':'application/json'},