Skip to content

Instantly share code, notes, and snippets.

View michaelgodshall's full-sized avatar

Michael Godshall michaelgodshall

View GitHub Profile
#Taken from http://groups.google.com/group/django-users/browse_thread/thread/a743280fd76845e3#
class OfflineNotification(models.Model):
user = models.ForeignKey(User)
message = models.TextField()
level = models.PositiveSmallIntegerField(default=20)
created = models.DateTimeField(auto_now_add=True)
class OfflineNotificationsMiddleware:
def process_request(self, request):
@michaelgodshall
michaelgodshall / ABOUT
Created February 8, 2012 19:48 — forked from Skirmantas/ABOUT
Username maxlength hack for ``django.contrib.auth``
This code is a suggested answer to question asked on Stackoverflow:
http://stackoverflow.com/questions/4827965/can-i-change-djangos-auth-user-username-field-to-be-100-chars-long-without-break/
require('lib/setup')
Spine = require('spine')
Stages = require('controllers/main')
Stage = require('models/stage')
class App extends Spine.Controller
constructor: ->
super
@stage = new Stages
@michaelgodshall
michaelgodshall / index.coffee
Created July 2, 2012 18:17
Spine.js Preloader
require('lib/setup')
Spine = require('spine')
$ = Spine.$
Stages = require('controllers/main')
Stage = require('models/stage')
Question = require('models/question')
Profile = require('models/profile')
Leader = require('models/leader')
class App extends Spine.Controller
@michaelgodshall
michaelgodshall / app.coffee
Created August 1, 2012 15:25
Batman.js Example
class App extends Batman.App
@root 'students#index'
# Make App available in the global namespace so it can be used
# as a namespace and bound to in views.
window.App = App
@michaelgodshall
michaelgodshall / install_textblob_corpora
Last active March 5, 2016 23:48
How to Install Texblob NLTK Corpora on Heroku
#!/usr/bin/env bash
# Put this file in the `bin` directory at the root of your project
source $BIN_DIR/utils
echo "-----> Starting corpora installation"
# Assumes NLTK_DATA environment variable is already set
# $ heroku config:set NLTK_DATA='/app/nltk_data'
@michaelgodshall
michaelgodshall / project.json
Last active January 11, 2017 00:49
Prismic.io Custom Type Example
{
"Project" : {
"client" : {
"type" : "Link",
"fieldset" : "Details",
"config" : {
"placeholder" : "Client",
"select" : "document",
"customtypes" : [ "client" ]
}
@michaelgodshall
michaelgodshall / homepage.js
Last active November 14, 2016 19:55
Prismic.io Homepage Custom Type Example
Prismic.API(config.prismic.endpoint, {accessToken: config.prismic.accessToken}, function (error, api) {
api.query(Prismic.Predicates.at('document.type', 'project'), {'fetchLinks': 'client.name'}).then( function (projects) {
ctrl.projects = projects.results;
api.query(Prismic.Predicates.at('document.type', 'homepage')).then( function (homepage) {
ctrl.homepage = homepage.results[0];
// Header Projects
var headerProjects = ctrl.homepage.getGroup('homepage.header_projects').toArray();
// Get the full Project object for this link
_.forEach(headerProjects, function (headerProject) {
@michaelgodshall
michaelgodshall / data_layer.py
Last active July 2, 2017 07:25
A fix for SqlalchemyDataLayer for flask-rest-jsonapi that applies multiple relationships without Sqlalchemy errors
from flask_rest_jsonapi.data_layers.alchemy import SqlalchemyDataLayer
from flask_rest_jsonapi.schema import get_relationships
class ImprovedRelationshipsDataLayer(SqlalchemyDataLayer):
"""
Improves SqlalchemyDataLayer by setting multiple
relationships without Sqlalchemy errors
"""