Skip to content

Instantly share code, notes, and snippets.

Carlos de la Torre cmdelatorre

Block or report user

Report or block cmdelatorre

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
# Based on
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),
class MyViewSet(MultiSerializerViewSetMixin, ViewSet):
serializer_class = MyDefaultSerializer
cmdelatorre /
Created Aug 25, 2015
Integrate Backbone with Django: Add CSRF Token to Backbone Ajax calls
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')
cmdelatorre /
Last active Feb 22, 2018
Desicion tree classifier (ID3) algortihm
from collections import namedtuple, Counter, defaultdict
from math import log2
cmdelatorre /
Last active Aug 29, 2015
Synthetic example of
# # 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
You can’t perform that action at this time.