MQTT is probably best known as a lightweight messaging protocol implemented for small sensors, but there is actually a JavaScript implementation called MQTT.js. It's a JavaScript implementation, so of course it works in a browser. I think it's a great option for front-end engineers who are working with MQTT/IoT-related projects (for example, creating a dashboard to visualize MQTT data). In this article, I'd like to write about what I did when I tried to connect MQTT.js to the test server (broker) of Mosquitto™.
| import asyncio | |
| from collections.abc import Coroutine | |
| from typing import Any | |
| async def gather_limit( | |
| *tasks: Coroutine[None, None, Any], | |
| return_exceptions: bool = False, | |
| max_con: int = 100, | |
| ) -> Any: |
| import pandas as pd | |
| import re | |
| import string | |
| from tqdm import tqdm | |
| from Sastrawi.Stemmer.StemmerFactory import StemmerFactory | |
| class DataCleaning: | |
| # Initialization | |
| factory = StemmerFactory() | |
| stemmer = factory.create_stemmer() |
In this document, I will explain how to setup nut (Network UPS Tools) on Ubuntu 18.04 and 20.04.
It is basically the next chapter of my previous gist, Upgrade nut on Ubuntu 18.04.
I'll only document USB connected UPS and not the other supported connection modes.
| import cv2 | |
| import socketio #python-socketio by @miguelgrinberg | |
| import base64 | |
| sio = socketio.Client() | |
| sio.connect('http://x.x.x.x:xxxx) | |
| cam = cv2.VideoCapture(0) | |
| while (True): |
之前在这里研究过的用iptables配置跨网段的端口转发
Assume we have the following network environments:
- Device:
- eth0 (
192.168.6.59): for external access - enx000ec6a490c5 (
192.168.1.2): for ip camera
- eth0 (
- IP Camera:
192.168.1.10 - PC:
192.168.6.2
| from flask import Flask, request, jsonify | |
| from flask_sqlalchemy import SQLAlchemy | |
| from flask_marshmallow import Marshmallow | |
| from flask_restful import Resource, Api | |
| app = Flask(__name__) | |
| api = Api(app) | |
| app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db' | |
| app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False |
| /* Arduino data manipulation and concatenation with structures and unions | |
| * | |
| * This simple (ish) sketch shows you how to organize your data into a struct | |
| * and then access the whole thing as a byte array. | |
| * | |
| * Useful if you want to concatenate several variables into a single byte array | |
| * to send over bluetooth, i2c, lora or any other protocol that works with arrays. | |
| * In other words you have a fixed byte array, and we squeeze in variables of different | |
| * data types and lengths into it, while still using it as a byte array afterwards. | |
| * |
This guide will use either a macOS or an ArchLinux base system, to prepare a microSD card with Arch Linux for Raspberry Pi.
If someone managed to do the initial setup using Windows, please let me know, so I can add to this guide.
This guide will be verbose at times for some simple tasks. This is intended to help people just starting out, so it's not confusing. If something confuses you, let me know and I'll try my best to answer it.
| import cv2 | |
| import numpy as np | |
| img = np.zeros((100, 300, 3), dtype=np.uint8) | |
| ft = cv2.freetype.createFreeType2() | |
| ft.loadFontData(fontFileName='Ubuntu-R.ttf', | |
| id=0) | |
| ft.putText(img=img, | |
| text='Quick Fox', |