This file contains 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/python | |
# Script to fetch the current electricity market price in Germany from Tibber's API. | |
# Borrowed from https://github.com/mampfes/ha_epex_spot/blob/main/custom_components/epex_spot/EPEXSpot/Tibber/__init__.py, thanks! | |
import argparse | |
import asyncio | |
import aiohttp | |
from datetime import datetime, timedelta |
This file contains 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/python | |
# Script to fetch the current electricity market price in Germany. | |
# Borrowed from https://github.com/mampfes/ha_epex_spot/blob/main/custom_components/epex_spot/EPEXSpot/SMARD/__init__.py, thanks! | |
import argparse | |
from datetime import datetime, timedelta, timezone | |
import aiohttp | |
import asyncio |
This file contains 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
-- https://livebook.manning.com/book/postgis-in-action-second-edition/chapter-17/242 | |
-- with a couple of bugs fixed | |
CREATE OR REPLACE FUNCTION get_rast_tile( | |
param_format text, -- e.g. 'image/png' | |
param_width integer, -- e.g. 256 | |
param_height integer, -- e.g. 256 | |
param_srid integer, -- e.g. 'EPSG:3857' | |
param_bbox text, -- e.g. '660415.9243839228,3713005.085980721,665307.8941941742,3717897.0557909757' in EPSG:3857 | |
param_schema text, |
This file contains 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
<?php | |
$data = file_get_contents('php://input'); | |
$json = json_decode($data); | |
header("Content-type: application/json"); | |
if ($json->_type !== 'location') { | |
return; | |
} |
This file contains 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
// Reboot after 5 minutes of disconnect | |
let wait_sec = 30; | |
let retries = 10; | |
let c = 0; | |
let timer = Timer.set(wait_sec * 1000, true, function () { | |
Shelly.call('WiFi.GetStatus', null, function (result, error_code) { | |
if (result.status !== 'got ip') { | |
if (c++ < retries) { | |
print('wifi not connected, waiting another', (retries - c) * wait_sec, 'seconds until reboot'); |
This file contains 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/bash | |
# Author: Ferdinand Mütsch <ferdinand@muetsch.io> | |
# Script to determine the next subuid / subgid for a user. | |
# It will consider (a) all already existing subuid / subgid ranges and (b) all "real" user ids. | |
# | |
# Note: When using LDAP login (e.g. with SSSD), /etc/passwd won't contain those external users. | |
# In the case of SSSD, you will have to enable enumeration (https://access.redhat.com/solutions/500433) to make "getent passwd" all local AD / LDAP users. | |
# However, on the other hand, enabling recommendation is not recommended, because it will cause high load on server and client (https://docs.pagure.org/sssd.sssd/users/faq.html#when-should-i-enable-enumeration-in-sssd-or-why-is-enumeration-disabled-by-default). |
This file contains 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
# before: https://anchr.io/i/1NQ3x.png | |
# after: https://anchr.io/i/iMkiK.png | |
# script is interactive | |
# it will first fetch all broken products and then ask you for confirmation before actually updating them | |
import re | |
import sys | |
from typing import Tuple, Set, List, Any, Dict | |
import requests |
This file contains 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
import time | |
if __name__ == '__main__': | |
while True: | |
with open('/sys/class/power_supply/BAT0/current_now', 'r') as f: | |
current = float(f.readline().strip()) | |
with open('/sys/class/power_supply/BAT0/voltage_now', 'r') as f: | |
voltage = float(f.readline().strip()) | |
print(f'{current * voltage / 1000000000000} W', end='\r') |
This file contains 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
http://localhost:8080 { | |
@get method GET | |
@propfind method PROPFIND | |
root * /tmp/data | |
# TODO: add basic auth for DELETE, PROPPATCH, LOCK, etc. | |
# TODO: add matchers so uploaded file keys must be uuids | |
route { |
This file contains 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
Script that will trigger a local to remote sync when any changes below your local Google Drive folder occur - but at max. every 10 minutes - and a remote to local sync every x (e.g. 30 minutes) via a cron job. | |
0. Install rclone and configure it for Google Drive | |
1. Create files listed below | |
2. Configure rclone_watch_local.sh to be run on startup (e.g. using a systemd service unit) | |
3. Add a cron job that runs rclone_remote2local.sh every x (e.g. 30) minutes | |
---------------------- | |
rclone_local2remote.sh | |
---------------------- |
NewerOlder