Skip to content

Instantly share code, notes, and snippets.

View Lucianovici's full-sized avatar

Lucian Corduneanu Lucianovici

View GitHub Profile
@Lucianovici
Lucianovici / models.py
Created March 3, 2021 20:12
Django annotate foreign key challenge
from django.contrib.auth.models import User
from django.db import models
from django.db.models import Case, When, Q
from django.db.models.expressions import Value, F
class WidgetManager(models.Manager):
def with_user_status(self, user: User = None):
"""This approach duplicates the same widget for each UserStatus"""
return self.annotate(
@Lucianovici
Lucianovici / poc-esp32-two-cores-watchdog
Created February 23, 2019 21:43
ESP32 Watchdog on two cores
/**
* Monopolizing two cores that should reset the watchdog timer.
*/
#include "esp_attr.h"
#include "esp_log.h"
#include "esp_system.h"
#include "esp_task_wdt.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
@Lucianovici
Lucianovici / echo-payload-view.py
Last active February 26, 2019 11:27
Echo Payload API point - deserializer
class DevicePayloadView(APIView):
SUBMETER_TYPE = 1
CONCENTRATOR_TYPE = 2
authentication_classes = ()
permission_classes = ()
def post(self, request, eui):
"""