Skip to content

Instantly share code, notes, and snippets.

@manio
manio / wifi-checker.sh
Created March 3, 2025 12:11
sample script which is stopping/starting aawgd based on nearby WiFi network visibility
#!/bin/sh
# this is a sample script which is testing if there is available ESSID on the WiFi
# and according to the result it is starting/stopping aawgd
# more info: https://github.com/nisargjhaveri/WirelessAndroidAutoDongle/issues/212#issuecomment-2692423007
delaytime=5
essid="searchedAPName"
while [ true ]; do
wifiavail='iw dev wlan0 scan|grep SSID'
use std::error::Error;
use std::io;
use rppal::gpio::{Gpio, Trigger}; // 0.16.1
pub const BTN1: u8 = 13;
pub const BTN2: u8 = 4;
fn main() -> Result<(), Box<dyn Error>> {
let mut btns = [
@manio
manio / .zshrc
Created September 24, 2023 16:59
No `man` installed, and want online Archlinux man page?
# as in title - you have no `man` installed but sometimes you need to quick search for a manual page
# add this to your .zshrc
man() {
xdg-open https://man.archlinux.org/man/$1
}
@manio
manio / laptop-battery.service
Created September 6, 2023 15:29
linux systemd service for listening on UDP with netcat and constantly putting the data in temporary file
# This is a systemd service file to be able to monitor battery level on a windows laptop
# The Windows side is described in this gist:
# https://gist.github.com/manio/95ad95dc5eba708b12d658f2e6f478ea
# This unit is listening on specified UDP port and it is writing data
# to specified output file. It is overwriting the data with every new
# UDP frame.
[Unit]
Description=laptop battery monitoring daemon
After=local-fs.target
@manio
manio / battery_level.ps1
Created September 6, 2023 15:06
PowerShell script for sending laptop battery level from Windows10 via UDP to some other host
# ABOUT:
# I needed to have a battery level percentage of my Windows laptop reported to a linux host somehow.
# I am then able to monitor this value and automate switching ON/OFF power supply to keep the laptop
# battery charged in ranges about 20-80%, totaly automatically
# first you need to download this helper script for sending UDP:
# https://gist.githubusercontent.com/PeteGoo/21a5ab7636786670e47c/raw/30cc9ca860154429bcef500fa2d0e96811ad0292/Send-UdpDatagram.ps1
# the scripts neeed to be "unblocked" to be able to run from PowerShell using this method:
#dir .\battery_level.ps1|block-File
@manio
manio / jsn_aj-sr04-ping.rs
Created August 6, 2023 08:54
esp-rs embassy function for reading ultrasonic distance sensor JSN-SR04T / AJ-SR04M using mode 0 (pulse time)
/*
The following snipset is for reading the AJ-SR04M (JSN-SR04T compatible) ultrasonic distance sensor
under rust (esp-rs + embassy).
It is intended for mode 0 (which is the default) and it is counting the resulting echo pulse timing.
Finaly the useconds value is converted to centimeters value.
ESP32 wiring:
Vcc -> 5V
Trigger -> GPIO 19
Echo -> GPIO 21 (via level shifter)
diff --git a/fp-lib-table b/fp-lib-table
index b7032ccc..43ccd284 100644
--- a/fp-lib-table
+++ b/fp-lib-table
@@ -98,6 +98,7 @@
(lib (name Sensor_Current)(type KiCad)(uri ${KISYSMOD}/Sensor_Current.pretty)(options "")(descr "Specialized footprints for current sensors"))
(lib (name Sensor_Motion)(type KiCad)(uri ${KISYSMOD}/Sensor_Motion.pretty)(options "")(descr "Specialized footprints for motion sensors"))
(lib (name Sensor_Pressure)(type KiCad)(uri ${KISYSMOD}/Sensor_Pressure.pretty)(options "")(descr "Specialized footprints for pressure sensors"))
+ (lib (name Sensor_Temperature)(type KiCad)(uri ${KISYSMOD}/Sensor_Temperature.pretty)(options "")(descr "Specialized footprints for temperature sensors"))
(lib (name Sensor_Voltage)(type KiCad)(uri ${KISYSMOD}/Sensor_Voltage.pretty)(options "")(descr "Specialized footprints for voltage sensors"))
@manio
manio / get_humid.c
Created January 11, 2018 17:33
Sample program to obtain a humidity from DS2438
//Sample program to obtain a humidity from DS2438
//more info:
//https://skyboo.net/2017/03/ds2438-based-1-wire-humidity-sensor/
//compile with: gcc -o humid get_humid.c
#include <stdio.h>
void get_humidity()
{
FILE *fp;
# fs_prepare.sh
# more info: https://skyboo.net/2017/04/rpi-creating-a-ram-disk-running-linux-environment-from-nfs-booted-raspbian/
set -x
mkdir -p /usr/lib/arm-linux-gnueabihf
mkdir -p /lib/arm-linux-gnueabihf
cp /old_root/usr/lib/arm-linux-gnueabihf/libarmmem.so /usr/lib/arm-linux-gnueabihf
cp -P /old_root/lib/arm-linux-gnueabihf/libutil* /lib/arm-linux-gnueabihf
cp -P /old_root/lib/arm-linux-gnueabihf/libcrypt* /lib/arm-linux-gnueabihf
cp -P /old_root/lib/arm-linux-gnueabihf/libnss_files* /lib/arm-linux-gnueabihf
#!/bin/sh
# a sample /etc/init.d/rcS script
# more info: https://skyboo.net/2017/04/rpi-creating-a-ram-disk-running-linux-environment-from-nfs-booted-raspbian/
set -x
#prepare a new RAM filesystem copying needed libraries and binaries from the old fs
/old_root/fs_prepare.sh
#ssh server
/usr/sbin/dropbear -s
#convert the openssh key to the dropbear format