Skip to content

Instantly share code, notes, and snippets.

blueprint:
name: Motion-activated Light Off
description: Turn off things when no motion is detected. Inspired from from homeassistant - motion_light.yaml
domain: automation
source_url: https://gist.github.com/Mihai-P/5d2266aefaf5d4ddcfdca9cef4080bea
input:
motion_entity:
name: Motion Sensor
selector:
entity:
@Mihai-P
Mihai-P / Ubuntu 20.04 LTS
Last active August 16, 2022 23:36
Ubuntu 20.04 LTS - Installing all the programs I use
This will install all the programs I need in Ubuntu 20.04 LTS
@Mihai-P
Mihai-P / docker.md
Last active July 22, 2021 19:55
Interesting operations

Docker

Connecting to a docker image based on the name of the image

docker exec -i -t $(docker ps -aqf "name=my-image") /bin/bash

Copying something from a docker container based on the image name

docker cp $(docker ps -aqf "name=my-image"):/some-file.txt .
#! /usr/bin/env bash
# creates a JWT in bash
# Static header fields.
HEADER='{
"type": "JWT",
"alg": "RS256"
}'
# PAYLOAD=$1
#!/bin/bash
# to install docker
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable edge test"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose
sudo usermod -aG docker ${USER}
@Mihai-P
Mihai-P / home-button.sh
Created July 5, 2019 00:58
Things to do on a mac to keep your sanity
#follow the instructions from here: https://www.maketecheasier.com/fix-home-end-button-for-external-keyboard-mac/
@Mihai-P
Mihai-P / transmission-purge-completed.sh
Last active April 6, 2024 13:34
Small script to delete any transmission torrents that are complete
#!/bin/sh
# based on this gist https://gist.github.com/pawelszydlo/e2e1fc424f2c9d306f3a
# port, username, password
# if using a seedbox the server can have the format http://SEREVR:PORT/PREFIX/transmission
SERVER="$TRANSMISSION_SERVER -n $TRANSMISSION_USER:$TRANSMISSION_PASS"
# use transmission-remote to get torrent list from transmission-remote list
# use sed to delete first / last line of output, and remove leading spaces
# use cut to get first field from each line
#!/bin/bash
sudo apt-get update
sudo apt-get upgrade
# this may fail, some ditros do not have it installed by default
sudo apt-get remove --purge bcmwl-kernel-source
# this may fail, some ditros do not have it installed by default
sudo rm /etc/modprobe.d/blacklist-bcm43.conf
sudo apt-get install bcmwl-kernel-source
@Mihai-P
Mihai-P / cubox.sh
Last active May 1, 2019 11:13
cubox
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
DEBIAN_FRONTEND=noninteractive apt-get -yq install ddclient
echo Username that you use for noip.com?
read USERNAME
@Mihai-P
Mihai-P / backup.sh
Last active February 3, 2019 10:55 — forked from mihaikelemen/backup.sh
A minimalistic backup tool for MySQL / MariaDB or files with auto-cleanup
#!/bin/bash
#
# A minimalistic backup tool for MySQL or files with auto-cleanup after a certain period, on a Ubuntu or Centos based environments.
# It can handle multiple projects (websites) located on the server where this tool is present. Add one or more *.conf files in the backup.d directory
# For each one of them we generate the md5 checksum.
#
# Requirements:
# - md5sum (usually present by default)
# - tar (usually present by default)
# - mysqldump (it comes with MySQL/MariaDB)