Skip to content

Instantly share code, notes, and snippets.

@maphew
maphew / broken-raw-string-example.py
Last active February 21, 2016 20:30
python 2.7.8 broken raw string?
import os
import sys
wspace = r'D:\Feb-19'
tile = '116o'
ex1 = os.path.join(wspace, r'Work_{}\scratch.gdb'.format(tile))
ex2 = os.path.join(wspace, r'\Work_{}\scratch.gdb'.format(tile))
print(sys.version)
print('''\n--- Expected ---
# ./my_cli/cli.py
# wrapper created for console_scripts to run 'tools/multi_main'
import os
import sys
here = os.path.abspath(os.path.dirname(__file__))
def multi_main(argv):
fname = os.path.join(here, '../tools', 'multi_main.py')
@maphew
maphew / readme.md
Last active July 25, 2016 22:28
"Roads and Bridges: the unseen labor behind our digital infrastructure" -- crudely reformatted from PDF to HTML using MS Word 2013. Mostly legible, but has significant layout issues. Refer to original in case of confusion: http://www.fordfoundation.org/library/reports-and-studies/roads-and-bridges-the-unseen-labor-behind-our-digital-infrastructure/

Roads and Bridges: the unseen labor behind our digital infrastructure

by Nadia Eghbal

This is a copy, crudely reformatted from PDF to HTML using MS Word 2013. It has significant layout issues and no images, but should be mostly legible on small screens.

Refer to original in case of confusion:
http://www.fordfoundation.org/library/reports-and-studies/roads-and-bridges-the-unseen-labor-behind-our-digital-infrastructure/

Read rendered gist version:
https://cdn.rawgit.com/maphew/2d0f6b0c9b5d4f96d6f4509b0011b352/raw/b3c0a8c82bd77e7a75bebe9a2672623926fdfb11/roads-and_filtered.html

@maphew
maphew / yt-meteo.html
Created December 7, 2016 02:56
Meteo Earth, centred over the Yukon Territory
<script type='text/javascript' src='http://www.meteoearth.com/service/me.js'></script>
<div id='meDiv' style='width:420px;height:420px;background:#000;position:relative'></div>
<script type='text/javascript'>var meConfig={div:document.getElementById('meDiv'),viewSettings:{longitude: -132.8662,latitude: 65.7642,zoom:8.3868,is3DEnabled:true,isLightingEnabled:true, isPrecipitationEnabled:true, isWindEnabled:true}};me_createView(meConfig);</script>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maphew
maphew / qgis-vector-polygonize-output.geojson
Last active June 27, 2017 19:18
How to create polygons from this geojson grid, using pure javascript or tools available to Node.js? From https://gis.stackexchange.com/questions/245277/how-to-create-geojson-polygons-from-lines
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maphew
maphew / points-with-names.geojson
Created June 27, 2017 20:46
A few geojson points with a 'Name' attribute to use for labelling
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@echo off
echo.
echo. Manually registering custom ArcGIS COM tools in the current folder...
echo.
setlocal
set PATH=%PATH%;C:\Program Files (x86)\Common Files\ArcGIS\bin;C:\Program Files\Common Files\ArcGIS\bin
for %%a in (*.dll) do ESRIRegAsm.exe "%%~dpna"
endlocal
@maphew
maphew / asc2json.ps1
Last active October 18, 2017 20:41
Convert Arcinfo Ascii Grid file to JSON
# asc2json
# Convert Arcinfo Ascii Grid file to JSON
# RegEx replace:
# - strip leading whitespace
# - strip line not beginning with a number
# - add opening `[` to beginning of line
# - space to comma
# - end of line to `],`
# - strip empty list `[],`
@maphew
maphew / fetch-renderer.py
Last active October 26, 2017 22:33
How to change or assign ArcMap layer symbology type from python?
#Interactive Python window in ArcMap
import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "*", df)[0]
renderer = lyr._arc_object.renderer
>>> renderer
u"<Renderer xsi:type='typens:RasterClassifyRenderer' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
...snip...