Skip to content

Instantly share code, notes, and snippets.

View craigds's full-sized avatar
👾
mildly amused

Craig de Stigter craigds

👾
mildly amused
View GitHub Profile
#!/usr/bin/env python
from datetime import datetime
import os
import sys
import gdata.projecthosting.client
import gdata.projecthosting.data
import gdata.gauth
import gdata.client
import gdata.data
{"comment":{"gravatar_id":"67a1b68aca6b44984ff9b8bdb30fc6ed","created_at":"2010/09/11 23:29:15 -0700","body":"[insin](http://github.com/insin) (29 Dec 07):\n\nMaking this a blocker for the first public release, as modifying a parent currently\nleaves the tree in an invalid state.","updated_at":"2010/09/11 23:29:15 -0700","id":401907,"user":"craigds"}}
@classmethod
def with_base_model(cls, base_model):
"""
This returns an MPTTModel CLASS with the given base model.
Used for linearizing inheritance chains.
The given model should be abstract.
"""
if cls is not MPTTModel:
raise RuntimeError, "with_base_model() must be called on MPTTModel"
diff --git a/mptt/managers.py b/mptt/managers.py
index e7893af..8290443 100644
--- a/mptt/managers.py
+++ b/mptt/managers.py
@@ -2,7 +2,7 @@
A custom manager for working with trees of objects.
"""
from django.db import connection, models, transaction
-from django.db.models import F, Max
+from django.db.models import F, Max, Q
Index: alg/gdalwarper.cpp
===================================================================
--- alg/gdalwarper.cpp (revision 21094)
+++ alg/gdalwarper.cpp (working copy)
@@ -32,6 +32,7 @@
#include "cpl_minixml.h"
#include "ogr_api.h"
#include "gdal_priv.h"
+#include <iostream>
#!/usr/bin/env python
"""
Calculate and displays all possible N-ominoes for a given N.
(c) 2010 Craig de Stigter
craig.ds@gmail.com
http://flavors.me/craigds
"""
# sample code as a suggestion for https://convore.com/django-community/how-to-make-an-automatic-status-change/
from datetime import datetime
class MyManager(models.Manager):
def active(self):
return self.get_query_set().filter(expires_at__gt=datetime.now())
class MyClass(models.Model):
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
@craigds
craigds / mapsearch.py
Created February 24, 2011 23:53
Gets search results from Google Maps for the given string
#!/usr/bin/env python
"""
Gets search results from Google Maps for the given string.
Usage:
mapsearch.py "address" [region]
Regions are two-character ccTLDs: http://en.wikipedia.org/wiki/CcTLD
They're not validated by this script
"""
=== modified file 'mptt/managers.py'
--- mptt/managers.py 2008-12-05 01:37:34 +0000
+++ mptt/managers.py 2008-12-05 19:08:24 +0000
@@ -11,15 +11,11 @@
qn = connection.ops.quote_name
COUNT_SUBQUERY = """(
- SELECT COUNT(*)
- FROM %(rel_table)s
- WHERE %(mptt_fk)s = %(mptt_table)s.%(mptt_pk)s
@craigds
craigds / gist:873438
Created March 16, 2011 22:16
backport gdal [20189] to 1.7.3. ticket: http://trac.osgeo.org/gdal/ticket/3708
Index: gdal/apps/gdal_translate.cpp
===================================================================
--- gdal/apps/gdal_translate.cpp (revision 21963)
+++ gdal/apps/gdal_translate.cpp (working copy)
@@ -991,7 +991,14 @@
pfnProgress, NULL );
if( hOutDS != NULL )
{
+ int bHasGotErr = FALSE;
+ CPLErrorReset();