Skip to content

Instantly share code, notes, and snippets.

@ezheidtmann
ezheidtmann / routing-notes.md
Created October 20, 2016 23:54
Notes for an LTS-based routing engine, with eventual integration with Ride Report stress data

The Vision

Cycling can be a great way to get around a city, but it's often difficult to find good routes that feel safe. We believe that more people would bike if they had access to better bike directions.

Existing bicycle routing technologies can be great, but they have serious drawbacks:

  • No standard ranking system for streets -- riders don't know what to expect from the algorithm
  • No transparency of tradeoffs between speed, ease of memorization, and stressfulness -- riders don't know whether a given route will feel safe or not.
  • No personalization based on stress tolerance -- riders can't provide their parameters to find a low-stress ride
@ezheidtmann
ezheidtmann / distance-comparison.csv
Last active May 31, 2016 23:49
Comparison between CoreLocation distanceFromLocation() and other earth distance methods
ios_distanceFromLocation geopy_great_circle geopy_vincenty great_circle_difference vincenty_difference
3.93925768 3.9281531653 3.93922265629 0.0111045147028 3.50237133229e-05
25.72370334 25.7073197794 25.7236413377 0.0163835605726 6.20023199041e-05
5.46728098 5.45349443375 5.46725389515 0.0137865462544 2.70848484067e-05
8.29325257 8.27305170503 8.2932119731 0.0202008649714 4.05968985113e-05
9.69501709 9.67160552512 9.69496572517 0.0234115648778 5.13648320624e-05
6.00842669 5.99403658269 6.00839455602 0.014390107307 3.21339784124e-05
5.12883773 5.11445893246 5.12880707646 0.0143787975444 3.06535422894e-05
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
@ezheidtmann
ezheidtmann / centersquartermilebuffer.geojson
Last active May 28, 2016 00:29
Areas of Portland within 1/4 mile of a designated center in comp plan draft
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Simple Rewards:
Ride on first day of bike month
Ride in first week of bike month
Ride in bike week
Ride every week of bike month
Ride every day of bike week
First ride in a while
Fourth ride of the day (when norm is 2)
@ezheidtmann
ezheidtmann / mycustomurlprocessor.module
Last active January 28, 2016 20:07
Custom FacetAPI url processor for project-specific and search-specific overrides
<?php
function mycustomurlprocessor_module_implements_alter(&$implementations, $hook) {
if ($hook == 'facetapi_searcher_info_alter') {
# move our implementation to the end of the list so we can override the
# alterations made by facetapi_pretty_paths_facetapi_searcher_info_alter
$group = $implementations['mycustomurlprocessor'];
unset($implementations['mycustomurlprocessor']);
$implementations['mycustomurlprocessor'] = $group;
}
@ezheidtmann
ezheidtmann / drf_viewsets.py
Last active June 20, 2016 23:13
How to enable "PUT to create" with Django Rest Framework
from rest_framework import viewsets
from django.http import Http404
class MyViewSet(viewsets.ModelViewSet):
serializer_class = MySerializer
# ...
def update(self, request, *args, **kwargs):
partial = kwargs.get('partial', False)
try:
@ezheidtmann
ezheidtmann / reference.txt
Last active October 12, 2015 15:27
LVM2 cheat sheet
# LVM is an advanced system. This document only describes my use case.
# I use it on a pair of external USB disks; these commands help me to mount & unmount logical volumes on my laptop.
#####
# Plug in the disks, mount them
vgscan # maybe optional
vgchange -ay # creates /dev/* entries
mount /dev/<vgname>/<lvname> /mountpoint
@ezheidtmann
ezheidtmann / squishy.drush.inc
Created May 21, 2014 17:21
Safety-oriented implementation of drush hooks, for squishymedia
<?php
/** @file squishy.drush.inc
*
* Place this file in sites/all/drush to enable its features. Attempts to
* prevent sql-sync to prod and sets up some safe dev settings after a sql-sync
* from anywhere.
*/
/**
* Implements drush_hook_pre_sql_sync()
@ezheidtmann
ezheidtmann / template.php
Created January 29, 2014 20:49
Add region-based suggestions for bean blocks (Drupal 7, bean module)
<?php
/**
* Implements hook_preprocess_block()
*
* For each bean block, add a template suggestion containing the name of the
* region where the block will appear.
*
* Requires "bean" module (fieldable blocks)
*/
function THEME_preprocess_entity(&$vars, $hook) {
@ezheidtmann
ezheidtmann / template.php
Created January 29, 2014 20:45
Add a template suggestion for each context in effect (Drupal 7)
<?php
/**
* Implements hook_preprocess()
*
* For each context currently activated, add a theme suggestion for each
* existing suggestion. If you have a context called "everywhere", we don't
* generate a suggestion for that context.
*
* FIXME: This doesn't indicate which context is positioning each
* individual item. Usually this isn't a problem, but it should be fixed.