Skip to content

Instantly share code, notes, and snippets.

View mattwigway's full-sized avatar

Matthew Wigginton Bhagat-Conway mattwigway

  • Department of City and Regional Planning, University of North Carolina at Chapel Hill
  • Durham, NC, USA
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# similar to Python's built in zip function, but yielding named tuples instead of tuples.
# i.e. list(namedzip(a=[1, 2], b=[3, 4])) => [namedzipitem(a=1, b=3), namedzipitem(a=2, b=4)]
# Author: Matthew Wigginton Conway <mwconway@asu.edu>
# feel free to use and share
from collections import namedtuple
def namedzip (**kwargs):
keys = list(kwargs.keys())
typ = namedtuple('namedzipitem', keys)
length = len(kwargs[keys[0]])
@mattwigway
mattwigway / boxplot.py
Last active January 4, 2018 23:23
Matplotlib boxplot with custom summary stats
# To the extent possible under law, Matthew Wigginton Conway has waived all copyright and
# related or neighboring rights to this work. This work is published from: United States.
def customBoxPlot (whiskerLo, boxLo, med, boxHi, whiskerHi, **kwargs):
fakeData = [np.array([42, 42]) for i in whiskerLo]
bp = plt.boxplot(fakeData, **kwargs)
for i in range(len(whiskerLo)):
# https://stackoverflow.com/questions/27214537
# This can't possibly be the best way to do this...
# lower whisker
@mattwigway
mattwigway / ocrpdf.sh
Last active August 21, 2017 20:35
Command-line tool to OCR PDFs
#!/bin/bash
# OCR a PDF using Tesseract and Ghostscript
# (brew install tesseract, brew install ghostscript using Homebrew on a Mac)
# Usage: ocrpdf input.pdf output.pdf
# Copyright (c) 2017 Matthew Wigginton Conway
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@mattwigway
mattwigway / index.html
Last active December 16, 2015 21:49
Equations
<!DOCTYPE html>
<html>
<head>
<title>Equations</title>
<script type="text/javascript"
src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head>
<body>
<a name="1.1">1.1 Balanced accessibility model</a>
@mattwigway
mattwigway / README.md
Last active December 16, 2015 11:29
Half-life visualization (distance decay for a gravity model)

Distance decay

This shows the distance decay for a given half-life in the gravity model, i.e. e^bx fixed by 0,1 and h,0.5 where h is the half-life.

@mattwigway
mattwigway / Batch traceback
Created April 17, 2013 21:42
batch traceback
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchProcessor': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.opentripplanner.routing.core.RoutingRequest] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(mappedName=, shareable=true, description=, name=, type=class java.lang.Object, authenticationType=CONTAINER)}
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:300)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:
2013-02-17 20:55:49,626 INFO [WebMapService.java:89] : reprojecting envelope from WGS84 to PROJCS["NAD83 / California zone 3",
GEOGCS["NAD83",
DATUM["North American Datum 1983",
SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]],
TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
AUTHORITY["EPSG","6269"]],
PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
UNIT["degree", 0.017453292519943295],
AXIS["Geodetic longitude", EAST],
AXIS["Geodetic latitude", NORTH],
<!DOCTYPE html>
<html>
<head>
<title>Migration among California counties</title>
</head>
<body>
<div class="map">
</div>
</body>