Skip to content

Instantly share code, notes, and snippets.

View andrewxhill's full-sized avatar

Andrew W. Hill andrewxhill

View GitHub Profile
@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 :)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andrewxhill
andrewxhill / index.html
Created August 19, 2015 12:57
USPO map lives again!
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>CartoDB + Time</title>
<link rel="shortcut icon" href="http://cartodb.com/favicon/favicon_32x32.ico" />
<style>
html, body, #map {
@andrewxhill
andrewxhill / index.html
Created July 27, 2015 20:44
list all points at a point
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--Edit the title of the page-->
<title>CartoDB Point Clustering</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" />
@andrewxhill
andrewxhill / description.md
Created June 23, 2015 18:34
How the Twitter Template works

Step 1, provide a viz.json

This is the obvious step. My template then just grabs the viz.json and reads some basic information from it, including username and tablename.

Step 2, set the bounds

Okay, this was a bit of guessql. So, it creates the grid and measures all the points in each cell. It then selects the most dense cells that account for the first 60% of records. It then uses those to create the bounding box for the map :)

SELECT the_geom 
@andrewxhill
andrewxhill / change_log.sql
Last active August 29, 2015 14:23
Create a table to store changes from any of your tables in a log table.
--
-- Create a table in your CartoDB editor called 'version_control'
-- Run the following SQL in your editor to create the needed columns
--
ALTER TABLE version_control ADD COLUMN data json;
ALTER TABLE version_control ADD COLUMN source_id integer;
ALTER TABLE version_control ADD COLUMN table_name text;
ALTER TABLE version_control ADD COLUMN tg_op text;
@andrewxhill
andrewxhill / app.js
Last active August 29, 2015 14:21
currency map
// NODE.JS app
// Harvest Yahoo Finance and update CartoDB
var express = require('express');
var app = express();
var http = require('http'),
https = require('https'),
querystring = require('querystring'),
Step = require('step'),
fs = require('fs');