Skip to content

Instantly share code, notes, and snippets.

@dentex
dentex / buzzer.py
Last active March 7, 2017 14:53
Python script I'm using with Raspbian to operate a piezoelectric buzzer (connect the [+] end to a GPIO pin and the [-] to a GND pin)
#!/usr/bin/python -u
"""
MIT License
Copyright (c) 2016 Samuele Rini
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@dentex
dentex / lcd_driver.py
Last active May 11, 2017 07:43
Phython driver and usage script to run a 20x4 LCD (with a PCF8574 I2C backpack) with Raspbian
#!/usr/bin/python -u
# -*- coding: utf-8 -*-
"""
Copyright 2017 Samuele Rini
Modified from:
https://bitbucket.org/ryanteckltd/16x2-python-i2c-lib/
https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=34261&p=378524
@dentex
dentex / Timer.sh
Last active April 14, 2018 11:06
Get a popup window as a timer using zenity
#!/bin/bash
# (C) 2014 Roland Latour, gpl v2
# from http://user.cavenet.com/rolandl
# uses zenity to create/move popup window as a timer
###################################################################
# modified by Samuele Rini
#
# https://github.com/dentex/
# https://dentex.github.io/
@dentex
dentex / dnsdynamic_update.sh
Created May 10, 2018 17:40
Bash script to update a dnsdynamic.org domain with your machine's current external IP.
#!/bin/bash
# script name
SC=`basename $0`
############### CONFIG ################
user="<<DNSDYNAMIC-ACCOUNT-EMAIL>>"
pw="<<DNSDYNAMIC-ACCOUNT-PASSWD>>"
domain="<<DNSDYNAMIC-DOMAIN-TO-UPDATE>>"
@dentex
dentex / lirc-pi3.txt
Created September 25, 2018 16:44 — forked from prasanthj/lirc-pi3.txt
Getting lirc to work with Raspberry Pi 3 (Raspbian Stretch)
Notes to make IR shield (made by LinkSprite) work in Raspberry Pi 3 (bought from Amazon [1]).
The vendor has some documentation [2] but that is not complete and sufficient for Raspbian Stretch.
Following are the changes that I made to make it work.
$ sudo apt-get update
$ sudo apt-get install lirc
# Add the following lines to /etc/modules file
lirc_dev
lirc_rpi gpio_in_pin=18 gpio_out_pin=17
@dentex
dentex / sgs2cmd_bot_gh.py
Last active October 13, 2020 22:59
SGS2cmdBot: a Python Telegram bot to remotely control an old Samsung Galaxy S2 used as IP cam
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
code adapted from https://github.com/ade1963/RaspberrySensorsBot
working on a Samsung Galaxy S2 (GT-I9100), with Lineage OS 14.1
dependencies to install on the SGS2:
IP Webcam android app -> https://play.google.com/store/apps/details?id=com.pas.webcam
QPython -> https://play.google.com/store/apps/details?id=org.qpython.qpy
@dentex
dentex / button_long-press_test.py
Last active March 5, 2023 12:50 — forked from jedie/button_test.py
microPython button irq long-press detection
import time
from micropython import const
from machine import Pin
BUTTON_A_PIN = const(17)
class Button:
@dentex
dentex / digispark_rotary-encoder-Krita.ino
Created December 30, 2020 09:36
Arduino sketch to Zoom in/out view and increase/decrease brush size in Krita, using a Digispark ATtiny85 board
/*
* Kritary - Krita Rotary Zoom and Brush Size Controller
* [Using a Digispark (ATtiny85) and a rotary encoder]
*
* Copyright (C) 2020 Samuele RINI <samuele.rini76 [AT] gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
@dentex
dentex / script-launcher.sh
Created April 27, 2022 14:22
Simple personal scripts launcher, using Zenity
#!/bin/bash
# Scripts location directory
scr_dir="$HOME/bin/script-launcher.d"
# Search for executable files only in "$scr_dir" and store them in an array:
arr=( `find $scr_dir/* -type f -executable -printf '%f\n' | sort -n` )
# Show `zenity` list dialog
scr=$(zenity --width 400 --height 520 --list --title "Scripts Launcher" --text "Select the script to be executed" --radiolist --column "" --column "scripts list" `for item in ${arr[*]}; do printf "%s\n" FALSE $item; done` 2>/dev/null)
@dentex
dentex / rm_from_db.sh
Last active July 27, 2023 10:50
Remove specified DOMAINS or CLIENTS from the pi-hole logs and long term data
#!/bin/bash
usage() {
echo "***************************************************"
echo "Valid commands are: 'remove' OR 'search'"
echo ""
echo "'remove' accepts the parameters: 'domain' OR 'client'"
echo -e " 'domain' accepts a domain's name (list) in the form:\n google.it\n it.somesite.com\n %anothersite.com (wildcard for subdomains)"
echo -e " 'client' accepts: a client IP (list) in the form:\n 192.168.1.xxx"