This file contains 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
import sys | |
from twisted.internet import inotify, reactor, threads | |
from twisted.python import filepath | |
# Resources: | |
# Introduction to Deferreds: | |
# http://twisted.readthedocs.io/en/twisted-16.1.1/core/howto/defer-intro.html | |
# Returning Deferreds from synchronous functions: | |
# https://twistedmatrix.com/documents/current/core/howto/gendefer.html#returning-deferreds-from-synchronous-functions |
This file contains 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
from twisted.internet import inotify, reactor, threads | |
from twisted.python import filepath | |
# Resources: | |
# Introduction to Deferreds: | |
# http://twisted.readthedocs.io/en/twisted-16.1.1/core/howto/defer-intro.html | |
# Returning Deferreds from synchronous functions: | |
# https://twistedmatrix.com/documents/current/core/howto/gendefer.html#returning-deferreds-from-synchronous-functions | |
# addCallbacks Docs: | |
# https://twistedmatrix.com/documents/16.1.1/api/twisted.internet.defer.Deferred.html#addCallbacks |
This file contains 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
from rest_framework import serializers | |
class DynamicFieldsModelSerializer(serializers.ModelSerializer): | |
""" | |
A ModelSerializer that allows for optional fields to be added to a | |
serializer. These fields only appear when they are referred to by | |
name with a `include` GET parameter. | |
Additionally, a user can provide a `fields` GET parameter to limit |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
from django.contrib import admin, messages | |
from django.shortcuts import render | |
from my_app.models import MyModel | |
from my_app import forms | |
class MyModelAdmin(admin.ModelAdmin): | |
actions = ['my_action'] |
This file contains 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
from django.contrib import admin, messages | |
from django.http import HttpResponseRedirect | |
from django.shortcuts import render | |
from my_app.forms import CustomForm | |
class FakeModel(object): | |
class _meta: | |
app_label = 'my_app' # This is the app that the form will exist under |
This file contains 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
#!/usr/bin/python | |
""" | |
This script assumes that you have a LCD connected to a RaspberryPi or BeagleBone | |
Black as as described in this tutorial: | |
https://learn.adafruit.com/character-lcd-with-raspberry-pi-or-beaglebone-black | |
along with a temperature sensor as described in this tutorial: | |
https://learn.adafruit.com/measuring-temperature-with-a-beaglebone-black | |
""" | |
from collections import deque |