Skip to content

Instantly share code, notes, and snippets.

@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}}
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 / 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__)
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
{
"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": [
{
@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}}
@mjumbewu
mjumbewu / instructions.md
Last active August 29, 2015 14:14
Create a settings context processor in Django

Create a file called context_processors.py, and insert this:

from django.conf import settings as django_settings

def settings(request):
    return {'settings': django_settings}

Then, in settings.py, add this:

class NewAlbum:
def leastAmountOfCDs(self, nSongs, length, cdCapacity):
# First, for kicks, let's just check whether all the songs fit on
# one CD
totalLength = nSongs * length
if totalLength <= cdCapacity:
return 1
# If all the songs don't fit on one CD, start iterating through the
@mjumbewu
mjumbewu / README.md
Last active August 29, 2015 14:17
Thoughts on the usage of GitHub as a tool for CbK

Coded By Kids ❤ GitHub

GitHub may turn out to be a great resource for tracking kids' progress on projects. Commit messages can form the basis of a progress journal, as well as a built-in point of reflection after each session. Students can use them to summarize the work completed during the session. Volunteer instructors can refer back through the commit history to see kids process as they have been working on a project. Using the web interface and gh-pages may be a good, gentle introduction before getting into the command line.

Good Git tutorials & resources

@mjumbewu
mjumbewu / Gruntfile.js
Created September 8, 2015 07:45
Starter Gruntfile
module.exports = function(grunt) {
// Do grunt-related things in here
};