Skip to content

Instantly share code, notes, and snippets.

@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
# root2ram.sh
# more info: https://skyboo.net/2017/04/rpi-creating-a-ram-disk-running-linux-environment-from-nfs-booted-raspbian/
set -x
#uncomment following 2 lines to have a network in qemu:
#ip route del default
#ip route add default via 10.0.2.2 dev eth0
#setting time from NTP as the first step, otherwise all created files/dirs will have a bad dates
/usr/src/ntpclient/ntpclient -n -d -c1 -s ntp.task.gda.pl
@manio
manio / waga.sh
Created March 8, 2017 07:48
a simple bash script for weight logging automation to myfitnesspal and influxdb
#!/bin/bash
# a simple bash script for weight logging automation
# more info: https://skyboo.net/2017/03/automate-my-weekly-weight-logging/
if [[ $# -eq 0 ]]; then
echo "[*] ERROR: missing weight argument"
exit
fi
echo "[*] **** MyFitnessPal ****"