This file contains hidden or 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
# Based on http://stackoverflow.com/a/22922156/1161156 | |
class MultiSerializerViewSetMixin(object): | |
def get_serializer_class(self): | |
""" | |
Look for serializer class in self.serializer_action_classes, which | |
should be a dict mapping action name (key) to serializer class (value), | |
i.e.: | |
class MyViewSet(MultiSerializerViewSetMixin, ViewSet): | |
serializer_class = MyDefaultSerializer |
This file contains hidden or 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
oldSync = Backbone.sync | |
Backbone.sync = (method, model, options) -> | |
csrfSafeMethod = (method) -> | |
# these HTTP methods do not require CSRF protection | |
/^(GET|HEAD|OPTIONS|TRACE)$/.test method | |
options.beforeSend = (xhr, settings) -> | |
if !csrfSafeMethod(settings.type) and !@crossDomain | |
xhr.setRequestHeader 'X-CSRFToken', $.cookie('csrftoken') |
This file contains hidden or 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
""" | |
http://en.wikipedia.org/wiki/ID3_algorithm | |
http://www.cise.ufl.edu/~ddd/cap6635/Fall-97/Short-papers/2.htm | |
""" | |
from collections import namedtuple, Counter, defaultdict | |
from math import log2 |
This file contains hidden or 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
# # Example of a model in your legacy app: | |
# | |
# class OldNotes(models.Model): | |
# title = models.CharField(max_length=256) | |
# text = models.TextField() | |
# | |
# # Example of a model in one of your new apps, awesomeapp: | |
# | |
# HEADER_LEN = 256 |