Skip to content

Instantly share code, notes, and snippets.

@adrianmihalko
adrianmihalko / miflora-domoticz.py
Created December 10, 2017 14:30
Miflora Domoticz
#!/usr/bin/env python3
#usage:
#python3 ./miflora-domoticz.py --idx_temp 61 --idx_lux 62 --idx_moist 63 --idx_cond 64 --backend gatttool poll C4:7C:8D:63:7A:11
import argparse
import re
import logging
#domoticz
@adrianmihalko
adrianmihalko / update.sh
Created January 13, 2018 17:38
Letsencrypt update script, restart service if success and notify with ssmtp
SERVER="Ubuntu (192.168.1.54)"
EMAIL='hello@gmail.com'
ALERTMESSAGE='/tmp/ALERTMESSAGE_cert.tmp'
if /usr/bin/openssl x509 -checkend 86400 -noout -in /etc/letsencrypt/live/my.domain.eu/fullchain.pem
then
echo "Certificate is good for another day!"
else
echo "To: $EMAIL" > $ALERTMESSAGE
@adrianmihalko
adrianmihalko / gist:ff01b7b3c0321d0fcb1cfa9935ea6ff2
Created January 11, 2019 14:10
Custom DDNS on Ubiquiti USG for specific interface
/etc/cron.hourly/ddns:
#!/bin/bash
YDNS_USER=
YDNS_PASSWD=
HOST=.ydns.eu
INTERFACE=pppoe0
IP=$(ip address show ${INTERFACE} | grep 'inet ' | awk '{print $2}')
curl --basic -u "$YDNS_USER:$YDNS_PASSWD" --silent "https://ydns.io/api/v1/update/?host=${HOST}&ip=${IP}"
@adrianmihalko
adrianmihalko / gist:dfab154681775538087d97baf704f990
Created January 15, 2019 21:36
Esphomeyaml Sonoff S20 for Home Assistant
This configuration allows you to use physical button on your Sonoff S20, add one button to Home Assistant and for safe turn off after x minutes.
esphomeyaml:
name: sonoffs20_esphomeyaml_1
platform: ESP8266
board: esp01_1m
wifi:
ssid: ''
password: ''
@adrianmihalko
adrianmihalko / sonoff.yaml
Last active January 28, 2019 20:58
Sonoff, Esphome
esphomeyaml:
name: sonoff_1
platform: ESP8266
board: esp01_1m
wifi:
ssid: ''
password: ''
manual_ip:
@adrianmihalko
adrianmihalko / gist:cfc076b28a3ff4652766a295972a9945
Created February 6, 2019 21:58
Convert all white transparent icons into transparent black (change icon color)
for f in *.png ; do convert "$f" -fill black -colorize 100 "${f%.png}.png" ; done
@adrianmihalko
adrianmihalko / networkmap1.png
Last active April 30, 2022 15:07
wireguard edgerouter mullvad config
!!!NOT WORKING!!!
configure
set interfaces wireguard wg0 address 10.xx.xxx.253/32
set interfaces wireguard wg0 listen-port 51820
set interfaces wireguard wg0 route-allowed-ips false
set interfaces wireguard wg0 peer JuE+ endpoint mullvadserverip:51820
set interfaces wireguard wg0 peer JuE+ allowed-ips 0.0.0.0/0
@adrianmihalko
adrianmihalko / agistfile1.txt
Last active August 29, 2022 03:41
Selective routing trough VPN with Unifi USG.
I wanted to route only specific IPs trough a Wireguard interface. I am not expert in any way, but I am trying to explain you as best I can how I did it.
Setup a WG connection as usual on one of your device in your network (In my example I will call it "Ubuntu server", 192.168.1.54):
[Interface]
Address = something/24
PrivateKey = longprivatekeyR5FE=
Table = 43
PostUp = ip rule add from 192.168.1.91 table 43; iptables -w -A FORWARD -i %i -j ACCEPT; iptables -w -A FORWARD -o %i -j ACCEPT; iptables -w -t nat -A POSTROUTING -o ens160 -j MASQUERADE; iptables -t nat -A POSTROUTING -o %i -j MASQUERADE
@adrianmihalko
adrianmihalko / gist:62ed2ea8dc1f75780d3bf5d2a292cc86
Created February 26, 2021 21:42
One line webserver with request logging with python twisted
python -c 'from twisted.web.server import Site; from twisted.web.static import File; from twisted.internet import reactor; from twisted.python import log; import sys; log.startLogging(sys.stdout); reactor.listenTCP(1990, Site(File("."))); reactor.run()'
{
"firewall": {
"modify": {
"LOAD_BALANCE": {
"description": "LOAD_BALANCE",
"rule": {
"2501": {
"action": "modify",
"modify": {
"table": "5"