Skip to content

Instantly share code, notes, and snippets.

View tristen's full-sized avatar

Tristen Brown tristen

View GitHub Profile
@tmcw
tmcw / index.html
Created August 30, 2012 22:10
mapbox.js + WMS
<!DOCTYPE html>
<html>
<head>
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.5/mapbox.js'></script>
<script src='sphericalmercator.js'></script>
<link href='http://api.tiles.mapbox.com/mapbox.js/v0.6.5/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
@tmcw
tmcw / index.html
Last active April 30, 2016 20:52
Running year-by-year
<html>
<head>
<title>runs over time</title>
<style>
body { margin: 0; padding: 0; background:#f8f8f8; }
svg {
font: 10px sans-serif;
}
path {
stroke: steelblue;
@tmcw
tmcw / index.html
Created August 22, 2012 14:31
MapBox + d3
<!DOCTYPE html>
<html>
<head>
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.4/mapbox.js'></script>
<script src='http://d3js.org/d3.v2.min.js?2.9.3'></script>
<link
href='http://api.tiles.mapbox.com/mapbox.js/v0.6.4/mapbox.css'
rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@tmcw
tmcw / togeo.py
Created August 11, 2012 18:53
geo-assign any arbitrary image to a geotiff usable in tilemill
import subprocess
import sys, re
MERC = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs'
infile = sys.argv[1]
info_output = subprocess.Popen(['gdalinfo', infile], stdout=subprocess.PIPE).communicate()[0]
size_is_re = re.compile('Size is (?P<width>\d+), (?P<height>\d+)')
size_is = filter(lambda x: x, map(lambda x: size_is_re.match(x), info_output.split('\n')))
@gka
gka / index.html
Created July 11, 2012 06:40
How to use HCL in d3.js
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
padding: 14px;
}
(function($) {
$.fn.mapbox = function() {
return this.map(function(x) {
var $this = $(this);
if (!$this.data('map')) $(this).data('map', mapbox.map(this));
return $this.data('map');
});
};
})(jQuery);
@tristen
tristen / README.md
Last active October 5, 2015 07:28
Hash

Hash

Best to download this example to see the full effect outside of an iframe. Explore the anchor links in the example above. The hash links are refresh the map to the exact coordinates described.

Contributors

var points = [];
var clusters = {};
points.map(function(x) {
if (clusters[x.coordinates.join(',')]) {
clusters[x.coordinates.join(',')].push(x);
}
clusters[x.coordinates.join(',')] = [x];
});
@tristen
tristen / README.md
Last active June 21, 2016 22:15
Great Circle

Great Circle

Create an arc like shape by specifying two points and drawing the points between them using HTML canvas

Contributors