Skip to content

Instantly share code, notes, and snippets.


William Huster whusterj

View GitHub Profile
whusterj /
Created May 4, 2018
Track 'WTF' moments over time. Optionally include a message.
#!/usr/bin/env python
Just write a timestamp to a text file, so later we can calculate the
number of 'WTFs' per minute.
Inspired by:
Use it like this:
View gist:d7da3b9b04da9dd8fd01
function deepGet (obj, properties) {
// If we have reached an undefined/null property
// then stop executing and return undefined.
if (obj === undefined || obj === null) {
// If the path array has no more elements, we've reached
// the intended property and return its value.
if (properties.length === 0) {
whusterj / getEditDistance.js
Created Jan 15, 2015
Levenshtein Edit Distance
View getEditDistance.js
// Compute the edit distance between the two given strings
function getEditDistance(a, b) {
if(a.length === 0) return b.length;
if(b.length === 0) return a.length;
var matrix = [];
// increment along the first column of each row
var i;
for(i = 0; i <= b.length; i++){
An example of how to use html2text to create plaintext emails without all the headache.
import html2text
from django.conf import settings
from django.core.mail.message import EmailMultiAlternatives
from django.template.loader import render_to_string
whusterj /
Created Nov 18, 2014
Django custom template tag useful for marking navigation links with an 'active' class.
Easily mark navigation links with an 'active' class in Django templates.
<a href="{% url 'some_view_name' %}" class="{% active request 'some_view_name' %}">Link to Somewhere</a>
from django.core.urlresolvers import reverse
from django import template
whusterj / prettyListFilter.js
Last active Aug 29, 2015
A custom AngularJS Filter for printing a human-readable list.
View prettyListFilter.js
* A custom AngularJS Filter for printing a human-readable list.
* Example: Use in a controller:
* $scope.daysOfTheWeek = ['Monday', 'Tuesday', 'Wednesday' ]
* Example: Use in a template:
* {{ daysOfTheWeek | prettyList }}
You can’t perform that action at this time.