Skip to content

Instantly share code, notes, and snippets.

View andrewxhill's full-sized avatar

Andrew W. Hill andrewxhill

View GitHub Profile
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
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'},
@andrewxhill
andrewxhill / static_map.py
Created April 14, 2016 21:49
Get a static map from a viz.json using python
import sys
import urllib
import urllib2
import json
import requests
basemap = {
"type": "http",
"options": {
"urlTemplate": "http://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}.png"
@andrewxhill
andrewxhill / README.md
Created March 18, 2016 19:13
Example of a CartoDB iframe in the Amp library

Example of a CartoDB iframe in the Amp library

@andrewxhill
andrewxhill / minimum_spanning_tree.sql
Created March 13, 2016 14:07
Minimum spanning tree in SQL... just because
CREATE TYPE minimum_spanning_tree_internal AS (
d NUMERIC[],
a INT[],
b INT[],
geoms GEOMETRY[],
ids TEXT[]
);
CREATE TYPE minimum_spanning_tree_unit AS (
d NUMERIC,
@andrewxhill
andrewxhill / README.md
Created January 28, 2016 18:12
Static Image Generator Example

A basic class that allows you to quickly generate static images from the CartoDB API using custom CartoCSS builders etc.

@andrewxhill
andrewxhill / index.html
Created November 10, 2015 21:34
fixed election map
<!DOCTYPE html>
<html>
<head>
<title>Election Mapping Bonanza</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,700|Open+Sans+Condensed:300,700' rel='stylesheet' type='text/css'>
<style>