Skip to content

Instantly share code, notes, and snippets.

Avatar
🤷‍♂️
lol

Nick Pettazzoni pettazz

🤷‍♂️
lol
View GitHub Profile
@pettazz
pettazz / home-assistant.service
Created Nov 15, 2020
home-assistant systemd unit
View home-assistant.service
[Unit]
Description=Home Assistant service
Requires=docker.service
After=docker.service
[Service]
Restart=always
User=hassio
Group=hassio
@pettazz
pettazz / docker-compose.yml
Created Nov 15, 2020
home-assistant docker-compose.yml
View 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 / convert_mdb.sh
Last active Jun 16, 2020
boy is this some extremely specific shit huh
View convert_mdb.sh
#!/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 / brightness.sh
Last active Jan 19, 2020
Set the brightness on certain Raspberry Pi compatible screens as a percentage
View brightness.sh
#!/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 / button-handler.js
Last active Jul 29, 2018
AWS Lambda function to be triggered by an IoT button click, sends a message to SQS consumed by a homebridge server
View button-handler.js
/**
* 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 / today-i-learned-xargs.sh
Created Jun 7, 2017
copy an existing file to a bunch of subdirectories
View today-i-learned-xargs.sh
ls parent-dir/ | xargs -I{} -n 1 cp my-cool-file.tgz parent-dir/{}/
@pettazz
pettazz / clicks_for_vic.py
Created Apr 29, 2017
A great way to run out of memory quick
View clicks_for_vic.py
import threading
import time
from selenium import webdriver
TOTAL_WORKERS = 10
TWITTER_USER = 'butts'
TWITTER_PASSWORD = 'bu77s'
def worker():
@pettazz
pettazz / osto.us-yxorp-ssl.conf
Last active Apr 16, 2019
Reverse SSL proxy apache config
View osto.us-yxorp-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName osto.us
ServerAlias osto.us
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
@pettazz
pettazz / butwhy.php
Created Mar 13, 2017
png image from hex string
View butwhy.php
<?php
$data = 'blah';
$data = hex2bin($data);
header('Content-Type: image/png');
imagepng(imagecreatefromstring($data));
?>
@pettazz
pettazz / transmission-cleanup.py
Last active Apr 5, 2019
Delete and remove files for any seeding torrents that have been idle for some number of days
View transmission-cleanup.py
import datetime
import transmissionrpc
from config import TRANSMISSION
daemon = transmissionrpc.Client(
address=TRANSMISSION.server,
port=TRANSMISSION.port,
user=TRANSMISSION.user,
password=TRANSMISSION.password)