Skip to content

Instantly share code, notes, and snippets.

@ondrejh
ondrejh / ctrltab.y
Created November 16, 2021 14:28
Script emulating CTRL+TAB pressing every 10 seconds.
#!/usr/bin/python3
from pynput.keyboard import Key, Controller
from time import sleep
if __name__ == "__main__":
keyboard = Controller()
@ondrejh
ondrejh / skluzavka.ino
Created May 25, 2021 12:43
Arduino based water pump timer with signalisation and safety float switch.
/**
* Casovy spinac pro cerpadlo na skluzavku do bazenu. Cerpadlo se zapne na 15s po stisku tlacitka. Kontrolka sviti. Poslednich 5s blika.
* Pokud je malo vody (plovakovy spinac), cerpadlo se nezapne a kontrolka blika rychle.
*/
#define CAS_ZAPNUTI 15000 //ms
#define CAS_BLIKANI 5000 //ms
#define CAS_CHYBY 1000 //ms
#define BLIKANI_POMALE 500 //ms
@ondrejh
ondrejh / lamp_install.md
Created December 24, 2020 07:38
LAMP installation

Install Apache

sudo apt update
sudo apt install apache2

Install MySQL

@ondrejh
ondrejh / rainbow.ino
Created November 29, 2020 07:59
Slowly changing color light strip using arduino and neopixels
/**
* Slowly changing color light strip using arduino and neopixels. Suitable for mood lights.
* recent usage: sauna pool downlight, advent candlestick ..
*/
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
@ondrejh
ondrejh / servo_limiter.ino
Last active May 2, 2020 15:10
Servo limiter - limits servo signal to 25% (HW - Arduino Pro Mini)
/**
* Program reads servo signal on "input", changes its aplitude by 25% and sends it to "output".
* It is used for limiting RC car power - for kids.
*/
// input and output pin
const int input = 2;
const int output = 3;
const int led = LED_BUILTIN;
@ondrejh
ondrejh / pull.py
Last active May 30, 2019 19:52
first succesfull sdm120 module communication
#!/usr/bin/env python3
# http://www.eastrongroup.com/data/uploads/Eastron_SDM120-Modbus_user_manual_2016_V2_6.pdf
# http://www.eastroneurope.com/media/_system/tech_specs/3914/SDM120%20PROTOCOL.pdf
from serial import *
from time import sleep
PORT_NAME = "/dev/ttyUSB0"
@ondrejh
ondrejh / mountnfs.sh
Created January 29, 2014 10:43
Bash script: Wakeup and mount NFS server.
#!/bin/bash
#
# This script should do:
#
# 1) test if nfs folder is mounted and exit 0 if yes
# 2) try to mount it and exit 0 if success
# 3) try to wake the server if not possible to mount
# 4) wait while its not woked (pinging)
# 5) try againt 2-4 several times