Instantly share code, notes, and snippets.

View google-earth-perspective-to-geojson.js
#!/usr/bin/env osascript -l JavaScript
// usage: google-earth-perspective-to-geojson.js xSamples ySamples > currentPerspective.geojson
function run(argv) {
var xSamples = argv[0] || 50;
var ySamples = argv[1] || 50;
var ge = Application('Google Earth Pro');
#!/usr/bin/env python
# This script copies georeferencing information from one file to another that has none,
# via the creation of an .aux.xml file (so it should work with any image format).
# This is useful if, for example, you've edited a GeoTIFF in Photoshop,
# and saved the result as a JPG that you'd still like to be geo-aware for use
# with GDAL or QGIS.
# Requires GDAL command line tools, because re-making gdalbuildvrt in python
View closest_point_on_perimeter_of_rectangle.js
// translated from
function clamp(n,lower,upper) {
return Math.max(lower, Math.min(upper, n));
function getNearestPointInPerimeter(l,t,w,h,x,y) {
var r = l+w,
b = t+h;
View remove_googledocs_page_breaks.css
#docs-editor-container .kix-page-compact::before {
border-top: none;
View lockView.js
// Looks an element up by CSS selector and keeps it centered in the viewport on window resize
// Useful for testing responsive versions of specific DOM elements
// if jquery isn't loaded on the page, paste this code into the console first to load it:
var jqURL = '';
var jqscript = document.createElement('script');
jqscript.type= 'text/javascript';
jqscript.src = jqURL;

Experiments faking 3d rotation of a globe and sun in SVG. Illusion is helped by dynamic gradients, two nested orthographic projections, scaling the sun circle's radius based on distance from the 'camera', and toggling a clipping mask that makes the sun appear to move "behind" the earth.

Based on Mike Bostock's Solar Terminator and this past experiment.

This example stems from drafts of maps for Norway the Slow Way. Also see Mike's Pencil Sketch example.

View gist:2a6fb6f57850ef6e2829 (full book online)
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
.counties {
fill: none;
stroke: black;
# These are shell functions to quickly create pansharpened RGB images ready for color correction
# from a set of raw Landsat 8 TIF files in a given directory.
# For example:
# l8_pansharp LC81690352014169LGN00
# Creates:
# LC81690352014169LGN00_rgb_pansharp.tif
# l8_rush_pansharp downloads a L8 tile from Google Storage (if they have it), extracts the relevant bands, then creates the pansharpened output.
View l8get
# This is a shell function to quickly grab the data for a given Landsat 8 tile ID from Google's servers
# For example:
# l8get LC81690352014169LGN00
# The echo at the end is to remind myself of the syntax for extracting bands 8, 4, 3, and 2. (Pansharp, Red, Green, Blue)
# On OSX this would go into your ~/.bash_profile file.
# Requires gsutil from
# Most useful in conjunction with USGS' Earth Explorer: