Skip to content

Instantly share code, notes, and snippets.

View pettazz's full-sized avatar
🤷‍♂️
lol

Nick Pettazzoni pettazz

🤷‍♂️
lol
View GitHub Profile
@pettazz
pettazz / today-i-learned-xargs.sh
Created June 7, 2017 22:34
copy an existing file to a bunch of subdirectories
ls parent-dir/ | xargs -I{} -n 1 cp my-cool-file.tgz parent-dir/{}/
@pettazz
pettazz / button-handler.js
Last active July 29, 2018 19:47
AWS Lambda function to be triggered by an IoT button click, sends a message to SQS consumed by a homebridge server
/**
* This is a sample Lambda function that sends a message to an SQS queue
* when an IoT button is pressed. The message format is defined by the
* homebridge-sqs plugin: https://www.npmjs.com/package/homebridge-sqs
*
* The following JSON template shows what is sent as the payload:
{
"serialNumber": "GXXXXXXXXXXXXXXXXX",
"batteryVoltage": "xxmV",
"clickType": "SINGLE" | "DOUBLE" | "LONG"
@pettazz
pettazz / transmission-cleanup.py
Last active April 5, 2019 15:45
Delete and remove files for any seeding torrents that have been idle for some number of days
import datetime
import transmissionrpc
from config import TRANSMISSION
daemon = transmissionrpc.Client(
address=TRANSMISSION.server,
port=TRANSMISSION.port,
user=TRANSMISSION.user,
password=TRANSMISSION.password)
@pettazz
pettazz / osto.us-yxorp-ssl.conf
Last active April 16, 2019 11:13
Reverse SSL proxy apache config
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName osto.us
ServerAlias osto.us
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
@pettazz
pettazz / brightness.sh
Last active January 19, 2020 17:58
Set the brightness on certain Raspberry Pi compatible screens as a percentage
#!/usr/bin/env bash
if ! [[ $1 =~ ^-?[0-9]+$ ]]; then
echo "Percentage must be an integer" 1>&2
exit 1
fi
if (( $1 < 0 || $1 > 100 )); then
echo "Percentage value must be at least 0 or at most 100" 1>&2
exit 1
@pettazz
pettazz / convert_mdb.sh
Last active June 16, 2020 18:14
boy is this some extremely specific shit huh
#!/usr/bin/env bash
######################################################################
# #
# da config zone #
# #
######################################################################
# where to put all the converted files, relative to where this script lives
OUTPUT_DIR="output-dir"
@pettazz
pettazz / reset_vms.sh
Last active November 9, 2020 09:01
bash script for deleting and re-cloning VirtualBox VMs from existing base images
#!/bin/bash
function reset_vm {
echo -e "\e[0;32m\n\nresetting $1...\n\n\e[00m"
echo -e "\e[0;34mpoweroff\e[00m"
vboxmanage controlvm "$1 - active" poweroff
sleep 5s
echo -e "\e[0;34munregister\e[00m"
vboxmanage unregistervm "$1 - active" --delete
echo -e "\e[0;34mclone\e[00m"
@pettazz
pettazz / docker-compose.yml
Created November 15, 2020 18:54
home-assistant docker-compose.yml
version: '2'
services:
homeassistant:
container_name: home-assistant
image: homeassistant/home-assistant:stable
volumes:
- /opt/home-assistant/config:/config
devices:
- /dev/ttyUSB1:/dev/ttyUSB1
environment:
@pettazz
pettazz / home-assistant.service
Created November 15, 2020 18:55
home-assistant systemd unit
[Unit]
Description=Home Assistant service
Requires=docker.service
After=docker.service
[Service]
Restart=always
User=hassio
Group=hassio
#!/bin/bash
UNRAR_LOG="/config/unrar.log"
UNRAR_DESTINATION="$TR_TORRENT_DIR"
echo "unrar for $TR_TORRENT_NAME, in $UNRAR_DESTINATION" >> $UNRAR_LOG
cd $UNRAR_DESTINATION;
if [ -n "$TR_TORRENT_NAME" ]; then