Skip to content

Instantly share code, notes, and snippets.

@TalalMash
TalalMash / Hijacking Wi-Fi Direct for Seamless Wi-Fi Onboarding on Raspberry Pi without using BLE.md
Last active July 7, 2025 17:55
Hijacking Wi-Fi Direct for Seamless Wi-Fi Onboarding on Raspberry Pi without using BLE

Hijacking Wi-Fi Direct for Seamless Wi-Fi Onboarding on Raspberry Pi without using BLE

SoftAP multi-role Issues

Acting as access point and client at the same time

In captive portal applications, specifically when using Wi-Fi onboarding flow over the same Wi-Fi adapter:

  • Windows, iOS and macOS will retry during the disconnection while scanning the same SSID, which works well if the authentication succeeds and connection is established in less than 5 seconds. Otherwise, the user has to be instructed to manually reconnect, breaking UX flow.

  • Android, GNOME, and ChromeOS will disconnect if their connectivity check endpoint does not return 204 at any time during the short period of disconnection.

@TalalMash
TalalMash / USB ethernet gadget on Raspberry Pi OS example compatible with Windows 10 1709+ (driverless), MacOS, iOS 13+, Android.md
Last active June 29, 2025 11:44
USB ethernet gadget on Raspberry Pi OS example compatible with Windows 10 1709+ (driverless), MacOS, iOS 13+, Android

USB ethernet gadget on Raspberry Pi OS compatible with:

  • Windows 10 1709+ (driverless)
  • MacOS
  • iOS 13+
  • Android (RNDIS is used for Android 6 and below) *1
  • Linux (ECM supported *2)

*1 Android will not request for an IP address if gateway is empty or internet is not found after the first connection, requiring a reboot. To mitigate, add captive portal redirect page or toggle airplane mode.

@TalalMash
TalalMash / ytdl.sh
Last active June 28, 2025 17:08
yt-dlp archiver with resolution limit, thumbnail and metadata embeds
#!/bin/sh
#Youtube playlist/video archiver, downloads changes on subsequent run, keeps track in archive.txt file.
#Install yt-dlp from pip: pip install yt-dlp --break-system-packages
#Reopen terminal, run `sh ytdl.sh https://playlistvideourlhere <optional command>`
#Use cookies and remove sleep-interval max-sleep-interval for much faster playlist parsing and speeds.
# --cookies ${COOKIES} \
#https://chromewebstore.google.com/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc
@TalalMash
TalalMash / HDR to SDR with 3D-LUT Example.md
Last active June 14, 2025 22:37
HDR to SDR with 3D-LUT Example

Effective on any OLED display and 600+ nit LCD display, only with good ambient light.

Set color profile to Cinema

Comparision with HDR10+ display, reference on left: image

Comparision without 3D-LUT: Plex tonemapping, Handbrake bt.709, Netflix... ingot is dim and shadows are darker: image

@TalalMash
TalalMash / Flutter PageView: Proper scrolling with Scrollwheel, Touchpad and Touchscreen.dart
Last active June 14, 2025 22:32
Flutter PageView: Proper scrolling with Scrollwheel, Touchpad and Touchscreen
import 'package:flutter/material.dart';
import 'package:flutter/gestures.dart';
import 'dart:async';
import 'dart:io' show Platform;
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:universal_html/html.dart' as html;
bool isDesktop() {
final userAgent = html.window.navigator.userAgent.toString().toLowerCase();
if (kIsWeb) {
@TalalMash
TalalMash / [Klipper] Auto align dual Z-motor Y-axis on first home only once after power up.md
Last active June 14, 2025 22:39
[Klipper] Auto align dual Z-motor Y-axis on first home only once after power up

demo

Requirements:

  • Rigid couplers (use ball bearing inside the coupler for flexible type)
  • Add extra 20mm in your Z limit configuration to allow stepper stalling
  • Physical limiter (e.g a screw in the extrusion on both sides with equal distances)
  • (Optional) Software current control for low noise on stalls; using TMC in this example

Functions:

  • Aligns the two leadscrew-driven motors only once after powerup on the first G28 command until next power cycle.
@TalalMash
TalalMash / [OpenWRT] UBOND Example
Last active April 25, 2023 10:08
[OpenWRT] UBOND Example
Download binaries: https://github.com/TalalMash/ubond/releases/tag/v0.1.1
Disable encryption for 400Mbit+ , force DNS over HTTPS if needed.
Temporarily running as root. (tun bugfix TODO)
----------------------
VPS/crontab -e:
@reboot screen -d -m sh -c "/root/startubond.sh"
----------------------
/root/startubond.sh
----------------------
#!/bin/sh
@TalalMash
TalalMash / [Tasmota] SR-04 Ultrasonic Tank Level measurement rules.txt
Last active June 14, 2025 22:32
[Tasmota] SR-04 Ultrasonic Tank Level measurement rules
Rule1 ON sr04#distance>0 DO Backlog var1=((((%value%*)-20)-(EM-20))/(EM-20))*-100; var2=(var1*0.01)*LT; event sendval ENDON
Rule1 + ON event#sendval DO publish tele/watertank/LEVEL %var1% ENDON ON event#sendval DO publish tele/watertank/VOLUME %var2% ENDON
Rule1 1
Replace:
-LT with the number of liters
-EM with the distance when the tank is empty.
You will get percentage (level) and number of liters, accurate starting from 60cm deep tanks.
SR-04 (water proof) is recommended for use.