Skip to content

Instantly share code, notes, and snippets.

@aigarius
aigarius / imapdrop.py
Created September 2, 2024 20:59
Send email messages from local /var/mail spool folder to IMAP folder (on GMail) avoiding all spam filtering. Script user must have "mail" group.
import imaplib
import logging
import mailbox
import netrc
import getpass
from datetime import datetime, timezone
logging.basicConfig(level=logging.DEBUG)
@aigarius
aigarius / appdaemon_budget_future.py
Created October 24, 2023 20:49
Predict future balance of an asset account considering outstanding salary income, bills and credit card balances/resets
import requests
from datetime import datetime
import appdaemon.plugins.hass.hassapi as hass
app_token = "<FIREFLY_PERSONAL_ACCESS_TOKEN>"
firefly_url = "<FIREFLY_URL>"
main_account_name = "Main account"
salary_amount = 4000
salary_date = 28
@aigarius
aigarius / shelly_with_ha.js
Created April 12, 2023 10:48
Shelly script to revert to direct switch control if Home Assistant is not available
// Preconditions:
// Shelly connected to a manual switch and to a smart light
// Shelly set to disconnected mode and to restore power to on after power loss
// Input mode is button (might need a minor change for switch - untested)
// Shelly is added to Home Assistant
// An automation is created in Home Assistant to toggle the light when single button press is
// detected on the Shelly (other automations may also exist)
let online_status = 0;
// Change this to the URL of your Home Assistant base URL + "/api/ping"
@aigarius
aigarius / date_loop.sh
Last active August 29, 2015 14:20 — forked from chluehr/date_loop.sh
One line date looper script in bash with parallelism option
#!/bin/bash
start="2012-01-20" end="2012-03-02" now=$start; while [ "$now" != "$end" ]; do now=`date +"%Y-%m-%d" -d "$now + 1 day"`; echo $now ;done
sh -c 'start="2012-01-20" end="2012-03-02" now=$start; while [ "$now" != "$end" ]; do now=`date +"%Y-%m-%d" -d "$now + 1 day"`; echo $now ;done' | xargs -n 1 -P 5 -i echo {}