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
-- Hexagonal tiling for PostGIS | |
------------------------------- | |
-- Edward Abraham, Dragonfly Science | |
-- Use freely | |
-- Functions for generating tiles in a hexagonal tiling, from cartesian | |
-- coordinates. The tiling is made of hexagons defined by their 'width' | |
-- (the distance bewteen two parallel sides). The hexagon with index (0, 0) | |
-- is centered on the point x=0, y=0, and is oriented so that it points | |
-- upwards. Hexagons in the same row have the same j-coordinate, and hexagons |
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 os | |
from PIL import Image | |
import cStringIO | |
from django.core.files.base import ContentFile | |
from django.db.models import ImageField | |
from django.db.models.fields.files import ImageFieldFile | |
class JPEGImageFieldFile(ImageFieldFile): | |
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
# A git aware bash prompt for ubuntu, that shows what branch you are on, and whether you have anything to commit. | |
# Add to your .bashrc file. | |
# Works with git version 1.7.9.5. | |
# | |
# Based on http://www.intridea.com/blog/2009/2/2/git-status-in-your-prompt | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { |
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/sh | |
git log --date='short' --format='%ad %an %s' | grep $1 |
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
""" Make a dictionary that maps timezone abbreviations to timezone names. | |
The timezone_lookup module supplies a single dictionary, timezone_lookup. For example, | |
>>> timezone_lookup['EST'] | |
'US/Michigan' | |
""" | |
from datetime import datetime | |
import pytz |
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> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
background: #333; | |
} | |
</style> | |
<body> |
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
# A python example of calculating the probability of the word 'hine' | |
# See https://discourse.mozilla.org/t/quick-heads-up-on-some-metadata-confidence-estimate-work-were-doing/40618/2 | |
# The probability that a word is incorrect before the nth letter: | |
def p_not_word(n, probabilities): | |
if n == 0: | |
return 0 | |
else: | |
return probabilities[n - 1] * p_not_word(n - 1, probabilities) + \ | |
(1 - probabilities[n - 1]) |