This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"{"places":[{"place_id":"from","place_name":"Origin","place_lat":38.914544497799476,"place_lon":-77.0196533203125},{"place_id":"to","place_name":"Destination","place_lat":38.77335772026906,"place_lon":-77.0196533203125}],"journeys":[{"journey_id":0,"journey_name":0,"segments":[{"type":"WALK","from":{"type":"PLACE","place_id":"from"},"to":{"type":"STOP","stop_id":"1095"}},{"type":"TRANSIT","pattern_id":"66","from_stop_index":8,"to_stop_index":17},{"type":"WALK","from":{"type":"STOP","stop_id":"3581"},"to":{"type":"STOP","stop_id":"9613"}},{"type":"TRANSIT","pattern_id":"526","from_stop_index":1,"to_stop_index":27},{"type":"WALK","from":{"type":"STOP","stop_id":"1192"},"to":{"type":"STOP","stop_id":"10067"}},{"type":"TRANSIT","pattern_id":"256","from_stop_index":26,"to_stop_index":27},{"type":"WALK","from":{"type":"STOP","stop_id":"10622"},"to":{"type":"PLACE","place_id":"to"}}]},{"journey_id":1,"journey_name":1,"segments":[{"type":"WALK","from":{"type":"PLACE","place_id":"from"},"to":{"type":"STOP","stop_id":" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.mapdb.*; | |
import java.util.Collections; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
import java.util.stream.IntStream; | |
/** | |
* Created by matthewc on 9/15/15. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Remove all the -99999... values in the NL neighborhoods file and replace them with NULL | |
from sys import argv | |
import fiona | |
with fiona.open(argv[1]) as infile: | |
meta = infile.meta | |
meta['schema']['geometry'] = 'MultiPolygon' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>MetricsGraphics Confidence Bound Test</title> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/metrics-graphics/2.2.1/metricsgraphics.css" /> | |
</head> | |
<body> | |
<div id="chart"></div> | |
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a set of Tuple2<key in original map, value> - secondary keys, backwards. | |
*/ | |
public static <K, V, V2> void inverseSecondaryKeys (MapWithModificationListener<K, V> map, | |
final NavigableSet<Fun.Tuple2<K, V2>> set, final Function2<V2[], K, V> fun) { | |
if (set.isEmpty()) { | |
for (Map.Entry<K, V> e : map.entrySet()) { | |
for (V2 val : fun.run(e.getKey(), e.getValue())) { | |
set.add(new Tuple2<K, V2>(e.getKey(), val)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Iterator; | |
import org.mapdb.DB; | |
import org.mapdb.DBMaker; | |
import org.mapdb.Fun.Tuple2; | |
public class MapDBEmptyPumpSource { | |
public static void main(String... args) { | |
Iterator<Tuple2<String, String>> data = new Iterator () { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Demo of using OpenTripPlanner and opentripplanner-jython | |
# Public domain | |
from opentripplanner import RoutingRequest, Graph | |
from opentripplanner.batch import BatchProcessor, PointSet | |
# Set the parameters for our search | |
r = RoutingRequest() | |
r.dateTime = 1412974800 # Friday, Oct. 10th, 2014, 4:00 pm CDT (doesn't matter for a walking search) | |
r.setModes('WALK') |