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
from polymorphic.managers import PolymorphicManager | |
from polymorphic.models import PolymorphicModel | |
from .query import RelatedPolymorphicQuerySet, RelatedPolymorphicModel, RelatedPolymorphicManager | |
class ProjectManager(RelatedPolymorphicManager): | |
pass | |
class ProjectManager2(PolymorphicManager): | |
pass |
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
from django.db.models import CASCADE, SET_DEFAULT, SET_NULL, PROTECT, QuerySet, Q | |
from django.db.models.expressions import F | |
from django.db.models.functions import Cos, Sqrt, ASin | |
class ExampleModel(models.Model): | |
# Example model that could use this function | |
latitude = models.FloatField() | |
longitude = models.FloatField() | |
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
// Decode decodes an array of bytes into an object. | |
// - fPort contains the LoRaWAN fPort number | |
// - bytes is an array of bytes, e.g. [225, 230, 255, 0] | |
// The function must return an object, e.g. {"temperature": 22.5} | |
/* | |
@reference https://elsys.se/public/documents/Sensor_payload.pdf | |
Sensors Name Designation | |
------------------------------------------------------------ | |
Sound Sensor ERS Sound |
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
### settings | |
""" | |
SWAGGER_SETTINGS = { | |
... | |
'DEFAULT_FIELD_INSPECTORS': [ | |
'project.utils.PolymorphicSerializerInspector', | |
'drf_yasg.inspectors.CamelCaseJSONFilter', | |
'drf_yasg.inspectors.ReferencingSerializerInspector', | |
'drf_yasg.inspectors.RelatedFieldInspector', | |
'drf_yasg.inspectors.ChoiceFieldInspector', |
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
// Decode decodes an array of bytes into an object. | |
// - fPort contains the LoRaWAN fPort number | |
// - bytes is an array of payload, e.g. [225, 230, 255, 0] | |
// The function must return an object, e.g. {"temperature": 22.5} | |
function Decode(fPort, bytes) { | |
/** | |
* @reference https://github.com/myDevicesIoT/cayenne-docs/blob/master/docs/LORA.md | |
* | |
* Added types for Tektelic Sensor | |
* Adapted for lora-app-server from https://gist.github.com/iPAS/e24970a91463a4a8177f9806d1ef14b8 |
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
from matplotlib import ticker | |
from matplotlib.dates import DateFormatter, _from_ordinalf | |
class ConditionalDateFormatter(ticker.Formatter): | |
def __init__(self, fmt: str, fmt_conditional: str, date_condition: Callable[[datetime], bool], tz=None): | |
""" | |
A formatter for dates in matplotlib plots where the output format string changes based on a condition. | |
Args: | |
fmt (str): regular format string |