Skip to content

Instantly share code, notes, and snippets.

@sevenissimo
sevenissimo / fusionsolar.huawei.com.js
Last active October 1, 2025 10:28
JavaScript snippets to download energy data (injected/withdrawn from e-distribuzione, or produced from Huawei inverter) in CSV format.
(async function() {
'use strict';
const wait = s => new Promise(fn => setTimeout(fn, Math.random() * s * 1000 + 500));
const isoStr = d => [d.getFullYear(), String(d.getMonth() + 1).padStart(2, '0'), String(d.getDate()).padStart(2, '0')].join('-');
const csvRow = (s, arr) => (s + ';' + arr.map(e => String(e).replace('--', '0').replace('.', ',')).join(';'));
const header = 'Giorno;'+Array.from({length:96}, (_, i) => new Date(i * 9e5).toLocaleTimeString('it-IT',{timeZone:'UTC'})).join(';');
let station;
@sevenissimo
sevenissimo / bundle.py
Created July 4, 2025 08:01
OrcaSlicer Preset Helpers
import os
import json
import sys
from time import time
def bundle(path):
def ls(path, sub):
files = []
path = os.path.join(path, sub)
if os.path.exists(path):

Run commands as Systemd (Dynamic)User

My Systemd unit uses User=hass, but user is reasonably locked. su, sudo or runuser are not aplicable.

Install packages in Python venv

systemd-run --uid=$(id -u hass) --gid=$(id -g hass) /usr/bin/python -m venv /var/lib/hass/.venv && /var/lib/hass/.venv/bin/pip install packaging

Check Home Assistant config

systemd-run --uid=$(id -u hass) --gid=$(id -g hass) /usr/bin/python -m venv /var/lib/hass/.venv && /var/lib/hass/.venv/bin/hass --config /var/lib/hass/ --script check_config -i -f

@sevenissimo
sevenissimo / README.MD
Created July 7, 2024 14:19
Custom Pacman repository

For the purposes of this example, we assume the local repository custom is located in /home/custompkgs.

Append a section for the local repository to /etc/pacman.conf

   [custom]
   SigLevel = Optional TrustAll
   Server = file:///home/custompkgs

Create the repository root and database:

@sevenissimo
sevenissimo / smb.conf
Created July 7, 2024 03:48
Default smb.conf from Git 2024-07-07
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options (perhaps too
# many!) most of which are not shown in this example
#
# For a step to step guide on installing, configuring and using samba,
# read the Samba-HOWTO-Collection. This may be obtained from:
# http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
#
# Many working examples of smb.conf files can be found in the
@sevenissimo
sevenissimo / IPv6Tunnel.ps1
Created July 1, 2024 08:00
A PowerShell script to activate (and update) a 6-in-4 tunnel in Windows 10/11 using Hurricane Electric IPv6 Tunnel Broker
$TunnelName = "IPv6Tunnel"
$TunnelID = "123456"
$ServerIPv6Address = "2001:a:b:c::1"
$ServerIPv4Address = "200.1.2.3"
# When behind a firewall appliance that passes protocol 41,
# use the IPv4 address you get from your appliance's DHCP service
# instead of the IPv4 endpoint you provided to Tunnelbroker
@sevenissimo
sevenissimo / mktempfifo.sh
Created June 6, 2024 15:39
Setup temporary FIFO, ensure cleanup
# Setup FIFO
mkfifo ${f:=$(mktemp -u)}
trap "rm -f $f" EXIT
exec {fd}<>$f # Needed to enable FIFO
@sevenissimo
sevenissimo / openmiio_agent.lua
Created March 3, 2024 09:54
Disable buzzer when switch alarm type (issue #1279)
function miio_request(from, method, req)
-- Disable buzzer when switch alarm type (issue #1279)
if from == 32 and method == "local.status" and req:find("alarm_long_one") then
return nil
end
end
#!/usr/bin/env bash
#set +x
# Create an array named as param ($1) or 'FOO'
# and fill it with random numbers without naming it
rand() {
declare -n ref="${1:-FOO}"
for i in {1..10}; do
ref[$i]=$RANDOM
done
#!/bin/bash
#set -x
function job {
: ${RANDOM:0:2}
sleep $_ && echo "Job $1 done in $_ sec"
}
for n in {1..12}; do
if [[ ${jobs:=0} -ge 3 ]]; then