This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # Define a storage pool using the libvirt API. | |
| # virsh vol-list <poolname> to verify. | |
| # virsh vol-delete <volname> --pool <poolname> to remove. | |
| import libvirt | |
| import sys | |
| import os |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| let _console_debug = console.debug | |
| console.debug = function(message) { | |
| if (debug) { | |
| _console_debug.apply(console, arguments) | |
| } | |
| } | |
| let debug = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Enable MicroPython WebREPL (Console over Websockets) | |
| from machine import Pin, SoftI2C | |
| from ssd1306 import SSD1306_I2C | |
| from network import WLAN, STA_IF | |
| from webrepl import start | |
| from netcfg import AP_NAME, AP_PASS, WEBREPL_PASS | |
| from ubinascii import a2b_base64 | |
| from time import sleep | |
| i2c = SoftI2C(scl=Pin(4), sda=Pin(5)) # Wemos board with built-in OLED uses pins 4 (clock) & 5 (data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Example of using uasyncio to run a web server. | |
| # The server does nothing but echo back what was sent to it. | |
| # But the point here is to demonstrate the use of uasyncio, callbacks, | |
| # and the mixing of async and regular (synchronous) functions. | |
| import uasyncio | |
| # This is a synchronous function that gets called from inside the async function. | |
| def create_http_response(body): | |
| res_lines = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class GapBuffer: | |
| def __init__(self, size, prefill=None): | |
| self._buffer = bytearray(size) | |
| self._gap_start = 0 # first element of gap | |
| self._gap_end = len(self._buffer) # first element after gap | |
| if prefill != None: | |
| prefill_end = len(prefill) if (len(prefill) <= size) else size | |
| self._buffer[0:prefill_end] = prefill[0:prefill_end] | |
| self._gap_start = len(prefill) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This shell script will back up files from remote systems as well as local | |
| using rsync. Default behavior is to prune any backups older than 90 days, | |
| except for Sundays. This results in daily copies for up to 90 days and weekly | |
| copies for anything older. | |
| Sample crontab entries to back up multiple hosts on a schedule: | |
| 0 6 * * * /media/backup/backup.sh lorum.home | |
| 0 7 * * * /media/backup/backup.sh ipsum.home | |
| 0 8 * * * /media/backup/backup.sh dolor.home |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Create initial directories and files for home automation stack. | |
| BASE_DIR=$(pwd) | |
| ESPHOME_DIR=$BASE_DIR/esphome | |
| HASS_DIR=$BASE_DIR/hass | |
| MOSQUITTO_DIR=$BASE_DIR/mosquitto | |
| NODE_RED_DIR=$BASE_DIR/node-red |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from machine import Pin, SoftI2C, Timer | |
| from ssd1306 import SSD1306_I2C | |
| from network import WLAN, STA_IF | |
| from time import ticks_diff, ticks_ms | |
| from config import WIFI_NAME, WIFI_PASS, WIFI_TIMEOUT | |
| BOOT_BUTTON_GPIO = 9 # ESP32 is 0, ESP32-C3 is 9 | |
| SCREEN_TIMEOUT = 30 # Seconds before blanking OLED | |
| i2c = SoftI2C(scl=Pin(4), sda=Pin(5)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Sample Eclipse Mosquitto config with MQTT Secure and MQTT Secure Websockets. | |
| # You need to provide the server.crt, server.key, and ca-certificates.crt | |
| # Global Options | |
| allow_anonymous true | |
| persistence true | |
| persistence_location /mosquitto/data/ | |
| log_dest stdout | |
| # Standard MQTT |