Skip to content

Instantly share code, notes, and snippets.

View Abathargh's full-sized avatar

Gianmarco Abathargh

View GitHub Profile
@Abathargh
Abathargh / Makefile
Created February 10, 2022 15:57 — forked from mcous/Makefile
Simple AVR Makefile template
# simple AVR Makefile
#
# written by michael cousins (http://github.com/mcous)
# released to the public domain
# Makefile
#
# targets:
# all: compiles the source code
# test: tests the isp connection to the mcu
@Abathargh
Abathargh / dict-paho-mqtt.py
Created February 1, 2022 17:22
Esempio con dizionario/cache e due topic MQTT
from paho.mqtt.client import Client
import time
topic_test1 = "test/1"
topic_test2 = "test/2"
last_msg = {}
client = Client(client_id = "sub-test")
@Abathargh
Abathargh / stream.py
Created August 21, 2021 18:32
Esempio di utilizzo della classe di gestione di Stream in ingresso BtSlaveInputStream
from shimmer_listener import BtSlaveInputStream
def on_connect(mac, info):
print(f"BT MAC {mac}: received presentation frame, {info}")
def on_disconnect(mac, lost):
if lost:
print(f"BT MAC {mac}: connection lost")
else:
print(f"BT MAC {mac}: disconnecting")
@Abathargh
Abathargh / env_to_json.py
Last active June 14, 2021 11:13
Convert a .env properties file to json
import sys
prop = None
with open(sys.argv[1], "r") as f:
prop = f.read()
res = "{\n"
for line in prop.split("\n"):
@Abathargh
Abathargh / py-fromsource-dep.sh
Created April 21, 2021 20:48
Dependencies needed for a working python installation from source (pip install wheel needed to build after altinstall)
sudo apt install build-essential libncursesw5-dev libreadline-gplv2-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev libffi-dev
@Abathargh
Abathargh / dunder.py
Created January 21, 2021 22:19
Esempi trattati nell'articolo di antima.it raggiungibile al seguente link https://antima.it/elementi-di-python-utilizzi-pratici-dei-metodi-dunder/
class Arduino:
def __init__(self, nome, microcontr):
self._nome = nome
self._microcontr = microcontr
def __str__(self):
return f"Arduino {self._nome}"
def __repr__(self):
return f"Arduino(nome={self._nome}, microcontr={self._microcontr})"
#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"
@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() {
@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 / 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 [""]