Skip to content

Instantly share code, notes, and snippets.

💭
merging your prs

Tom MacWright tmcw

💭
merging your prs
Block or report user

Report or block tmcw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tmcw
tmcw / xyz_vs_tms.md
Last active Nov 18, 2019
The difference between XYZ and TMS tiles and how to convert between them
View xyz_vs_tms.md

The difference between XYZ and TMS tiles and how to convert between them

Lots of tile-based maps use either the XYZ or TMS scheme. These are the maps that have tiles ending in /0/0/0.png or something. Sometimes if it's a script, it'll look like &z=0&y=0&x=0 instead. Anyway, these are usually maps in Spherical Mercator.

Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps.

Most of those are in XYZ. The best documentation for that is slippy map tilenames on the OSM Wiki, and Klokan's Tiles a la Google.

@tmcw
tmcw / togeo.py
Created Aug 11, 2012
geo-assign any arbitrary image to a geotiff usable in tilemill
View togeo.py
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')))
View SP500.csv
DATE SP500
2009-10-26 1066.95
2009-10-27 1063.41
2009-10-28 1042.63
2009-10-29 1066.11
2009-10-30 1036.19
2009-11-02 1042.88
2009-11-03 1045.41
2009-11-04 1046.50
2009-11-05 1066.63
@tmcw
tmcw / d3.md
Last active Oct 27, 2019
Accompaniment to dcjq
View d3.md

This is a more wordy, narrative accompaniment to my pretty bare presentation about d3 that I gave to the jQuery DC Meetup.

What is d3?

  • Not a chart library (though you can make charts with it)
  • Not a map library (though you can make maps with it)

Which is to say, d3 can be used for building things, but the 'atomic parts' are lower-level than bar graphs or projections or so on. This is a powerful fact. It also means that d3 is a good basis for simple interfaces, like Vega.js, that make its power accessible in other ways.

  • Not a compatibility layer (it doesn't work with bad browsers)
@tmcw
tmcw / README.md
Created Oct 31, 2012
GIS with Python, Shapely, and Fiona Example 1 - CSV Files
View README.md
@tmcw
tmcw / README.md
Created Mar 31, 2017
Managing GitHub Watching en masse
View README.md

Managing GitHub Watching

I decided to unwatch many repos in multiple organizations. Here are two scripts that I wrote to make that possible. It works like:

  1. I load GitHubAccessToken in my environment, an environment variable that gives these access
  2. I run node get-all-watched.js > all-watching.txt to dump all watching into a text file
  3. Run grep "^developmentseed" all-watching > developmentseed.txt, for instance, to make a text file of only repos in the developmentseed org that I'm watching
  4. Run node unwatch-file-of-repos.js developmentseed.txt to unwatch all those repos.
View .vimrc
call plug#begin('~/.vim/plugged')
Plug 'justinmk/vim-dirvish'
Plug 'tpope/vim-vinegar'
Plug 'ElmCast/elm-vim'
" Git
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-fugitive'
View gist:a5507b337d9fd05511ca50051ccd677e
(-------------List output---------- )
341 55
342 55
343 55
344 55
340 56
347 56
338 57
336 58
337 58
View gist:97d3e1e8ddc413e6e784c71820206d4e
(-------------List output---------- )
341 55
342 55
343 55
344 55
340 56
347 56
338 57
336 58
337 58
You can’t perform that action at this time.