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 itertools import chain | |
from django.db.models.fields.related import ManyToManyField | |
def model_to_dict_verbose(instance, fields=None, exclude=None): | |
""" | |
Returns a dict containing the data in ``instance`` suitable for passing as | |
a Form's ``initial`` keyword argument. Keys in dict are exchanged for | |
verbose names contained in the model. | |
``fields`` is an optional list of field names. If provided, only the named | |
fields will be included in the returned dict. |
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
def asFutureEither[T](f: Future[T]): Future[Either[Throwable, T]] = | |
f map { Right(_) } recover { case x => Left(x) } |
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 enum import Enum | |
from multiprocessing import Process | |
from time import sleep | |
import RPi.GPIO as GPIO | |
PINS = {'in': 19, 'out': 21} | |
class Program(Enum): |