Skip to content

Instantly share code, notes, and snippets.

@7wells
7wells / boot.sh
Created March 25, 2024 17:45 — forked from ThePlenkov/boot.sh
Resolve WSL DNS automatically
#!/bin/bash
# Remove existing "nameserver" lines from /etc/resolv.conf
sed -i '/nameserver/d' /etc/resolv.conf
# Run the PowerShell command to generate "nameserver" lines and append to /etc/resolv.conf
# we use full path here to support boot command with root user
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command '(Get-DnsClientServerAddress -AddressFamily IPv4).ServerAddresses | ForEach-Object { "nameserver $_" }' | tr -d '\r'| tee -a /etc/resolv.conf > /dev/null
@7wells
7wells / gist:ab7b61276e9b2fa048dd231341e55c02
Last active March 15, 2024 18:09
How to build Lineage OS 17.1 for Lenovo Tab4 10 Plus (TBX704)
#### How to build Lineage OS 17.1 for Lenovo Tab4 10 Plus (TBX704)
## References
# https://wiki.lineageos.org/devices/bacon/build
# https://xdaforums.com/t/how-to-build-lineageos-17-1-for-the-lenovo-tab4-10-plus.4275983
# Credits to: Ecthelion4 (see 2nd link)
## Prerequisites
@7wells
7wells / gist:4f8bd463cfe89879faaed2c2c98027f8
Last active March 15, 2024 18:10
How to create a shortcut in Windows startup folder for Pageant incl. encrypted keys
#### How to create a shortcut in Windows startup folder for Pageant incl. encrypted keys
## References
# https://stackoverflow.com/questions/31814060/create-a-shortcut-with-parameters-added-to-the-program-path
# The below batch file creates a temporary vbs script, executes it to create the startup entry
# for pageant, and it cleanly deletes the temporary vbs file afterwards. As shown in the example,
# you can add multiple keys in `Arguments`. Replace them by your key file name(s). You might also need
@7wells
7wells / gist:f32fa8f703cdab46b04c32e693bbae22
Created November 18, 2022 11:14
FHEM - How to ensure that ser2net starts not too early
# How to ensure that ser2net starts not too early (ie. not before the device is recognized)
#
sudo nano /lib/systemd/system/ser2net.service
# Add the following 2 lines in the [Unit] section:
After=network-online.target
Wants=network-online.target
# See also there: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1000622
@7wells
7wells / gist:2b94161e94083e863f41278ed6d6a0e5
Last active December 19, 2022 17:11
FHEM - How to define Tecalor THZ heatpump
# How to define Tecalor THZ heatpump:
#
define Mythz THZ <IP of device connected to heatpump>:2000
define FileLog_Mythz FileLog ./log/Mythz-%Y.log Mythz
attr Mythz interval_sDHW 600
attr Mythz interval_sHC1 600
attr Mythz interval_sGlobal 600
attr Mythz interval_sElectrDHWDay 3600
attr Mythz interval_sHeatDHWDay 3600
attr Mythz interval_sHeatRecoveredDay 3600
@7wells
7wells / gist:44009826a9c30a08c47abab7e59a18de
Last active November 18, 2022 11:01
FHEM - How to enable and set up MQTT2_CLIENT
# How to enable MQTT2_CLIENT:
#
define MyMQTT MQTT2_CLIENT <IP of MQTT server>:1883
# How to set MQTT user name:
#
Go to FHEM => MyMQTT => attr MyMQTT
Select 'username' from drop-down menu (under 'MQTT2_CLIENT' heading)
Enter username in empty field and hit [Return] key
@7wells
7wells / gist:06aa69f98d8dad2c864ca4a3798dab5f
Last active October 24, 2023 17:05
FHEM - How to add menu entries to FHEM's WebGUI
# How to add menu entries to FHEM's WebGUI:
#
# Click "Edit files" in navigation bar, then click on fhem.cfg
# In the new window, add following line to fhem.cfg (consider making a backup of fhem.cfg first):
attr WEB menuEntries Update,cmd=update,UpdateCheck,cmd=update+check,Restart,cmd=shutdown+restart
# To also add a menu entry for log file deletion, define an alias for the deletion command and add the menu entry, e.g.:
#
define c_dellog cmdalias dellog AS {qx(truncate $currlogfile --size 0);;Log 1, "logfile deleted";;}
@7wells
7wells / gist:d074817e8b13d5c728010e917e377433
Last active November 18, 2022 10:55
FHEM - disable write protection for fhem.cfg
# Enter following command to disable write protection for fhem.cfg (consider making a backup of fhem.cfg)
#
attr WEB editConfig 1
@7wells
7wells / gist:2433be8755ca0d133e5d1b9413ca96b4
Last active October 26, 2022 09:26
How to use scrcpy and adb via Wifi to mirror mobile device screen on PC/laptop
# Connect mobile device to PC/laptop via USB
# Connect to your Wifi network (PC/laptop and mobile device must be in the same Wifi)
# Enter command:
adb kill-server
# Enter command:
adb usb
@7wells
7wells / gist:aaaaeb53ed688edbd5625419347f54bc
Last active October 1, 2022 14:27
Testing mosquitto broker and client on Raspberry Pi OS
# How to test mosquitto broker and client on Raspberry Pi OS
#
# Source: https://randomnerdtutorials.com/testing-mosquitto-broker-and-client-on-raspbbery-pi/
#
# Install mosquitto clients (if not already installed together with mosquitto broker)
#
sudo apt install mosquitto-clients
# Subscribe to topic "testTopic"