Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am dsummersl on github.
* I am dane_summ_workco (https://keybase.io/dane_summ_workco) on keybase.
* I have a public key ASDnGDG8MO7dnz1hFkB0oQi5BU55CvTEuE2Xq-ZMV_9QNgo
To claim this, I am signing this object:
('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
dsummersl / examples.md
Last active March 9, 2021 20:06
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
dsummersl / makeFullScreen.applescript
Created November 30, 2012 12:19
Applescript script for toggling applications in and out of fullscreen mode.
on run argv
(*
Toggle an application from full screen to non full screen (or the reverse).
Parameters:
1: application name(ie, Chrome)
2: boolean (true/false).
When true ensure that the application is in full screen mode (if not, make it so)
When false ensure that the application is NOT in full screen mode (if not, make it so)
*)
set theapp to item 1 of argv
@dsummersl
dsummersl / getopt_template.sh
Created November 29, 2018 16:30
Shell script snippets
#!/bin/bash
# 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
@dsummersl
dsummersl / blocks.py
Last active September 10, 2018 15:00
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.
@dsummersl
dsummersl / boundaries.json
Created March 11, 2018 17:42
nc counties
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dsummersl
dsummersl / notes.md
Created March 4, 2018 16:48
Extract population from NC VTD data.

I started with some tract level data:

wget https://www.ncleg.net/GIS/Download/Base_Data/2011/Geo/Census_Features.gdb.zip
unzip Census_Features.gdb.zip
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: https://www.ncleg.net/representation/Content/BaseData/BD2011.aspx

@dsummersl
dsummersl / story.json
Created March 1, 2018 18:08
tracery.io cactus related story generation
{
"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#"],
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 = [
'productSlug',
'ClipartProductService'
];