Skip to content

Instantly share code, notes, and snippets.

View mjtamlyn's full-sized avatar

Marc Tamlyn mjtamlyn

  • Photocrowd
  • Oxford
View GitHub Profile
diff --git a/tests/runtests.py b/tests/runtests.py
index e852346..16f6e7b 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -58,6 +58,7 @@ ALWAYS_INSTALLED_APPS = [
def get_test_modules():
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
+ from django.db import connection
modules = []
@mjtamlyn
mjtamlyn / gist:aa80effbcf33f3b5065a
Created February 26, 2015 10:55
Cellar after installing hdf4 with --enable-fortran
$ find /usr/local/Cellar/hdf4/4.2.10
/usr/local/Cellar/hdf4/4.2.10
/usr/local/Cellar/hdf4/4.2.10/bin
/usr/local/Cellar/hdf4/4.2.10/bin/gif2hdf
/usr/local/Cellar/hdf4/4.2.10/bin/hdf24to8
/usr/local/Cellar/hdf4/4.2.10/bin/hdf2gif
/usr/local/Cellar/hdf4/4.2.10/bin/hdf2jpeg
/usr/local/Cellar/hdf4/4.2.10/bin/hdf8to24
/usr/local/Cellar/hdf4/4.2.10/bin/hdfcomp
/usr/local/Cellar/hdf4/4.2.10/bin/hdfed
@mjtamlyn
mjtamlyn / gist:5a3ae33cdd004e85d3c5
Created February 26, 2015 10:57
brew install hdf4 --debug --verbose --enable-fortran
==> Installing hdf4 from homebrew/homebrew-versions
==> Using Homebrew-provided fortran compiler.
This may be changed by setting the FC environment variable.
==> Downloading http://www.hdfgroup.org/ftp/HDF/releases/HDF4.2.10/src/hdf-4.2.10.tar.bz2
Already downloaded: /Library/Caches/Homebrew/hdf4-4.2.10.tar.bz2
==> Verifying hdf4-4.2.10.tar.bz2 checksum
tar xf /Library/Caches/Homebrew/hdf4-4.2.10.tar.bz2
==> Patching
patching file CMakeLists.txt
==> cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/hdf4/4.2.10 -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -Wno-dev -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DHDF4_BUILD_TOOLS=ON -DHDF4_BUILD_UTILS=ON -DHDF4_BUILD_WITH_INSTALL_NAME=ON -DHDF4_ENABLE_JPEG_LIB_SUPPORT=ON -DHDF4_ENABLE_NETCDF=OFF -DHDF4_ENABLE_SZIP_ENCODING=ON -DHDF4_ENABLE_SZIP_SUPPORT=ON -DHDF4_ENABLE_Z_LIB_SUPPORT=ON -DHDF4_BUILD_FORTRAN=ON -DCMAKE_Fortran_MODULE_DIRECTORY=/usr/local/Cellar/hdf4/4.2.10/include
class MyForm(forms.Form):
# ... Many fields
def clean(self):
foo = self.cleaned_data.get('foo')
bar = self.cleaned_data.get('bar')
if foo and bar and foo > 0 and bar < 0:
self.add_error('bar', ValidationError('Some message', code='foo_bar_mismatch'))
# ... Other validation rules here
@mjtamlyn
mjtamlyn / outdoors.md
Last active August 29, 2015 14:23
BUCS Outdoors proposal

BUCS Outdoors - Proposed format change

Background

This year, BUCS Outdoors was oversubscribed by around 100 entries. The resulted in a cut to just 11 archers per club. Some notable established clubs such as Edinburgh were particularly badly hit by this, and generally it was Novice archers who were cut. With the continued growth of sactudent archery, the situation is likely to continue to worsen over the next few years.

@mjtamlyn
mjtamlyn / base.py
Created March 1, 2012 18:17
Alternative dispatch
# Current dispatch method
def dispatch(self, request, *args, **kwargs):
# Try to dispatch to the right method; if a method doesn't exist,
# defer to the error handler. Also defer to the error handler if the
# request method isn't on the approved list.
if request.method.lower() in self.http_method_names:
handler = getattr(self, request.method.lower(), self.http_method_not_allowed)
else:
handler = self.http_method_not_allowed
self.request = request
@mjtamlyn
mjtamlyn / index.html
Created May 25, 2012 11:19
Testing storage options
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
function setCookie(c_name,value,exdays) {
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
marc ~ $ ls /usr/share/postgresql/timezonesets/
Africa.txt Asia.txt Australia.txt Europe.txt Pacific.txt
America.txt Atlantic.txt Default India
Antarctica.txt Australia Etc.txt Indian.txt
@mjtamlyn
mjtamlyn / gist:2897920
Created June 8, 2012 20:10
App-loading in django

Application loading refactor

At present application loading is handled in different ways through Django. Because of some of the limitations of Python, and some peculiarities of how models work, modules should not be reimported. Consequently Django maintains a global static, called the application cache. Models are imported from the application cache transparently when interacting with the database. But applications listed in INSTALLED_APPS contain more than just models. Some contain template tags, admin.py files, search_indexes.py files from

(docs)marc docs $ rm -rf _build/html/
(docs)marc docs $ make html
sphinx-build -b djangohtml -d _build/doctrees . _build/html
Making output directory...
Running Sphinx v1.1.3
loading pickled environment... done
building [djangohtml]: targets for 243 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] ref/class-based-views/generic-date-based
looking for now-outdated files... none found