Skip to content

Instantly share code, notes, and snippets.

@mjumbewu
mjumbewu / filtered_data.handlebars
Created September 9, 2014 15:51
Filter both places and comments by properties on the places
{{#created_within_days 365 dataset.places}}
{{!-- Filter the places by some property --}}
{{#filter_by . "properties.location_type" "park"}}
Number of new places: {{length .}}
{{#each .}} ... {{/each}}
{{/filter_by}}
{{/created_within_days}}
{
"id": 440,
"title": "Station Locations",
"phone": "+12159876034",
"start_date": "2014-08-22T17:31:26-04:00",
"end_date": null,
"confirmation": "Thanks again. There are approx. 90 proposed sites so if you see another sticker, text us from there!",
"public": false,
"questions": [
{
City Cycling Deaths / 1M People Pop (2010) Approx # of Deaths Cyclists as % of Pop # of Cyclists (2010) Deaths / 1K Cyclists
Jacksonville 5.68 823316 4.67643488 0.2 1647 2.8393654402
Phoenix 6.12 1449481 8.87082372 0.6 8697 1.0199866299
Mesa 6.05 440248 2.6635004 0.6 2641 1.0085196516
Fresno 5.98 496147 2.96695906 0.8 3969 0.7475331469
Houston 2.19 2107208 4.61478552 0.5 10536 0.4380016629
New Orleans 5.54 347858 1.92713332 1.8 6261 0.3077996039
NYC 2.1 8184899 17.1882879 0.8 65479 0.2625007697
Los Angeles 1.91 3797144 7.25254504 0.9 34174 0.2122240604
Chicago 2.22 2698831 5.99140482 1.3 35085 0.1707682719
@mjumbewu
mjumbewu / basic_auth.py
Last active March 20, 2019 15:10
WSGI middleware
from __future__ import unicode_literals
import base64
import binascii
import os
import re
import logging
log = logging.getLogger(__name__)
import re
from django.conf import settings
from django.core import cache as django_cache
from mock import patch
from rest_framework.permissions import SAFE_METHODS
from rest_framework.response import Response
class CachedResourceMixin (object):
@property
@mjumbewu
mjumbewu / index.html
Last active December 30, 2015 07:39
Simple static handlebars.js renderer
<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.1.2/handlebars.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
</head>
<body>
<!-- Your handlebars template goes below... -->
<script id="my-one-template" type="text/x-handlebars-template">
{{#each people}}
rvm system
travis encrypt SAUCE_USERNAME=$SAUCE_USERNAME --repo openplans/hatch
travis encrypt SAUCE_ACCESS_KEY=$SAUCE_ACCESS_KEY --repo openplans/hatch
# Add the values to your .travis.yml file
#
# NOTE: If you specify "--add env.global" with the encrypt command this will
# be done automatically.
#
# env:
@mjumbewu
mjumbewu / paginated_csv_renderer.py
Created September 20, 2013 15:27
Django REST Framework CSV renderer that works with Paginated data
from rest_framework_csv.renderers import CSVRenderer
class PaginatedCSVRenderer (CSVRenderer):
results_field = 'results'
def render(self, data, media_type=None, renderer_context=None):
if not isinstance(data, list):
data = data.get(self.results_field, [])
return super(PaginatedCSVRenderer, self).render(data, media_type, renderer_context)
@mjumbewu
mjumbewu / review2013.09.09.js
Last active December 23, 2015 01:59
JS Review
// We went over:
/*
* - What's JS used for
* - Modifying document structure (the HTML is not the webpage, like the
* blueprint is not the building)
* - Retrieving data from a server without a page reload
* - Widgets and usability
*/
@mjumbewu
mjumbewu / browserstack_tunnel_setup.sh
Last active December 20, 2015 00:19
A small bash script to start a BrowserStack tunnel as part of a Travis Build.
#!/bin/bash
# Setup and start BrowserStack Tunnel for your TravisCI build
#
# This script was adopted from Santiago Suarez Ordoñez's Sauce Connect
# setup script: https://gist.github.com/santiycr/5139565/
#
# This script requires your .travis.yml to include the following private
# env variable:
#