Skip to content

Instantly share code, notes, and snippets.

View gmag11's full-sized avatar

Germán Martín gmag11

View GitHub Profile
@gmag11
gmag11 / CallbackTest.ino
Last active January 4, 2017 15:47
MyAsyncWebServer prototype. Some code errors inside.
#include <ESPAsyncTCP.h>
#include <Ticker.h>
#include <ESPAsyncWebServer.h>
#include <ESP8266WiFi.h>
#include <functional>
#include <Hash.h>
using namespace std;
using namespace placeholders;
#include <Arduino.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port D2 on NodeMCU
#define ONE_WIRE_BUS D2
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
# This script work on any system using systemd as the init process.
# It works on Debian/Raspbian Jessie.
# If you have Debian/Rapbian Wheezy and want to use this script with systemd
# follow the information here : https://wiki.debian.org/systemd
# To easily download, install and set at startup:
# wget -O /tmp/download https://gist.github.com/Belphemur/3f6d3bf211b0e8a18d93/download && sudo tar -zxf /tmp/download --strip-components 1 -C /etc/systemd/system/ && sudo systemctl --reload-daemon && sudo systemctl enable Node-RED
# To consult the log : journalctl -u Node-RED
[Unit]
@gmag11
gmag11 / [email protected]
Last active March 27, 2024 04:01
Mount multiple RClone remotes on boot with a single SystemD forking service definition
# Rclone mount on boot
# Copy file to: /etc/systemd/system
# You need to create a remote on RClone and a folder on your disk, both with same name <rclone-remote>
# This example uses /cloud/ folder as origin to mount all remotes, change it to your needs
# This example use a linux user named rclone. Create it or adapt it to your needs. Rclone will get config from that user's home folder
# Register new service by typing:
# sudo systemctl daemon-reload
# Do the next one for every remote you want to load on boot
# sudo systemctl enable rclone-mount@<rclone-remote>.service
# systemctl start rclone-mount@<rclone-remote>.service
@gmag11
gmag11 / nodered-ssl.conf
Last active November 26, 2023 21:29
NodeRed 1.0 reverse proxy configuration with Apache 2.4
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName node.yourdomain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html # this does not matter
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
@gmag11
gmag11 / mqtt_ssl_idf.ino
Last active February 26, 2024 10:13
Secure MQTT connection to broker with ESP32 and internal IDF mqtt client library
#include "Arduino.h"
#include <WiFi.h>
#include "esp_log.h"
#include "esp_system.h"
#include "esp_event.h"
#include "mqtt_client.h"
#define SECURE_MQTT // Comment this line if you are not using MQTT over SSL
#ifdef SECURE_MQTT
@gmag11
gmag11 / TweetCloud.py
Created December 31, 2019 13:45
Hash processing from www.tweetstats.com
from xml.dom import minidom
import re
import math
mydoc = minidom.parse('TweetCloud.xml')
items = mydoc.getElementsByTagName('a')
hashtags = []
@gmag11
gmag11 / ip2mac.ino
Created January 2, 2022 22:15
Get MAC address from IP with ESP32
#include <WiFi.h>
#include "lwip/etharp.h"
const char* ssid = "xxxxxx";
const char* password = "xxxxxx";
const IPAddress remote_ip (192, 168, 1, 1); // Should be in your same subnet
void setup () {
@gmag11
gmag11 / merge_srt.py
Created November 1, 2024 23:02
Merges multiple SRT subtitle files, adds speaker tags, and generates a merged output in both SRT and plain text formats
import re
import sys
from datetime import datetime
# Función para convertir el tiempo SRT a formato datetime
def srt_time_to_datetime(srt_time):
return datetime.strptime(srt_time, '%H:%M:%S,%f')
# Función para convertir el tiempo datetime a formato SRT
def datetime_to_srt_time(dt):