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

@mick
mick / README.md
Created February 17, 2013 03:31 — forked from mbostock/.block

This choropleth encodes unemployment rates from 2008 with a quantize scale ranging from 0 to 15%. A threshold scale is a useful alternative for coloring arbitrary ranges.

@mick
mick / geos-config
Created June 20, 2012 04:10
geos config
#!/bin/sh
prefix=/app/.geo/geos
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
usage()
{
cat <<EOF
Usage: geos-config [OPTIONS]
Options:
@mick
mick / gist:2221357
Created March 27, 2012 23:16
subscription with bounds
<iq type='set'
from='admin@talkback.im'
to='geo.talkback.im'
id='sub1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<subscribe
node='test'
jid='admin@talkback.im'/>
<options node='test' jid='admin@talkback.im'>
<x xmlns='jabber:x:data' type='submit'>
@mick
mick / steps.js
Created March 27, 2012 22:46
spark like steps for a given array
var list = [1,45,23,45,65,6,2];
var steps = 6;
var packed_list = [];
var min=0, max=0;
for(l in list){
if(min > list[l])
min = list[l];
@mick
mick / gist:1218084
Created September 14, 2011 23:17
slide gists
{
"_id": "_design/gc-utils",
"_rev": "2-bd8fcdf5509cb9cc99560a39f0c642f0",
"vendor": {
"clustering": {
"KNNCluster": "/**\n * kNN-based Clustering\n */\n(function() {\n\tvar cluster = this.cluster = {};\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tmodule.exports = cluster;\n\t}\n\t\n\t//TODO\n})();",
"ProximityCluster": "/**\n * Proximity based clustering\n */\n(function() {\n\n var proxcluster = this.proxcluster = {};\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tmodule.exports = proxcluster;\n\t}\n\n var gju = require('vendor/geojson-js-utils/geojson-utils');\n\n proxcluster.PointCluster = function(threshold){\n this.clusters = [];\n this.points = [];\n this.distanceThreshold = threshold;\n\n };\n \n proxcluster.PointCluster.prototype.addToClosestCluster = function(point) {\n var distance = 40000; // Some large number\n var clusterToAddTo = null;\n var pos = point.geometry;\n
@mick
mick / gist:1189405
Created September 2, 2011 18:28 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job: Web Developer at occipital.com
Favorite Python project: graphite
Favorite Conference: OSCON.
Python Experience Level: Advanced. 5yr+
"""HTTP/1.1 client library
<intro stuff goes here>
<other stuff, too>
HTTPConnection goes through a number of "states", which define when a client
may legally make another request or fetch the response for a particular
request. This diagram details these state transitions:
(null)
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="guid"
t3st15
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="count"
2
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="userid"