Skip to content

Instantly share code, notes, and snippets.

View output errors
('invoke task failed', {'invoke': 'postgis.add-polygons -l "newset" -d 22 -p s3://vp-dev-blob/vp-stewardship-atlas/Yuba_Subset-1.geojson.ld', 'stdout': '', 'stderr': 'OpenBLAS WARNING - could not determine the L2 cache size on this system, assuming 256k
DEBUG:invoke:Didn\'t see any /function/invoke.yaml, skipping.
DEBUG:invoke:Didn\'t see any /function/invoke.yml, skipping.
DEBUG:invoke:Didn\'t see any /function/invoke.json, skipping.
DEBUG:invoke:Merging config sources in order onto new empty _config...
DEBUG:invoke:Defaults: {\'run\': {\'asynchronous\': False, \'disown\': False, \'dry\': False, \'echo\': False, \'echo_stdin\': None, \'encoding\': None, \'env\': {}, \'err_stream\': None, \'fallback\': True, \'hide\': None, \'in_stream\': None, \'out_stream\': None, \'pty\': False, \'replace_env\': False, \'shell\': \'/bin/bash\', \'warn\': False, \'watchers\': []}, \'runners\': {\'local\': <class \'invoke.runners.Local\'>}, \'sudo\': {\'password\': None, \'prompt\': \'[sudo] password: \', \'user\': None}, \'
dsummersl /
Created Nov 29, 2018
Shell script snippets
# nounset: undefined variable outputs error message, and forces an exit
set -u
# errexit: abort script at first error
set -e
# print command to stdout before executing it:
set -x
getopt --test > /dev/null
View boundaries.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
dsummersl /
Created Mar 4, 2018
Extract population from NC VTD data.

I started with some tract level data:

ogr2ogr census_features Census_Features.gdb

There is a good data dictionary on the site at well, where I found that the total population is PL10AA_TOT:

dsummersl /
Last active Mar 9, 2021
Example shapefile to csv, and csv into shapefile.

Shapefile to CSV

There are many ways to work with GIS data. I've used QGIS (or cartodb and mapbox online) when I need to explore shapefiles. When building a map or application built on a map, I like to use command line tools. The examples below use the GDAL command line tools as a lot of GIS libraries use the GDAL libraries under the hood. If you're somewhat familiar with SQL, the tools can be a quick way to explore the contents of shapefiles in a scriptable way.

For the examples below I used shapefiles that I downloaded directly from the US census: North Carolina Census Tracts

This shapefile contains polygon regions for all census tracts in NC. For the purposes of clustering we may only want the centroid of each tract. To create a CSV of all tracts in the shapefile, only a couple commands are required:

dsummersl / story.json
Created Mar 1, 2018 cactus related story generation
View story.json
"cactus": ["scarlet crown cactus", "hedgehog cactus", "disco cactus", "saguaro", "prickly pear", "peyote cactus"],
"home": ["home","haven","pueblo","hidy hole","ground fissure"],
"animals": ["snakes","flies","little animals","hawks","rabbits","prairie dogs","mice","fruitflies"],
"cause": ["loves the sun", "thrives at twilight", "is a #home# for #animals#", "grows among the #cactus#"],
"growsup": ["reaches full maturity", "blooms", "moves into its #home#", "survives to the rainy season", "turns green", "grows out its #home#"],
"fulfillment": ["#animals# erupt from its skin", "many #animals# travel from their #home#s to eat it"],
"moral": ["The desert is beautiful!", "Isn't desert life amazing?","The desert rejoices.", "The #animals# are happy."],
"story": ["A #cc# #cause#. When the #cc# #growsup#, #fulfillment#. #moral#"],
dsummersl /
Last active Sep 10, 2018
wagtail streamblocks
from django.utils.safestring import mark_safe
from wagtail.wagtailcore.blocks import (
StructBlock, StructValue, CharBlock, PageChooserBlock, URLBlock,
StreamBlock, StaticBlock)
from wagtail.wagtailimages.blocks import ImageChooserBlock
class PageLink(StructBlock):
"""Links to pages within this site.
View ProductDetails.ts
import * as angular from 'angular';
import {html} from './ProductDetails.html';
import {ClipartProductService} from '../../../../../common/ts/apps/svgcustom/services/ClipartProductService';
import {Color} from '../../../../../common/ts/apps/svgcustom/models/Color';
class ProductDetailsController {
static $inject = [

Keybase proof

I hereby claim:

  • I am dsummersl on github.
  • I am ntx3holc ( on keybase.
  • I have a public key whose fingerprint is 30D7 EB1C 3C2A B919 3036 B2E3 2834 CC62 9693 E1BD

To claim this, I am signing this object:

View data.rake
require 'rake'
namespace :data do
require 'open-uri'
require 'csv'
task load_drains: :environment do
puts 'Downloading Drains... ... ...'
url = 'durham.csv'
csv_string = open(url).read