Skip to content

Instantly share code, notes, and snippets.

View xirixiz's full-sized avatar

Bram van Dartel xirixiz

View GitHub Profile
@xirixiz
xirixiz / OpenWRT TTL manipulation on a travel router explained.md
Last active July 10, 2024 03:52
OpenWRT TTL manipulation on a travel router explained

OpenWRT TTL manipulation on a travel router explained


Setting the TTL to 65 can help solve OpenWRT hotel captive portal issues on a travel router because of the way captive portals often track and manage connected devices.

Here’s an explanation of the key reasons:

Device Differentiation:
Captive portals typically recognize and manage devices based on their MAC addresses and IP addresses. When you connect a device (like a laptop or phone) directly to the hotel's network, the captive portal captures the MAC address of that device and redirects it to a login page.
@xirixiz
xirixiz / espeasy
Last active January 9, 2022 22:07
ESP Home - Mertik Maxcontrol - HASS - Home Assistant - Bellfires
ESPeasy rules
//GIO14 == Relay 1 = blauw
//GPIO12 == Relay 2 = geel
//GPIO13 == Relay 3 = oranje
on IGNITION do
// Close relays contacts
gpio,14,1
gpio,13,1
timerSet 1,1 // 1 second delay
@xirixiz
xirixiz / Makefile.ask_passwd
Created November 24, 2021 12:34 — forked from hyamamoto/Makefile.ask_passwd
asking a password in a makefile.
ask_password:
@$(eval PASSWORD=$(shell stty -echo; read -p "Password: " pwd; stty echo; echo $$pwd))
echo $(PASSWORD)
ask_password_twice:
while true; do \
read -s -p "Password: " password; \
echo; \
read -s -p "Password (again): " password2; \
@xirixiz
xirixiz / reverse_filename.sh
Created April 7, 2021 19:32
Reverse Filname Script
#!/bin/bash
# Change to current dir.
cd "$(pwd)"
# Check if a parameter is given
if [[ -e $1 ]]
then # if a selection is found, just count the files in that selection
files="$1"
total=$(ls "$files" | wc -l)
# export private keys
gpg --export-secret-keys --armor > gpg-private.keys
# import private keys
gpg --import gpg-private.keys
# export public keys
gpg --export --armor > gpg-public.keys
# import public keys
@xirixiz
xirixiz / bashrc
Last active December 15, 2021 15:25
tmux.conf based on Byobu (keyboard shortcuts as well). tmux >2.9 required!
# Put in ~/.bashrc | then source ~/.bashrc
if [[ -z "${TMUX}" ]] && [[ "${UID}" != 0 ]]; then
tmux new-session -A -s 0
fi
@xirixiz
xirixiz / ventilation.yaml
Created February 21, 2021 15:11 — forked from SqyD/ventilation.yaml
ESPHome PWM fan using a Wemos D1 mini lite
# Controlling my Buva Qstream ventilation system using:
# * A Wemos D1 mini lite (an ESP8266 based board)
# * A Wemos power shield so I can power the Wemos from the ventilation units 12V supply.
# * A simple PWM to 10V convertor like this: https://www.cheaptech.nl/pwm-signaal-te-voltage-converter-1-3-khz-0-10-v-pw.html
# * The amazing ESPHome firmware tool: https://esphome.io
# * Home Assistant to tie it all together: https://www.home-assistant.io
#
# I used to use a Raspberry Pi and some Python code for this. See https://gist.github.com/SqyD/a927ab612df767a0cc892bcde23d025c
# The Wemos approach seems more stable and doesn't require external USB power.
# Bram van Dartel: Fix WSL2 network connection after setting up a Cisco Anyconnect VPN.
# Boot your laptop, start Docker and WSL2, setup a Cisco Anyconnect VPN connection, run this fix.
function Fix-WSLNet {
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1
Get-NetAdapter | Where-Object { $_.InterfaceDescription -Match "Cisco AnyConnect" } | Set-NetIPInterface -InterfaceMetric 6000
}
Fix-WSLNet
@xirixiz
xirixiz / UGW3_Wireguard.md
Last active February 25, 2024 22:12 — forked from pamolloy/README.md
Ubiquiti USG configuration for Wireguard

The purpouse is to have a WireGuard server running with a configuration for 2 clients to connect to the WireGuard server.

Installation - First steps

Follow the instructions for downloading and installing the WireGuard package here: https://github.com/WireGuard/wireguard-vyatta-ubnt

curl -OL https://github.com/WireGuard/wireguard-vyatta-ubnt/releases/download/${RELEASE}/${BOARD}-${RELEASE}.deb
sudo dpkg -i ${BOARD}-${RELEASE}.deb
#!/bin/python2s
# Symbolic name, meaning all available interfaces
VAR_HOST = ""
# Arbitrary non-privileged port
VAR_PORT = 9003
import socket
import sys