Skip to content

Instantly share code, notes, and snippets.

View mick's full-sized avatar

Mick Thompson mick

View GitHub Profile
@mick
mick / redshift_quadkey_udf.sql
Created September 10, 2020 03:15
Quadkey UDFs
create or replace function latlng_to_quadkey (lat float, lng float, zoom int)
returns varchar
STABLE
as $$
import math
if lng is None or lat is None:
return None
lat = float(lat)
lng = float(lng)
@mick
mick / readme.md
Last active January 17, 2017 17:02
Use Plotly to generate a chart from Mapbox Analytics

First your need plotly npm package, and a plotly account.

npm install plotly export PLOTLY_USERNAME=<plotly-username> export PLOTLY_APIKEY=<plotly-apikey> export MAPBOX_ACCESS_TOKEN=<your-mapbox-token>

To generate a image: curl --silent "https://api.mapbox.com/analytics/v1/accounts/?period=2016-01-01,2016-04-29&amp;access_token=$MAPBOX_ACCESS_TOKEN" | ./render-image.js &gt; chart.png

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Toggling layers</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox.js/v2.1.9/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v2.1.9/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.