Skip to content

Instantly share code, notes, and snippets.

View Abathargh's full-sized avatar

Gianmarco Abathargh

View GitHub Profile
from threading import Lock
from paho.mqtt.client import Client
CLIENTID = "Mediator"
HOST = "localhost"
BASETOPIC = "actuator"
SUBTOPIC = "sensor/#"
table = dict()
mutex = Lock()
"""
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
@Abathargh
Abathargh / esempi_iter_gen.py
Created April 22, 2020 23:10
Esempi trattati all'interno dell'articolo di antima.it su iteratori e generatori http://antima.it/elementi-di-python-iteratori-e-generatori/
class ListaConcatenata:
class Nodo:
val = None
prossimo = None
def __init__(self):
self.testa = None
def aggiungi(self, n_val):
if self.testa is None:
@Abathargh
Abathargh / mqtt_test.go
Created April 29, 2020 18:31
Esempio di Client MQTT implementato in go tramite paho.mqtt.golang
package main
import (
"fmt"
"github.com/eclipse/paho.mqtt.golang"
"log"
"os"
"os/signal"
"syscall"
)
"""
Installare le dipendenze tramite:
pip3 install requests audioop pyaudio
ed eseguire:
python3 lamp_control.py
"""
import requests
import audioop
@Abathargh
Abathargh / Dockerfile
Created November 6, 2020 19:09
Jade 4.5.0 over OpenJDK11 image
FROM openjdk:11.0.8
ENV CLASSPATH="/usr/lib/jade/jade.jar"
RUN wget --no-check-certificate -O jade.zip https://jade.tilab.com/dl.php?file=JADE-bin-4.5.0.zip
RUN unzip jade.zip && mkdir /usr/lib/jade && mv jade/lib/jade.jar /usr/lib/jade/jade.jar && rm -rf jade/ jade.zip
CMD [""]
@Abathargh
Abathargh / moody_dht.ino
Created December 26, 2020 00:00
MoodyESP8266 Sketch using a DHT11 sensor with data incoming on PIN0
#include <MoodyEsp8266.h>
#include <DHT.h>
#include "certs.h"
#define DATA_PIN 0
#define DHT_TYPE DHT11
MoodySensor sensor;
DHT dht(DATA_PIN, DHT_TYPE);
@Abathargh
Abathargh / matrix.ino
Created December 27, 2020 23:46
Quick reference example of actuating a WS2812B 8x8 Led matrix with FastLed.h
#include <FastLED.h>
#define NUM_LEDS 64
#define DATA_PIN 0
CRGB leds[NUM_LEDS];
int set = 0;
void setup() {
#include <PDM.h>
#include <arm_math.h>
#include <Arduino_HTS221.h>
#include <Arduino_LPS22HB.h>
#include <Arduino_APDS9960.h>
#include <ArduinoBLE.h>
#define BLE_NAME "Moody-ble"