Skip to content

Instantly share code, notes, and snippets.

View andrewxhill's full-sized avatar

Andrew W. Hill andrewxhill

View GitHub Profile
@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>
@andrewxhill
andrewxhill / suncalc.sql
Last active September 14, 2016 12:07
Test of SunCalc in SQL
-- Test of porting SunCalc to SQL
-- Original SunCalc https://github.com/mourner/suncalc
-- Original SunCalc License https://github.com/mourner/suncalc/blob/master/LICENSE
CREATE TYPE suncalc_position AS (
azimuth decimal,
altitude decimal
);
CREATE TYPE suncalc_coords AS (
declination decimal,
rightAscension decimal
@andrewxhill
andrewxhill / yahoo.py
Created September 18, 2015 17:59
Use yahoo string geolocation api and drop results into cartodb
#!/usr/bin/env python
import string
import sys
import urllib
import urllib2
#Uses Yahoo Placemaker and the python-placemaker library
from placemaker import placemaker
@andrewxhill
andrewxhill / index.html
Last active May 27, 2016 17:05
Simple createLayer
<!doctype html>
<html>
<head>
<title>createLayer</title>
<link href='http://fonts.googleapis.com/css?family=Alike' rel='stylesheet' type='text/css'>
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
@andrewxhill
andrewxhill / harvest_a_game.ipynb
Last active September 1, 2015 12:38
Use Goldberry to harvest a single basketball game and push it to CartoDB. WARNING This will pull ~2-3,000,000 points, so probably not for your typical free CartoDB account :)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.